diff options
| author | Andrew Chambers <[email protected]> | 2021-10-10 20:59:58 +1300 |
|---|---|---|
| committer | Andrew Chambers <[email protected]> | 2021-10-10 20:59:58 +1300 |
| commit | 455ad9e979015cde50cd1f89a028aa0dd165b8b3 (patch) | |
| tree | 68d024930b7c5068955530cb13493efba7637f56 /main.c | |
| parent | 6c881983cad0ac9b8896d41e2335f63c416325d4 (diff) | |
Add more directives and some simple opcodes.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -293,6 +293,20 @@ static void su32(uint32_t l) { secaddbytes(cursection, buf, sizeof(buf)); } +static void su64(uint32_t l) { + uint8_t buf[8] = { + l & 0xff, + (l & 0xff00) >> 8, + (l & 0xff00) >> 16, + (l & 0xff000000) >> 24, + (l & 0xff00000000) >> 32, + (l & 0xff0000000000) >> 40, + (l & 0xff000000000000) >> 48, + (l & 0xff00000000000000) >> 56, + }; + secaddbytes(cursection, buf, sizeof(buf)); +} + /* Convert an AsmKind to register bits in reg/rm style. */ static uint8_t regbits(AsmKind k) { return (k - (ASM_REG_BEGIN + 1)) % 16; } @@ -332,7 +346,7 @@ void assembleconstant(int64_t c, int nbytes) { su32((uint32_t)c); break; case 8: - fatal("TODO 8 byte"); + su64((uint64_t)c); break; default: unreachable(); @@ -651,7 +665,13 @@ static void assemble(void) { break; } case ASM_DIR_BYTE: - sb(v->byte.b); + sb((uint8_t)v->dirbyte.v); + break; + case ASM_DIR_INT: + su32((uint32_t)v->dirint.v); + break; + case ASM_DIR_QUAD: + su64((uint64_t)v->dirquad.v); break; case ASM_LABEL: sym = getsym(v->label.name); @@ -705,6 +725,12 @@ static void assemble(void) { case ASM_LEAVE: sb(0xc9); break; + case ASM_CLTD: + sb(0x99); + break; + case ASM_CQTO: + sb2(0x48, 0x99); + break; case ASM_RET: sb(0xc3); break; |
