mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 02:30:44 +00:00
For bit fields contained within single bytes, try to do character operations
instead of word sized ops. git-svn-id: svn://svn.cc65.org/cc65/trunk@4089 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
0b0353de13
commit
45d4771584
@ -161,12 +161,22 @@ void Assignment (ExprDesc* Expr)
|
|||||||
} else if (ED_IsBitField (Expr)) {
|
} else if (ED_IsBitField (Expr)) {
|
||||||
|
|
||||||
unsigned Mask;
|
unsigned Mask;
|
||||||
unsigned Flags = TypeOf (Expr->Type);
|
unsigned Flags;
|
||||||
|
|
||||||
|
/* If the bit-field fits within one byte, do the following operations
|
||||||
|
* with bytes.
|
||||||
|
*/
|
||||||
|
if (Expr->BitOffs / CHAR_BITS == (Expr->BitOffs + Expr->BitWidth - 1) / CHAR_BITS) {
|
||||||
|
Expr->Type = type_uchar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Determine code generator flags */
|
||||||
|
Flags = TypeOf (Expr->Type);
|
||||||
|
|
||||||
/* Assignment to a bit field. Get the address on stack for the store. */
|
/* Assignment to a bit field. Get the address on stack for the store. */
|
||||||
PushAddr (Expr);
|
PushAddr (Expr);
|
||||||
|
|
||||||
/* Load the value from the location as an unsigned */
|
/* Load the value from the location */
|
||||||
Expr->Flags &= ~E_BITFIELD;
|
Expr->Flags &= ~E_BITFIELD;
|
||||||
LoadExpr (CF_NONE, Expr);
|
LoadExpr (CF_NONE, Expr);
|
||||||
|
|
||||||
@ -180,7 +190,9 @@ void Assignment (ExprDesc* Expr)
|
|||||||
/* Read the expression on the right side of the '=' */
|
/* Read the expression on the right side of the '=' */
|
||||||
hie1 (&Expr2);
|
hie1 (&Expr2);
|
||||||
|
|
||||||
/* Do type conversion if necessary */
|
/* Do type conversion if necessary. Beware: Do not use char type
|
||||||
|
* here!
|
||||||
|
*/
|
||||||
TypeConversion (&Expr2, ltype);
|
TypeConversion (&Expr2, ltype);
|
||||||
|
|
||||||
/* If necessary, load the value into the primary register */
|
/* If necessary, load the value into the primary register */
|
||||||
@ -198,6 +210,9 @@ void Assignment (ExprDesc* Expr)
|
|||||||
/* Generate a store instruction */
|
/* Generate a store instruction */
|
||||||
Store (Expr, 0);
|
Store (Expr, 0);
|
||||||
|
|
||||||
|
/* Restore the expression type */
|
||||||
|
Expr->Type = ltype;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Get the address on stack if needed */
|
/* Get the address on stack if needed */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user