aboutsummaryrefslogtreecommitdiff
path: root/asm.peg
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-07 22:48:05 +1300
committerAndrew Chambers <[email protected]>2021-10-07 22:48:05 +1300
commit035c38a46e86ae24269ff24f1011776200050e7f (patch)
tree9744033f061a5c3acad5a4f0a34b0745447086d6 /asm.peg
parent34c94563338da7c2ba7ca3a3e41cd14a10a1ad2f (diff)
Implement more opcodes.
Diffstat (limited to 'asm.peg')
-rw-r--r--asm.peg24
1 files changed, 24 insertions, 0 deletions
diff --git a/asm.peg b/asm.peg
index 76918fd..a49dfe7 100644
--- a/asm.peg
+++ b/asm.peg
@@ -36,6 +36,7 @@ instr =
| i:add { $$ = i; }
| i:and { $$ = i; }
| i:lea { $$ = i; }
+ | i:mov { $$ = i; }
| i:or { $$ = i; }
| i:sub { $$ = i; }
| i:xor { $$ = i; }
@@ -47,6 +48,29 @@ lea =
| 'q'? ws s:m ws? ',' ws? d:r64 { $$ = INSTR(2, s, d); }
) { $$.instr.kind = ASM_LEA; }
+mov = "mov" (
+ 'b'? ws s:imm8 ws? ',' ws? d:r8 { $$ = INSTR(0, s, d); }
+ | 'w'? ws s:imm16 ws? ',' ws? d:r16 { $$ = INSTR(1, s, d); }
+ | 'l'? ws s:imm32 ws? ',' ws? d:r32 { $$ = INSTR(2, s, d); }
+ | 'q'? ws s:imm32 ws? ',' ws? d:r64 { $$ = INSTR(3, s, d); }
+ | 'b' ws s:imm8 ws? ',' ws? d:m { $$ = INSTR(4, s, d); }
+ | 'w' ws s:imm16 ws? ',' ws? d:m { $$ = INSTR(5, s, d); }
+ | 'l' ws s:imm32 ws? ',' ws? d:m { $$ = INSTR(6, s, d); }
+ | 'q' ws s:imm32 ws? ',' ws? d:m { $$ = INSTR(7, s, d); }
+ | 'b'? ws s:m ws? ',' ws? d:r8 { $$ = INSTR(8, s, d); }
+ | 'w'? ws s:m ws? ',' ws? d:r16 { $$ = INSTR(9, s, d); }
+ | 'l'? ws s:m ws? ',' ws? d:r32 { $$ = INSTR(10, s, d); }
+ | 'q'? ws s:m ws? ',' ws? d:r64 { $$ = INSTR(11, s, d); }
+ | 'b'? ws s:r8 ws? ',' ws? d:m { $$ = INSTR(12, s, d); }
+ | 'w'? ws s:r16 ws? ',' ws? d:m { $$ = INSTR(13, s, d); }
+ | 'l'? ws s:r32 ws? ',' ws? d:m { $$ = INSTR(14, s, d); }
+ | 'q'? ws s:r64 ws? ',' ws? d:m { $$ = INSTR(15, s, d); }
+ | 'b'? ws s:r8 ws? ',' ws? d:r8 { $$ = INSTR(16, s, d); }
+ | 'w'? ws s:r16 ws? ',' ws? d:r16 { $$ = INSTR(17, s, d); }
+ | 'l'? ws s:r32 ws? ',' ws? d:r32 { $$ = INSTR(18, s, d); }
+ | 'q'? ws s:r64 ws? ',' ws? d:r64 { $$ = INSTR(19, s, d); }
+) { $$.instr.kind = ASM_MOV; }
+
xchg =
'xchg' (
'w'? ws s:ax ws? ',' ws? d:r16 { $$ = INSTR(0, s, d); }