ref: 24aa60c70ccb02c74fe9658ca54520963e0fc688
parent: c35217a1a61f795d312eede2f84faf59c7c06a3c
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Dec 16 15:15:30 EST 2017
[as] Add align pseudo instruction
--- a/as/ins.c
+++ b/as/ins.c
@@ -206,3 +206,22 @@
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);
+}
--- 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