scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit dcb13199b1122210a423fa1e7db218ea7e05ab31
parent f930047fb00b66be7171661d6ddb12415e82b31a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 16 Dec 2017 20:15:30 +0100

[as] Add align pseudo instruction

Diffstat:
Mas/ins.c | 19+++++++++++++++++++
Mas/target/x80/x80.dat | 1+
2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/as/ins.c b/as/ins.c @@ -206,3 +206,22 @@ global(Op *op, Node **args) sym->flags |= FGLOBAL; } + +void +align(Op *op, Node **args) +{ + Symbol *sym = args[0]->sym; + TUINT curpc, pc, al; + + if ((sym->flags & FABS) == 0) + error("align expression is not an absolute expression"); + if ((al = sym->value) == 0) + return; + + al--; + curpc = cursec->curpc; + pc = curpc+al & ~al; + + for (al = pc - curpc; al > 0; --al) + emit((char []) {0}, 1); +} diff --git a/as/target/x80/x80.dat b/as/target/x80/x80.dat @@ -28,6 +28,7 @@ .EXTERN sym+ 0 none extrn Z80,R800,GB80 .STRING string+ 0 none string Z80,R800,GB80 .ASCII string+ 0 none ascii Z80,R800,GB80 +.ALIGN imm16+ 0 none align Z80,R800,GB80 NOP none 1 0x00 noargs Z80,R800,GB80 EI none 1 0xfb noargs Z80,R800,GB80