mirror of
https://github.com/cc65/cc65.git
synced 2025-01-28 15:31:18 +00:00
Fixed a problem with evaluation of the address size
git-svn-id: svn://svn.cc65.org/cc65/trunk@3621 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
78c5e6fcee
commit
142c131f06
@ -1378,34 +1378,30 @@ void StudyExpr (ExprNode* Expr, ExprDesc* D)
|
|||||||
*/
|
*/
|
||||||
if (ED_IsValid (D)) {
|
if (ED_IsValid (D)) {
|
||||||
unsigned char AddrSize;
|
unsigned char AddrSize;
|
||||||
if (D->SymCount == 1 && D->SecCount == 0) {
|
|
||||||
/* Exactly one symbol. Assume that the expression has the size of
|
/* If there are symbols or sections, use the largest one. If the
|
||||||
* the symbol, provided that this size is known.
|
* expression resolves to a const, use the address size of the value.
|
||||||
*/
|
*/
|
||||||
const SymEntry* Sym = D->SymRef[0].Ref;
|
if (D->SymCount > 0 || D->SecCount > 0) {
|
||||||
AddrSize = GetSymAddrSize (Sym);
|
|
||||||
if (AddrSize != ADDR_SIZE_DEFAULT) {
|
D->AddrSize = ADDR_SIZE_DEFAULT;
|
||||||
D->AddrSize = AddrSize;
|
|
||||||
} else {
|
for (I = 0; I < D->SymCount; ++I) {
|
||||||
AddrSize = GetConstAddrSize (D->Val);
|
const SymEntry* Sym = D->SymRef[I].Ref;
|
||||||
|
AddrSize = GetSymAddrSize (Sym);
|
||||||
if (AddrSize > D->AddrSize) {
|
if (AddrSize > D->AddrSize) {
|
||||||
D->AddrSize = AddrSize;
|
D->AddrSize = AddrSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (D->SymCount == 0 && D->SecCount == 1) {
|
|
||||||
/* Exactly one segment reference (segment+offset). In this case,
|
for (I = 0; I < D->SecCount; ++I) {
|
||||||
* the expression has the address size of the segment.
|
unsigned SegNum = D->SecRef[0].Ref;
|
||||||
*/
|
AddrSize = GetSegAddrSize (SegNum);
|
||||||
unsigned SegNum = D->SecRef[0].Ref;
|
|
||||||
AddrSize = GetSegAddrSize (SegNum);
|
|
||||||
if (AddrSize != ADDR_SIZE_DEFAULT) {
|
|
||||||
D->AddrSize = AddrSize;
|
|
||||||
} else {
|
|
||||||
AddrSize = GetConstAddrSize (D->Val);
|
|
||||||
if (AddrSize > D->AddrSize) {
|
if (AddrSize > D->AddrSize) {
|
||||||
D->AddrSize = AddrSize;
|
D->AddrSize = AddrSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
AddrSize = GetConstAddrSize (D->Val);
|
AddrSize = GetConstAddrSize (D->Val);
|
||||||
if (AddrSize > D->AddrSize) {
|
if (AddrSize > D->AddrSize) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user