scc

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

commit ec8247497f31bd90ffefeeb077ecf6bec8d9e71c
parent 27f97dfd312192e7b5188eb064369d44a7caad83
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 15 Dec 2017 09:34:36 +0000

[as] Add section selection pseudo instructions

Diffstat:
Mas/as.h | 2+-
Mas/ins.c | 26++++++++++++++++++++++++++
Mas/symbol.c | 2+-
Mas/target/x80/x80.dat | 4++++
4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/as/as.h b/as/as.h @@ -122,7 +122,7 @@ struct node { /* 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); diff --git a/as/ins.c b/as/ins.c @@ -73,3 +73,29 @@ equ(Op *op, Node **args) 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"); +} diff --git a/as/symbol.c b/as/symbol.c @@ -194,7 +194,7 @@ isect(Section *sec) } Section * -section(char *name) +setsection(char *name) { Section *sec; diff --git 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