aboutsummaryrefslogtreecommitdiff
path: root/asm.peg
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-08 03:27:45 +1300
committerAndrew Chambers <[email protected]>2021-10-08 03:27:45 +1300
commit7c8d5a28545bdaf7d2574fcde8867d12a13128f6 (patch)
treeefe338854f3a0dc161c949d81f266b5197451406 /asm.peg
parent6526cddc058df5a1a84d7f4081e3f4a499642733 (diff)
Work on relocations.
Diffstat (limited to 'asm.peg')
-rw-r--r--asm.peg30
1 files changed, 18 insertions, 12 deletions
diff --git a/asm.peg b/asm.peg
index 0718aef..281d27c 100644
--- a/asm.peg
+++ b/asm.peg
@@ -29,26 +29,32 @@ label =
{ $$.label = (Label){.kind = ASM_LABEL, .name = i.ident.name}; }
instr =
- "nop" { $$.kind = ASM_NOP; }
+ "nop" { $$.kind = ASM_NOP; }
| "leave" { $$.kind = ASM_LEAVE; }
- | "ret" { $$.kind = ASM_RET; }
- | i:xchg { $$ = i; }
- | i:add { $$ = i; }
- | i:and { $$ = i; }
- | i:lea { $$ = i; }
- | i:mov { $$ = i; }
- | i:or { $$ = i; }
- | i:sub { $$ = i; }
- | i:xor { $$ = i; }
+ | "ret" { $$.kind = ASM_RET; }
+ | i:jmp { $$ = i; }
+ | i:xchg { $$ = i; }
+ | i:add { $$ = i; }
+ | i:and { $$ = i; }
+ | i:lea { $$ = i; }
+ | i:mov { $$ = i; }
+ | i:or { $$ = i; }
+ | i:sub { $$ = i; }
+ | i:xor { $$ = i; }
+
+
+jmp =
+ "jmp" ws t:ident
+ { $$.jmp = (Jmp){ .kind = ASM_JMP, .target=t.ident.name } ; }
lea =
- 'lea' (
+ "lea" (
'w'? ws s:m ws? ',' ws? d:r16 { $$ = INSTR(0, s, d); }
| 'l'? ws s:m ws? ',' ws? d:r32 { $$ = INSTR(1, s, d); }
| 'q'? ws s:m ws? ',' ws? d:r64 { $$ = INSTR(2, s, d); }
) { $$.instr.kind = ASM_LEA; }
-#XXX Some other these rules can probably be collapsed.
+#XXX Some of these rules can probably be collapsed (or expanded for simplicity?).
mov = "mov" (
'b'? ws s:imm8 ws? ',' ws? d:r8 { $$ = INSTR(0, s, d); }