M68K: writing AND operation result at wrong memory address using address indirect with predecrement
Closed this issue · 3 comments
Description
When using M68K asm and performing AND operation with data register Dn and address register indirect with predecrement mode -(An) the result of the operation is written to wrong address in memory.
Example
move.l #$818081a8, d0
move.l #$1000, a0
move.l d0, (a0)+
move.l d0, (a0)
move.l #$0F0F, d0
and.w d0, (a0)
and.w d0, -(a0)
The first time it performs AND operation and.w d0, (a0) everything seems to be normal, but the next line
and.w d0, -(a0)
outputs the result in unexpected place at memory:
The calculated result is correct but is being written to wrong address space. I am not an expert of M68K asm but it clearly seems to be wrong.
Got déjà vu about this issue: #23 i'm guessing it's a similar issue, i'm checking now
Thank you for reporting! It was an issue where if the pre decrement was used as both destination and source (like in this instruction) then it would decrement twice. There was a check for this already and in fact it does not update the value of the register, but the write to memory is done to the address that was updated twice.
It should be fixed now.
Let me know if it works, in case i'll close the issue

