Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

68k assembly - plus symbol on address registers

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?

like image 651
Daniel Sloof Avatar asked Jan 26 '13 13:01

Daniel Sloof


People also ask

Where is the operand value located when a 68K CPU instruction uses the address register indirect mode?

The operand is in memory at the address provided by the value in an address register.

What do you mean by Motorola 68000 explain their mode of operation and addressing mode in brief?

The base address contained in one of the address registers is added to the content of a 16/32-bit register and an 8-bit index. This address mode requires 1 extension word that contains the 8-bit index; only the 8 least significant bits of the extension words are kept and sign-extended to 32-bits before any calculation.

What is the 68000 assembly language?

68000 assembly is the assembly language used for the Motorola 68000, or commonly known as the 68K. It should not be confused with the 6800 (which predates it). The Motorola 68000 is a big-endian processor with full 32-bit capabilities (despite most systems that use it being considered 16-bit.)


2 Answers

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.)

like image 94
Daniel Hedberg Avatar answered Nov 24 '22 19:11

Daniel Hedberg


(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.

like image 43
fdreger Avatar answered Nov 24 '22 18:11

fdreger