ref: 37ffac184537c284e94c6384c630236f13db972b
parent: 4786cd4f6eca4565c5c0044871877682b378aa68
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Mar 18 10:48:10 EDT 2015
Use unsigned types where it is possible
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -44,7 +44,7 @@
typedef struct node Node;
typedef struct {- short size;
+ unsigned short size;
uint8_t align;
char letter;
uint8_t flags;
@@ -75,8 +75,8 @@
};
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 inst {- char op;
+ uint8_t op;
Addr from, to;
Inst *next, *prev;
};
--- 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 @@
[IX] = ®_IX, [IY] = ®_IY, [SP] = ®_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:
--- a/cc2/code.c
+++ b/cc2/code.c
@@ -117,10 +117,9 @@
}
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 @@
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 @@
static void
inst2(void)
{- char op = pc->op;
+ uint8_t op = pc->op;
printf("\t%s\t", insttext[op]);addr2txt(op, &pc->to);
--
⑨