scc

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

commit 5ee0c779060595407f6042414f4bf9c1165634b9
parent 6c32e2dc143c56ea0187f19add3b543eae988c06
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 16 Mar 2015 18:34:16 +0000

Align elements in stack to 2

Stack in z80 is a 2 byte stack, so char will use 2 bytes always,
or in other case we can have problems with the stack.

Diffstat:
Mcc2/parser.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -508,7 +508,11 @@ localdcl(char *token) char sclass = *token; if (sclass == 'A' || sclass == 'R') { - curfun->u.f.locals += sym->u.v.type.size; + uint8_t size = sym->u.v.type.size; + /* stack elements are 2 byte multiple */ + if (size == 1) + ++size; + curfun->u.f.locals += size; sym->u.v.off = curfun->u.f.locals; } }