scc

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

commit 37ffac184537c284e94c6384c630236f13db972b
parent 4786cd4f6eca4565c5c0044871877682b378aa68
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 18 Mar 2015 14:48:10 +0000

Use unsigned types where it is possible

Diffstat:
Mcc2/cc2.h | 8++++----
Mcc2/cgen.c | 14+++++++-------
Mcc2/code.c | 7+++----
3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -44,7 +44,7 @@ typedef struct symbol Symbol; typedef struct node Node; typedef struct { - short size; + unsigned short size; uint8_t align; char letter; uint8_t flags; @@ -75,8 +75,8 @@ struct symbol { }; struct node { - char op; - char subop; + uint8_t op; + uint8_t subop; Type type; uint8_t complex; uint8_t addable; @@ -99,7 +99,7 @@ struct addr { }; struct inst { - char op; + uint8_t op; Addr from, to; Inst *next, *prev; }; diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -8,9 +8,9 @@ static Node *reguse[NREGS]; -static char upper[] = {[DE] = D, [HL] = H, [BC] = B, [IY] = IYH}; -static char lower[] = {[DE] = E, [HL] = L, [BC] = C, [IY] = IYL}; -static char pair[] = { +static uint8_t upper[] = {[DE] = D, [HL] = H, [BC] = B, [IY] = IYH}; +static uint8_t lower[] = {[DE] = E, [HL] = L, [BC] = C, [IY] = IYL}; +static uint8_t pair[] = { [A] = A, [H] = HL, [L] = HL, [B] = BC, [C] = BC, @@ -90,12 +90,12 @@ Node *regs[] = { [IX] = &reg_IX, [IY] = &reg_IY, [SP] = &reg_SP }; -static char +static uint8_t allocreg(Node *np) { - static char reg8[] = {A, B, C, D, E, H, L, IYL, IY, 0}; - static char reg16[] = {BC, DE, IY, 0}; - char *bp, c; + static uint8_t reg8[] = {A, B, C, D, E, H, L, IYL, IY, 0}; + static uint8_t reg16[] = {BC, DE, IY, 0}; + uint8_t *bp, c; switch (np->type.size) { case 1: diff --git a/cc2/code.c b/cc2/code.c @@ -117,10 +117,9 @@ writeout(void) } static void -addr2txt(char op, Addr *a) +addr2txt(uint8_t op, Addr *a) { Symbol *sym; - char *fmt; switch (a->kind) { case REG: @@ -157,7 +156,7 @@ inst0(void) static void inst1(void) { - char op = pc->op; + uint8_t op = pc->op; printf("\t%s\t", insttext[op]); addr2txt(op, (pc->to.kind != NONE) ? &pc->to : &pc->from); @@ -167,7 +166,7 @@ inst1(void) static void inst2(void) { - char op = pc->op; + uint8_t op = pc->op; printf("\t%s\t", insttext[op]); addr2txt(op, &pc->to);