Instruction
LDAA
Examples
LDAA 10
; load an 8-bit block of data from memory location 10 in accuma
LDAA #10; load the value 10 in accuma
LDAA MEM
; load an 8-bit block of data from memory location MEM in accuma
LDAA #MEM
; ERROR! load the 16-bit address of MEM into accuma
LDAA 0,X
; load an 8-bit block of data from memory location [X + 0] in accuma
LDAA 0,Y
; load an 8-bit block of data from memory location [Y+ 0] in accuma
Other instruction wit same format:
LDAB
STAA
STAB
CMPA (compare a to memory)
CMPB (compare b to memory)
COMA
; invert the bits
COMB
SUBA
;result is stored in a
SUBB
;result is stored in b
ADDA
; result is stored in a
ADDB
; result is stored in b
ADDD
;result is stored in b
SBA
; subtract b from a result is stored in a
CBA
; compare a with a
MUL
MUL
LDD
LDAA 10
; load an 16-bit block of data from memory location 10 in accumD
LDAA #10; load the value 10 in accumD
LDAA MEM
; load an 16-bit block of data from memory location MEM in accumaD
LDAA #MEM
; load the 16-bit address of MEM into accumD
LDAA 0,X
; load an 16-bit block of data from memory location [X + 0] in accumD
LDAA 0,Y
; load an 16-bit block of data from memory location [Y+ 0] in accumD
Other instructions with same format:
STD
STX
STY
LDX
LDY
CPY (compare Y to memory)
CPX (computer X to memory)
TAB
TBA
CLRA
CLRB
TAB
TBA
CLRA
CLRB
CLR
CLR MEM1
CLR 10
CLR 0,X
CLR 0,Y
CLR #10
CLR #MEM
Other instructions with the same format:
INC
DEC
INCA
INCB
INX
INY
;Accuma = Accuma +1
;Accumb= Accumb+1
;Accumx=Accumx+1
;Accumy=Accumy+1
INCA
INCB
INX
INY
;this branches when the result of the last compare operation returned that the first operand was larger. Further, ;this assumes that the numbers
being compared were less than zero. ONLY use this (versus BGT) if you want
;to compare POSITIVE numbers only. This will not handle 2s complement numbers.
LDAA
#10
CMPA
#9
BHI
LABEL
This code will ALWAYS branch to LABEL
LDAA
#100
CMPA
#-128
BHI
LABEL
Even though 100 is greater than -128, this will never branch. The reason is that -128 is represented as positive 128 if we are interpreting the
numbers as unsigned.
Other instructions with the same format:
BLO
BGT
BLT
BEQ
JMP
BRA
NOTE: never use BRA. The reason is that BRA has a strict limit on the distance that it can branch (and it isnt that far). Thus, if you ever want to branch from one part
of the program to another part that is far away, it is a much better idea to use a jmp than a bra. That being said, if you need to make a comparison operation, then branch
to a label close by and jump from there.
JSR
RTS
RTI
XGDX
XGDY
TSX
TSY
TXS
; This jumps to a service routine and stores the address of the JSR instruction to the stack
; This pops off a 16-bit value (the return address) from the system stack and jumps to that location
; This is to return from an interrupt
; This swaps the contents of D and X
; This swaps the contents of D and Y
; This transfers the stack pointer to X
; This transfers the stack pointer to Y
; This transfer X to the stack pointer (not that this instruction should NEVER be used!!)
IDIV
FDIV
A tip:
You will find that you will be using memory locations much like local variables (or registers) within HC11. As such, you many find that you are creating a great number
of temporary memory locations that will end up as wasted memory most of the time.
To solve this problem, we can dynamically allocate memory for each of our functions.
Example: instead of allocating two temporary variables TEMP1 and TEMP2, we can do the following.
JSR
MYFUNC
MYFUNC:
pshx
pshy
psha
pshb
ldx
pshx
pshx
tsx
#0
/* CREATE TEMP1 on STACK */
/* CREATE TEMP2 on STACK */
//copy the stack pointer to X
0,X
#1
0,X