I've got a similar issue. I'm a newbie to CW and Freescale/Motorola micros in general, so maybe there's something simple I'm not doing. I'm using CW 5.7.0 with the MC9S08GB60.
I've got a byte defined in my zero page, as so: ; variable/data section MY_ZEROPAGE: SECTION SHORT ;Transmit enabled flag. Controls transmission over RS-485 gbSGTE: DS.B 1 ;...other variables not relevant to my post.
And in my code, which is later in the same file, I've got a branch using gbSGTE: BRCLR 0, gbSGTE, \@FINISH ;Skip transmitting if not enabled.
This gives me A13003, Value truncated to one byte, even though the generated machine code is correct, at least in the debugger it looks correct. MY_ZEROPAGE is definitely in the zero page, as when I look at the assembly in the debugger, all the variables declared in MY_ZEROPAGE have addresses below $ff.
The problem is with gbSGTE, not \@FINISH, which is only +19 from the branch instruction. I can continue working for now, as it's 'only' a warning, and like I said the generated machine code turns out fine, so it's just annoying, but I would obviously like to get rid of it.
I understand that labels are 16-bit by default, but I would think that if you explicitly declare SECTION SHORT, that wouldn't be a problem. Is there a way I can force it to interpret gbSGTE as an 8-bit label?
That is odd. I do what you seem to be doing all of the time, but I don't get that error message, unless:
1) The variable is really not in the zero-page (not the case for you), or 2) The variable is defined after the code is defined (also doesn't seem to be the case).
However, it looks like you may be doing a few things different from me:
One is that you are using the "SECTION" directive to define page zero, whereas I use the "BSCT" directive. Maybe the assembler is not interpreting the "SHORT" keyword correctly (the linker has to) whereas it interprets "BSCT" correctly.
Second is that the label "\@FINISH" is in a format that is typically used within a macro. Are you doing this within a macro? I can't see how that would make a difference, however.
Unfortunately that didn't solve it. Actually, when I used BSCT, the variables weren't in the zero page anymore! I looked in the help files and I seemed to be using it right, but there it was, so I went back to my SECTION SHORT format.
I fixed my problem by declaring the variable in a separate assembly file and importing it using XREF.B, which does force it to an 8-bit label. Problem solved, if not satisfactorily understood.
But although these warnings are often of no consequence, the assembler doesn't know whether it is or not.
The reason you got the error is that you did an addition of two constants, and constant math is done with 32-bit precision within the assembler. Since the LDA-immediate instruction only takes one byte as an operand, the 32-bit value had to be truncated. The assembler does not know if you meant to truncate or not.
You can avoid this error by doing the truncation explicitly:
Or, you could pre-define the constant, though I don't understand why this doesn't cause the error also:
Thanks Rocco. The first thing I looked for was to see if the symbol was defined prior to the code, and it was. At least to my eyeballs it was, but it turned out that it was not. So, moving the equate line prior to the code stops the warning. (been there done that)
This is the only assembler I've used that can't wait until pass #2 to flag this as a warning/error, and then do it only if the symbol evaluates to something larger than will fit in a register.