scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 1ada0241a9714132ea2da02e5b6281f0b198ac5e
parent c6306509943c89def518bd6fadae6ef4439dc0a5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  9 Sep 2017 07:17:59 +0200

[as] Move pack() to emit.c

It is better to keep ins.c files only for instruction formats

Diffstat:
Mas/as.h | 1+
Mas/emit.c | 15+++++++++++++++
Mas/ins.c | 15---------------
3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/as/as.h b/as/as.h @@ -56,6 +56,7 @@ extern void writeout(char *name); extern void emit(Section *sec, char *bytes, int nbytes); extern Section *section(char *name); extern void incpc(int siz); +extern char *pack(TUINT v, int n, int inc); extern Section *cursec; extern int nr_ins; diff --git a/as/emit.c b/as/emit.c @@ -27,6 +27,21 @@ Section *cursec = &text, *headp = &text; int pass; +char * +pack(TUINT v, int n, int inc) +{ + static char buf[sizeof(TUINT)]; + int idx; + + idx = (inc < 0) ? n-1 : 0; + while (n--) { + buf[idx] = v; + idx += inc; + v >>= 8; + } + return buf; +} + static void isect(Section *sec) { diff --git a/as/ins.c b/as/ins.c @@ -8,21 +8,6 @@ direct(Op *op, Arg *args) emit(cursec, op->bytes, op->size); } -char * -pack(TUINT v, int n, int inc) -{ - static char buf[sizeof(TUINT)]; - int idx; - - idx = (inc < 0) ? n-1 : 0; - while (n--) { - buf[idx] = v; - idx += inc; - v >>= 8; - } - return buf; -} - void def(Arg *args, int siz) {