ref: b087a9736048f974abbd068d4ef434c668dc6626
parent: 3e2ddf390374b77222c3e8f966aabaf58c8a6ea6
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Dec 15 04:34:36 EST 2017
[as] Add section selection pseudo instructions
--- a/as/as.h
+++ b/as/as.h
@@ -122,7 +122,7 @@
/* symbol.c */
extern void isections(void);
extern void emit(char *bytes, int nbytes);
-extern Section *section(char *name);
+extern Section *setsection(char *name);
extern Symbol *tmpsym(TUINT val);
extern void killtmp(void);
extern int toobig(Node *np, int type);
--- a/as/ins.c
+++ b/as/ins.c
@@ -73,3 +73,29 @@
else
linesym->value = (*args)->sym->value;
}
+
+void
+section(Op *op, Node **args)
+{
+ Symbol *sym = args[0]->sym;
+
+ setsection(sym->name.buf);
+}
+
+void
+text(Op *op, Node **args)
+{
+ setsection("text");
+}
+
+void
+data(Op *op, Node **args)
+{
+ setsection("data");
+}
+
+void
+bss(Op *op, Node **args)
+{
+ setsection("bss");
+}
--- a/as/symbol.c
+++ b/as/symbol.c
@@ -194,7 +194,7 @@
}
Section *
-section(char *name)
+setsection(char *name)
{
Section *sec;
--- a/as/target/x80/x80.dat
+++ b/as/target/x80/x80.dat
@@ -1,5 +1,9 @@
# Tab 16, tabs 16, :set ts=16
# op args size bytes format cpu
+.SECTION sym 0 none section Z80,R800,GB80
+.TEXT none 0 none text Z80,R800,GB80
+.DATA none 0 none data Z80,R800,GB80
+.BSS none 0 none bss Z80,R800,GB80
.DB imm8+ 0 none defb Z80,R800,GB80
.DEFB imm8+ 0 none defb Z80,R800,GB80
.BYTE imm8+ 0 none defb Z80,R800,GB80