-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsyntax.asm
97 lines (86 loc) · 1.69 KB
/
syntax.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
; This program just demonstrates and tests all the instructions in the assembler.
; Don't try to run it. It will probably do strange things.
; Comments start with semicolons
start: ; labels are identifiers followed by colons
CLS
JP start
JP #123 ; Hexadecimal numbers are preceded by # symbols
JP v0, #123
JP v0, end
call end
call #203
se V1, #AA
se V2, v3
sne V1, #AA
sne V2, v3
end:
RET
add V1, #AA
add V2, v3
ld V1, #AA
ld V2, v3
or V2, v3
and VA, vb
xor VA, vb
shr VA, vb
shr VA
subn VA, vb
shl VA, vb
shl VA
rnd VD, #FF
drw VE, VF, #4
skp VE
sknp VA
add I, V8
ld I, #AAA
ld V5, DT
ld V5, K
ld DT, V5
ld ST, V5
ld F, V5
ld B, V5
ld [I], VA
ld VA, [I]
; "define" can be used to define constants
define aaa #222
jp aaa
; "define" can also be used to define aliases for registers
define bbb vd
ld bbb, %01010101 ; Binary literals start with % symbols
JP %101001010101
JP x
LD I, x
; SCHIP instructions are supported
SCD #4
SCL
SCR
EXIT
HIGH
LOW
DRW V1, V2, 0
LD HF, V5
LD R, V6
LD V7, R
; Offset moves the location where output is generated
offset #280
; This is how you can define sprites:
; "db" emits raw bytes, separated by commas.
; "dw" can emit 16-bit words.
x: db #11, #22, #33, #44
y: db
%00100100,
%11111111,
%01011010,
%00111100,
%00100100
CLS
; You can load text data into the output through the `text` directive:
string1:
text "hello"
; (The label `string1` can be used later like so: `ld I, string1`)
; The above is equivalent to this `db` directive
; db #68, #65, #6C, #6C, #6F, #00
; The string can also contain special symbols escaped with '\'
string2: text "\"\e\r\n"
; This is how you can include another file:
include "font2.asm"