aboutsummaryrefslogtreecommitdiff
path: root/src/c8asm/grammar.ebnf
blob: 59ba9fc9bf077281a2b50fcc0e8957c5b29675fe (plain) (blame)
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
program = {line};
line = {label}, [operation], EOL;
label = IDENT, ':';

operation = add  | and  | bcd | call
          | cls  | drw  | hex | jp
          | ld   | or   | ret | rnd
          | rstr | se   | shl | shr
          | sknp | skp  | sne | stor
          | sub  | subn | sys | xor
		  | db;

add  = "add", ((vreg, vreg) | (vreg, BYTE) | ("i", vreg));
and  = "and", vreg, vreg;
bcd  = "bcd", vreg;
call = "call", addr;
cls  = "cls";
drw  = "drw", vreg, vreg, NIBBL;
hex  = "hex", vreg;
jp   = "jp", ["v0"], addr;
ld   = "ld", ((vreg, (vreg | BYTE | "dt" | "k"))
            | ("i", addr)
			| ("dt", vreg)
			| ("st", vreg));
or   = "or", vreg, vreg;
ret  = "ret";
rnd  = "rnd", vreg, BYTE;
rstr = "rstr", vreg;
se   = "se", vreg, (vreg | BYTE);
shl  = "shl", vreg;
shr  = "shr", vreg;
sknp = "sknp", vreg;
skp  = "skp", vreg;
sne  = "sne", vreg, (vreg | BYTE);
stor = "stor", vreg;
sub  = "sub", vreg, vreg;
subn = "subn", vreg, vreg;
sys  = "sys", addr;
xor  = "xor", vreg, vreg;
db   = "db", {(BYTE | STRING)};

addr = ADDR | IDENT;
vreg = "v0" | "v1" | "v2" | "v3"
     | "v4" | "v5" | "v6" | "v7"
     | "v8" | "v9" | "va" | "vb"
     | "vc" | "vd" | "ve" | "vf";