Question

While reverse engineering something for fun, I came across the following piece of assembly:

move.b  (a1)+,(a0)+

I understand that the parentheses mean 'value of', but what does the plus symbol stand for? How would I accurately translate this to C?

Was it helpful?

Solution 2

(a1)+ accesses memory at a1 and increments a1 by the size of the operation. In this case 1. What you have looks like a part of a typical loop that copies memory.

OTHER TIPS

The parentheses mean indirect addressing and the + means post-increment. In this case both a1 and a0 will be increased by the size of the operation after the instruction is executed. Another common addressing mode is indirect addressing with pre-decrement, -(An).

The typical use for a move instruction where indirect addressing with post-increment is used for both the source and destination register is to copy data from one memory location to another in a loop.

The Programmer's Reference Manual is invaluable for any M68000 programmer.

In C, *a0++ = *a1++; for char *a0, *a1 variables. The loop body for a classic simplistic memcpy going only 1 byte at a time. (For larger copies, you'd prefer move.w or move.l, or a more optimized memcpy implementation.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top