Bad immediate constant
Alan Adams (2486) 1125 posts |
In a largish piece of code written using the BASIC assembler, I added a short section near the beginning. As a result, code a lot further down, that worked before the addition now produces a seried of “bad immediate constant” messages. In each case the data referred to in an ADR instruction was immediately after the code segment. Moving it before the code segment got rid of the message. However this last one has me beat. I moved the others because I suspected that the offset was too large between the instruction and the data. However this one is already very close.
Line 1033 is the ADR instruction. I haven’t removed anything between the reference and the label, so it’s close. |
Steve Pampling (1551) 7932 posts |
The phrase a step too far comes to mind. |
Martin Avison (27) 1418 posts |
Are you sure that label name is not duplicated elsewhere (and out of range)? |
Steve Drain (222) 1620 posts |
Is the choicesname label duplicated earlier in the program? |
Alan Adams (2486) 1125 posts |
I also checked for a duplicated name – it’s the sort of thing pasting in additional code could cause. It’s not that either. |
Richard Coleman (3190) 54 posts |
Your code above would indicate that there are spaces before the label. |
Alan Adams (2486) 1125 posts |
Hmm… Just tried the assembly again, and it worked. Now I’m getting an undefined instruction, so more detective work needed. The only change I knowingly made was from which only adds a listing. |
Alan Adams (2486) 1125 posts |
I try to left-justify them, but I thought that was only cosmetic. I’m fairly sure there are other labels with spaces in this code. StrongED tries very hard to move things away from the left edge. |
Colin Ferris (399) 1748 posts |
Run out of space / memory? |
Alan Adams (2486) 1125 posts |
the size is &3000. The code uses &14d2 bytes. I’m assembling with limit checking too, as I’ve been bitten by the previously. |
Steve Drain (222) 1620 posts |
Long shot: O% and P% inside the loop? |
Alan Adams (2486) 1125 posts |
Yes. It was strange, but it’s not happening any more. In the last two weeks working on this, I’ve had about 4 occasions where syntax errors or bad variable names have been reported in the assembler section. In each case deleting the line and retyping it fixed the problem. There was no visible difference between the before and after. I didn’t think to turn on invisibles. If it happens again I might remember to try that. I’m wondering whether this is a variant of that. |
Martin Avison (27) 1418 posts |
Rndom and varied problems like that in BASIC programs can often be caused by something overwriting something within variable storage. Is the program simply the code to assemble, or does it have any indirection operators anywhere? |
Alan Adams (2486) 1125 posts |
No indirection in this case. If it happens again, I’ll try to save a copy, and trim it down to an example. |