diff options
| -rw-r--r-- | asm.peg | 66 | ||||
| -rw-r--r-- | main.c | 9 | ||||
| -rw-r--r-- | parse.c | 1 |
3 files changed, 35 insertions, 41 deletions
@@ -97,38 +97,40 @@ instr = | i:cltd { $$ = i; } | i:cqto { $$ = i; })) | (& 's' - ( - i:set { $$ = i; } - | i:sub { $$ = i; } - | i:sal { $$ = i; } - | i:sar { $$ = i; } - | i:shl { $$ = i; } - | i:shr { $$ = i; } - | i:subsd { $$ = i; } - | i:subss { $$ = i; })) - | i:or { $$ = i; } - | i:leave { $$ = i; } - | i:ret { $$ = i; } - | i:push { $$ = i; } - | i:pop { $$ = i; } - | i:jmp { $$ = i; } - | i:div { $$ = i; } - | i:idiv { $$ = i; } - | i:lea { $$ = i; } - | i:imul { $$ = i; } - | i:neg { $$ = i; } - | i:test { $$ = i; } - | i:xchg { $$ = i; } - | i:xor { $$ = i; } - # Floating point is less common, so check last. - | i:divss { $$ = i; } - | i:divsd { $$ = i; } - | i:pxor { $$ = i; } - | i:xorpd { $$ = i; } - | i:xorps { $$ = i; } - | i:ucomisd { $$ = i; } - | i:ucomiss { $$ = i; } - | i:nop { $$ = i; } + ( + i:set { $$ = i; } + | i:sub { $$ = i; } + | i:sal { $$ = i; } + | i:sar { $$ = i; } + | i:shl { $$ = i; } + | i:shr { $$ = i; } + | i:subsd { $$ = i; } + | i:subss { $$ = i; })) + | (& 'x' + ( + i:xchg { $$ = i; } + | i:xor { $$ = i; } + | i:xorpd { $$ = i; } + | i:xorps { $$ = i; } )) + | i:or { $$ = i; } + | i:leave { $$ = i; } + | i:ret { $$ = i; } + | i:push { $$ = i; } + | i:pop { $$ = i; } + | i:jmp { $$ = i; } + | i:div { $$ = i; } + | i:idiv { $$ = i; } + | i:lea { $$ = i; } + | i:imul { $$ = i; } + | i:neg { $$ = i; } + | i:test { $$ = i; } + # Floating point is less common, so check last. + | i:divss { $$ = i; } + | i:divsd { $$ = i; } + | i:pxor { $$ = i; } + | i:ucomisd { $$ = i; } + | i:ucomiss { $$ = i; } + | i:nop { $$ = i; } call = "call" 'q'? ws ( '*' t:mem @@ -172,11 +172,6 @@ static Relocation *newreloc() { static void sb(uint8_t b) { secaddbyte(cursection, b); } -static void sb2(uint8_t b1, uint8_t b2) { - uint8_t buf[2] = {b1, b2}; - secaddbytes(cursection, buf, sizeof(buf)); -} - static void sbn(uint8_t *bytes, size_t n) { secaddbytes(cursection, bytes, n); } static void su16(uint16_t w) { @@ -211,8 +206,6 @@ static void su64(uint64_t l) { /* Convert an AsmKind to register bits in reg/rm style. */ static uint8_t regbits(AsmKind k) { return (k - (ASM_REG_BEGIN + 1)) % 16; } -static uint8_t isreg64(AsmKind k) { return k >= ASM_RAX && k <= ASM_R15; } - /* Register that requires the use of a rex prefix. */ static uint8_t isrexreg(AsmKind k) { return k > ASM_REG_BEGIN && k < ASM_REG_END && @@ -508,7 +501,7 @@ static void assembleinstr(const Instr *instr) { Rex rex; const Memarg *memarg; const Imm *imm; - uint8_t mod, reg, rm; + uint8_t reg, rm; switch (instr->encoder) { case ENCODER_OP: @@ -44,7 +44,6 @@ const char *internstring(const char *s) { } static String decodestring(char *s) { - int i; char *end; size_t len = 0; size_t cap = 0; |
