-
Notifications
You must be signed in to change notification settings - Fork 2
/
pseudocommands.asm
103 lines (85 loc) · 1.74 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
/*
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
}
/* MULT8: multiply the accumulator by 8 */
.pseudocommand mult8 {
asl
asl
asl
}
/* CHK_MINE: check if the piece in the accumulator is mine */
/* and branch to 'if_not' if it isn't */
.pseudocommand chk_mine if_not {
pcol
cmp currentplayer
bne if_not
}
/* CHK_EMPTY: check if a square is empty and branch if it is */
/* .x should be loaded with the index offset for a movefrom */
/* or a moveto location */
.pseudocommand chk_empty branch {
jeq BoardState, x:#EMPTY_SPR:branch
}
/* PCOL: get the color for the piece stored in .a */
.pseudocommand pcol {
and #BIT8
clc
rol
rol
}