1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-12 02:30:44 +00:00

Fixed g_addlocal codegen with long types.

This commit is contained in:
acqn 2020-04-16 18:38:49 +08:00 committed by Oliver Schmidt
parent 8066cd9ace
commit f9204e5b6f

View File

@ -1541,16 +1541,17 @@ void g_addlocal (unsigned flags, int offs)
/* Add a local variable to ax */ /* Add a local variable to ax */
{ {
unsigned L; unsigned L;
int NewOff;
/* Correct the offset and check it */ /* Correct the offset and check it */
offs -= StackPtr; NewOff = offs - StackPtr;
CheckLocalOffs (offs); CheckLocalOffs (NewOff);
switch (flags & CF_TYPEMASK) { switch (flags & CF_TYPEMASK) {
case CF_CHAR: case CF_CHAR:
L = GetLocalLabel(); L = GetLocalLabel();
AddCodeLine ("ldy #$%02X", offs & 0xFF); AddCodeLine ("ldy #$%02X", NewOff & 0xFF);
AddCodeLine ("clc"); AddCodeLine ("clc");
AddCodeLine ("adc (sp),y"); AddCodeLine ("adc (sp),y");
AddCodeLine ("bcc %s", LocalLabelName (L)); AddCodeLine ("bcc %s", LocalLabelName (L));
@ -1559,7 +1560,7 @@ void g_addlocal (unsigned flags, int offs)
break; break;
case CF_INT: case CF_INT:
AddCodeLine ("ldy #$%02X", offs & 0xFF); AddCodeLine ("ldy #$%02X", NewOff & 0xFF);
AddCodeLine ("clc"); AddCodeLine ("clc");
AddCodeLine ("adc (sp),y"); AddCodeLine ("adc (sp),y");
AddCodeLine ("pha"); AddCodeLine ("pha");