ref: 5ee0c779060595407f6042414f4bf9c1165634b9
parent: 6c32e2dc143c56ea0187f19add3b543eae988c06
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Mar 16 14:34:16 EDT 2015
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.
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -508,7 +508,11 @@
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;
}
}