Hello Truk,
I got this question recently from a customer, here is the answer I sent him :
A12003: Value is truncated to one byte
Description:
A word operand is specified in an assembly instruction expecting a byte operand. This warning may be generated in following cases:
•1. A symbol located in a section, which is accessible using the extended addressing mode, is specified as operand in an instruction expecting a direct operand.
•2. An external symbol imported using XREF is specified as operand in an instruction expecting a direct operand.
•3. The mask specified in a BCLR, BSET, BRCLR or BRSET is bigger than 0xFF.
Example
XREF extData
dataSec: SECTION
data: DS.B 1
data2: DS.B 1
destination: DS.W 1
codeSec: SECTION
MOVB #data, destination
MOVB #data, destination
MOVB #extData, destination
BCLR data, #$54F
Tips:
According to the reason why the warning was generated, the warning can be avoided in the following way:
•1. Specify the force operator .B at the end of the operand or < in front of the operand.
•2. Use XREF.B to import the symbol.
Example for the points above:
XREF.B extData
dataSec: SECTION
data: DS.B 1
data2: DS.B 1
destination: DS.W 1
codeSec: SECTION
MOVB #data.B, destination
MOVB #extData, destination
BCLR data, #$4F
•3. Use the SHORT modifier, here again is an example extracted from the manual:
In this example, the value in the register A is stored in the variable data which is located at address $50.
Example
MyData: SECTION SHORT
data1: DS.B 1
XREF.B data2
MyCode: SECTION
Entry:
LDS #$AFE ; init Stack Pointer
LDAA data1
main: STAA data2
BRA main
Here data1 is located in a relocatable section. To inform the assembler that this section will be placed in the zero page, the SHORT qualifier after SECTION is used.
The label data2 is imported into this code. To inform the assembler that this label can also be used with the direct addressing mode, the directive "XREF.B" is used.
You can find more details about error messages and tricky programming rules in the assembler manual
Hope this helps,
- BlackWolf -
Hi Truk,
Not sure what you have attached to your post. I can't veiw it. This message can occur where you do some maths on some variables that could _potentially_ give a bigger than 8-bit answer and then use that variable in a place that can only be 8-bits.
HTH
BR David