scc

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

commit bb08aef03af276b006584ce2f26cc2de6391b8e4
parent 50e7ddaeb14834574ae4964535be5730e977d957
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 16 Dec 2017 19:25:28 +0100

[as/objdump] Add global and extern pseudo instructions

These pseudo instructions are needed to implement global
variables. Dedup flag is removed because it can be implemented
using common. This patch also adds absolute flag in myro
files.

Diffstat:
Mas/as.h | 2+-
Mas/ins.c | 16++++++++++++++++
Mas/myro.c | 2--
Mas/target/x80/x80.dat | 2++
Minc/myro.h | 7++++---
Mobjdump/main.c | 2--
6 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/as/as.h b/as/as.h @@ -12,7 +12,7 @@ enum symflags { FCOMMON = 1 << 2, FEXTERN = 1 << 3, FUNDEF = 1 << 4, - FDEDUP = 1 << 5, + FGLOBAL = 1 << 5, FRELOC = 1 << 6, FABS = 1 << 7, }; diff --git a/as/ins.c b/as/ins.c @@ -159,3 +159,19 @@ bss(Op *op, Node **args) { cursec = sbss; } + +void +extrn(Op *op, Node **args) +{ + Symbol *sym = args[0]->sym; + + sym->flags |= FEXTERN; +} + +void +global(Op *op, Node **args) +{ + Symbol *sym = args[0]->sym; + + sym->flags |= FGLOBAL; +} diff --git a/as/myro.c b/as/myro.c @@ -94,8 +94,6 @@ getsymflags(Symbol *sym) flags |= MYROSYM_EXTERN; if (sym->flags & FUNDEF) flags |= MYROSYM_UNDEF; - if (sym->flags & FDEDUP) - flags |= MYROSYM_DEDUP; return flags; } diff --git a/as/target/x80/x80.dat b/as/target/x80/x80.dat @@ -24,6 +24,8 @@ .SIZE imm16 0 none size Z80,R800,GB80 .COMM sym,imm16 0 none common Z80,R800,GB80 .COMM imm16 0 none common Z80,R800,GB80 +.GLOBL sym+ 0 none global Z80,R800,GB80 +.EXTERN sym+ 0 none extrn Z80,R800,GB80 NOP none 1 0x00 noargs Z80,R800,GB80 EI none 1 0xfb noargs Z80,R800,GB80 diff --git a/inc/myro.h b/inc/myro.h @@ -56,10 +56,11 @@ enum myrosecflg { }; enum myrosymflg { - MYROSYM_DEDUP = 1 << 0, - MYROSYM_COMMON = 1 << 1, - MYROSYM_EXTERN = 1 << 2, + MYROSYM_COMMON = 1 << 0, + MYROSYM_EXTERN = 1 << 1, + MYROSYM_GLOBAL = 1 << 2, MYROSYM_UNDEF = 1 << 3, + MYROSYM_ABS = 1 << 4, }; extern int wrmyrohdr(FILE *fp, struct myrohdr *hdr); diff --git a/objdump/main.c b/objdump/main.c @@ -146,8 +146,6 @@ symflags(struct myrosym *sym) static char flags[10]; char *s = flags + sizeof(flags); - if (sym->flags & MYROSYM_DEDUP) - *--s = 'D'; if (sym->flags & MYROSYM_COMMON) *--s = 'C'; if (sym->flags & MYROSYM_EXTERN)