summaryrefslogtreecommitdiff
path: root/notes
blob: 294e21724d9fadb62e4b0a0121d99d418d9e27cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
ops:
15   14   13   12   11   10   9    8    7    6    5    4    3    2    1    0
0  | 0  | 0  | 1  | 0  | 0  | opcode       | bw | ad      | dest              |
0  | 0  | 1  | cond         | pc-offset                                       |
opcode            | source            | ad | bw | as      | dest              |

bw = 1 for byte ops, 0 for word ops

oneop
000 RRC 9-bit rotate through carry
001 SWPB - swap 8-bit halves. no byte form
010 RRA(.B) - arithmetic right shift
011 SXT sign extend 8 bits to 16 bits. no byte form
100 PUSH(.B) - push byte still decrements sp by 2
101 CALL - get operand. push PC, PC = operand. no byte form. hard to do PC-relative call
110 RETI - pop SP then pop PC. opeand field unused.
111 not used

relative jumps
all PC-relative
000 JNE/JNZ
001 JEQ/JZ
010 JNC/JLO
011 JC/JHS
100 JN
101 JGE
110 JL
111 JMP

twoop
generally dest = src op dest
mov doesnt fetch dest, cmp/bit dont write dest. all valid in 8 bit and 16 bit

0100 MOV - dest = src
0101 ADD - dest += src
0110 ADDC - dest += src + C
0111 SUBC - dest = dest - src + c (dest += ~src + C)
1000 SUB - dest -= src
1001 CMP - dest - src (set status only, dest not written)
1010 DADD - dest += src + C, in BCD
1011 BIT - dest & src (set status only)
1100 BIC - dest &= ~src (status not set)
1101 BIS - dest |= src (status not set)
1110 XOR - dest ^= src
1111 AND - dest &= src

NOP implemented as virtual function, among others -
NOP == MOV r3, r3
POP dst == MOV @SP+, dst
BR dst == MOV dst, PC
RET == MOV @SP+, PC
CLRC 1
SETC 1
CLRZ 2
SETZ 2
CLRN 4
SETN 4
DINT 8
EINT 8

RLA dst == ADD dst, dst
RLC dst = ADDC dst, dst

INV dst == XOR #-1, dst
CLR dst == MOV #0, dst
TST dst == CMP #0, dst

DEC == SUB #1, dst
DECD == SUB #2, dst
INC == ADD #1, dst
INCD == ADD #2, dst

ADC dst == ADDC #0, dst
DADC dst == DADD #0, dst
SBC dst == SUBC #0, dst