I am in the process of learning assembly and using a tutorial to guide me through the learning process. In this case, I am learning the Motorola 68000 to do some programming on the Sega Genesis compiling with VASM.
Take the following snippet:
VDP_ctrl EQU $C00004 ;VDP control, word or longword writes only
MOVE.W (VDP_ctrl),D5 ;$C00004 read VDP status (interupt acknowledge)?
Understanding that MOVE.W
is meant for a 16-bit WORD value into a register (D5
in this case), and $C00004
is a 24-bit hex value, how is this possible? This does compile and works on the Sega emulator Fusion.
For full context, the tutorial is located at https://www.chibiakumas.com/68000/helloworld.php#LessonH1
Book to follow along: https://www.amazon.com/gp/product/B08W7DWZB3
There's no 24-bit data being manipulated here. What is 24-bit is the address. The instruction
MOVE.W (VDP_ctrl),D5
is moving data between the word at the address VDP_ctrl
and the register D5
.
Note the parentheses. In assembly, these are often used to indicate a level of indirection. Similarly, (A0)
indicates that data is being accessed at the address held in A0
, as opposed to the contents of A0
itself:
MOVEA.L D0, A0 ; Copies the contents of D0 into A0 (most assemblers accept MOVE.L)
MOVE.L D0, (A0) ; Copies the contents of D0 into the longword at address A0