diff options
author | H. Peter Anvin <hpa@zytor.com> | 2014-05-09 21:51:41 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2014-05-09 21:51:41 -0700 |
commit | 68a27ad2ff4de60b592346a643c0a4cf34264a3f (patch) | |
tree | 540aaed1398cd0350fdccf4fabbd6363e6c01b2e | |
parent | 209a67bda77468dea45b94cfb85bb3bae3eee337 (diff) | |
download | abc80-68a27ad2ff4de60b592346a643c0a4cf34264a3f.tar.gz abc80-68a27ad2ff4de60b592346a643c0a4cf34264a3f.tar.xz abc80-68a27ad2ff4de60b592346a643c0a4cf34264a3f.zip |
z80asm: add an align directive
Having an alignment directive is handy.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | tools/z80asm/z80asm.c | 19 | ||||
-rw-r--r-- | tools/z80asm/z80asm.h | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/tools/z80asm/z80asm.c b/tools/z80asm/z80asm.c index 2a326df..73813b3 100644 --- a/tools/z80asm/z80asm.c +++ b/tools/z80asm/z80asm.c @@ -34,7 +34,7 @@ const char *mnemonics[] = { "cp", "di", "ei", "ex", "im", "in", "jp", "jr", "ld", "or", "rl", "rr", "db", "dw", "ds", "dm", "include", "incbin", "if", "else", "endif", "end", "macro", "endm", - "seek", NULL + "seek", "align", NULL }; /* linked lists */ @@ -2463,6 +2463,23 @@ assemble (void) printerr (1, "Missing expression in defw\n"); } break; + case ALIGN: + { + r = rd_expr (&ptr, '\0', NULL, sp, 1) & 0xffff; + if (r <= 0 || (r & (r-1))) { + printerr (1, "Alignment is not a power of two\n"); + break; + } + r = ((addr + r - 1) & ~(r - 1)) - addr; + if (havelist) { + fprintf (listfile, " 00..."); + listdepth += 6; + } + for (i = 0; i < r; i++) { + write_one_byte (0, 0); + } + } + break; case DEFS: case DS: r = rd_expr (&ptr, ',', NULL, sp, 1); diff --git a/tools/z80asm/z80asm.h b/tools/z80asm/z80asm.h index af398ca..160da54 100644 --- a/tools/z80asm/z80asm.h +++ b/tools/z80asm/z80asm.h @@ -51,7 +51,7 @@ enum mnemonic LDD, LDI, NEG, NOP, OUT, POP, RES, RET, RLA, RLC, RLD, RRA, RRC, RRD, RST, SBC, SCF, SET, SLA, SLL, SLI, SRA, SRL, SUB, XOR, ORG, CP, DI, EI, EX, IM, IN, JP, JR, LD, OR, RL, RR, DB, DW, DS, DM, - INCLUDE, INCBIN, IF, ELSE, ENDIF, END, MACRO, ENDM, SEEK + INCLUDE, INCBIN, IF, ELSE, ENDIF, END, MACRO, ENDM, SEEK, ALIGN }; /* types of reference */ |