Fixed wrong code generation for
((unsigned char *)(&shadow))[reg & 0x0f] = value; git-svn-id: svn://svn.cc65.org/cc65/trunk@3875 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -938,7 +938,7 @@ static void ArrayRef (ExprDesc* Expr)
|
|||||||
* constant, we call special functions to add the address to the
|
* constant, we call special functions to add the address to the
|
||||||
* offset value.
|
* offset value.
|
||||||
*/
|
*/
|
||||||
if (!ConstBaseAddr) {
|
if (!ConstBaseAddr) {
|
||||||
|
|
||||||
/* The array base address is on stack and the subscript is in the
|
/* The array base address is on stack and the subscript is in the
|
||||||
* primary. Add both.
|
* primary. Add both.
|
||||||
@@ -952,15 +952,15 @@ static void ArrayRef (ExprDesc* Expr)
|
|||||||
* often a better idea to reverse again the order of the
|
* often a better idea to reverse again the order of the
|
||||||
* evaluation. This will generate better code if the subscript is
|
* evaluation. This will generate better code if the subscript is
|
||||||
* a byte sized variable. But beware: This is only possible if the
|
* a byte sized variable. But beware: This is only possible if the
|
||||||
* subscript was not scaled, that is, if this was a byte array
|
* subscript was not scaled, that is, if this was a byte array
|
||||||
* or pointer.
|
* or pointer.
|
||||||
*/
|
*/
|
||||||
if ((ED_IsLocConst (&SubScript) || ED_IsLocStack (&SubScript)) &&
|
if ((ED_IsLocConst (&SubScript) || ED_IsLocStack (&SubScript)) &&
|
||||||
CheckedSizeOf (ElementType) == SIZEOF_CHAR) {
|
CheckedSizeOf (ElementType) == SIZEOF_CHAR) {
|
||||||
|
|
||||||
unsigned Flags;
|
unsigned Flags;
|
||||||
|
|
||||||
/* Reverse the order of evaluation */
|
/* Reverse the order of evaluation */
|
||||||
if (CheckedSizeOf (SubScript.Type) == SIZEOF_CHAR) {
|
if (CheckedSizeOf (SubScript.Type) == SIZEOF_CHAR) {
|
||||||
Flags = CF_CHAR;
|
Flags = CF_CHAR;
|
||||||
} else {
|
} else {
|
||||||
@@ -968,33 +968,36 @@ static void ArrayRef (ExprDesc* Expr)
|
|||||||
}
|
}
|
||||||
RemoveCode (&Mark2);
|
RemoveCode (&Mark2);
|
||||||
|
|
||||||
/* Get a pointer to the array into the primary. */
|
/* Get a pointer to the array into the primary. */
|
||||||
LoadExpr (CF_NONE, Expr);
|
LoadExpr (CF_NONE, Expr);
|
||||||
|
|
||||||
/* Add the variable */
|
/* Add the variable */
|
||||||
if (ED_IsLocStack (&SubScript)) {
|
if (ED_IsLocStack (&SubScript)) {
|
||||||
g_addlocal (Flags, SubScript.IVal);
|
g_addlocal (Flags, SubScript.IVal);
|
||||||
} else {
|
} else {
|
||||||
Flags |= GlobalModeFlags (SubScript.Flags);
|
Flags |= GlobalModeFlags (SubScript.Flags);
|
||||||
g_addstatic (Flags, SubScript.Name, SubScript.IVal);
|
g_addstatic (Flags, SubScript.Name, SubScript.IVal);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ED_IsLocAbs (Expr)) {
|
|
||||||
/* Constant numeric address. Just add it */
|
if (ED_IsLocAbs (Expr)) {
|
||||||
g_inc (CF_INT, Expr->IVal);
|
/* Constant numeric address. Just add it */
|
||||||
} else if (ED_IsLocStack (Expr)) {
|
g_inc (CF_INT, Expr->IVal);
|
||||||
/* Base address is a local variable address */
|
} else if (ED_IsLocStack (Expr)) {
|
||||||
if (IsTypeArray (Expr->Type)) {
|
/* Base address is a local variable address */
|
||||||
g_addaddr_local (CF_INT, Expr->IVal);
|
if (IsTypeArray (Expr->Type)) {
|
||||||
|
g_addaddr_local (CF_INT, Expr->IVal);
|
||||||
} else {
|
} else {
|
||||||
g_addlocal (CF_PTR, Expr->IVal);
|
g_addlocal (CF_PTR, Expr->IVal);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Base address is a static variable address */
|
/* Base address is a static variable address */
|
||||||
unsigned Flags = CF_INT | GlobalModeFlags (Expr->Flags);
|
unsigned Flags = CF_INT | GlobalModeFlags (Expr->Flags);
|
||||||
if (IsTypeArray (Expr->Type)) {
|
if (ED_IsRVal (Expr)) {
|
||||||
|
/* Add the address of the location */
|
||||||
g_addaddr_static (Flags, Expr->Name, Expr->IVal);
|
g_addaddr_static (Flags, Expr->Name, Expr->IVal);
|
||||||
} else {
|
} else {
|
||||||
|
/* Add the contents of the location */
|
||||||
g_addstatic (Flags, Expr->Name, Expr->IVal);
|
g_addstatic (Flags, Expr->Name, Expr->IVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user