-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpseudocommands.asm
116 lines (94 loc) · 1.72 KB
/
pseudocommands.asm
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#importonce
/*
KickAssembler has a cool feature called 'pseudocommands' that let you build
your own pseudo instructions. They're similar to macros, but the calling
syntax very much resembles standard 6502 instructions.
*/
/* BFS: branch if flag set */
.pseudocommand bfs flag:location {
lda flag
bmi location
}
/* BFC: branch if flag clear */
.pseudocommand bfc flag:location {
lda flag
bpl location
}
/* CLF: clear flag */
.pseudocommand clf flag {
Disable(flag)
}
/* SEF: set flag */
.pseudocommand sef flag {
Enable(flag)
}
/* TGF: toggle flag */
.pseudocommand tgf flag {
Toggle(flag)
}
/* WFS: wait for flag set */
.pseudocommand wfs flag {
!wait:
bfc flag:!wait-
}
/* WFC: wait for flag clear */
.pseudocommand wfc flag {
!wait:
bfs flag:!wait-
}
/* WFV: wait for value */
.pseudocommand wfv address:value {
!wait:
jne address:value:!wait-
}
/* JNE: jump if not equal */
.pseudocommand jne address:value:location {
lda address
cmp value
bne location
}
/* JEQ: jump if equal */
.pseudocommand jeq address:value:location {
lda address
cmp value
beq location
}
/* STB: store byte */
.pseudocommand stb value:address {
lda value
sta address
}
/* MULT2: multiply the accumulator by 2 */
.pseudocommand mult2 {
asl
}
/* DIV2: divide the accumulator by 2 */
.pseudocommand div2 {
lsr
}
/* MULT4: multiply the accumulator by 4 */
.pseudocommand mult4 {
mult2
mult2
}
/* DIV4: divide the accumulator by 4 */
.pseudocommand div4 {
div2
div2
}
/* MULT8: multiply the accumulator by 8 */
.pseudocommand mult8 {
asl
asl
asl
}
/* MULT16: multiply the accumulator by 16 */
.pseudocommand mult16 {
mult8
mult8
}
/* BRA: branch always */
.pseudocommand bra address {
clv
bvc address
}