Working With Data
In T32, data movement is half the story. Since there is only one general-purpose
register, it helps to get comfortable with the flow between A, DP, memory,
and the stack.
Reading and writing memory
The pair LDA and STA are your basic memory tools.
LDP value
LDA
ADI 1
STA
This sequence:
- points
DPatvalue - loads
mem[DP]intoA - adds
1 - stores the result back into memory
Walking through memory
Use IDP and DDP to move the data pointer.
LDP buffer
LDA
IDP
LDA
This reads two adjacent bytes from memory.
Immediate values
Use immediate instructions when the value is known directly in the code:
LDI imm8ADI imm8SBI imm8CMI imm8
These are often the simplest way to bring constants into a program.
Splitting and rebuilding DP
T32 lets you inspect or modify the low and high bytes of DP:
LDL: copyAinto the low byte ofDPLDH: copyAinto the high byte ofDPSDL: copy the low byte ofDPintoASDH: copy the high byte ofDPintoA
This is useful when you need to compute an address in pieces.
Bitwise operations
T32 includes a compact set of bitwise tools:
ANDORRXORSHLSHR
These all operate through A, usually using mem[DP] as the second operand for
the binary operations.