CW5.1 Assembler-Error "Value is truncatet in 1 byte"

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CW5.1 Assembler-Error "Value is truncatet in 1 byte"

2,055 Views
Truk
Contributor I
For this projekt I have taken some files from an old MC05-Project which was written with a DOS-based P&E assembler.
I didn't anderstud why I get message mentioned above because I have specified the ZERO_RAM page.
regard,
Truk
 
Labels (1)
0 Kudos
3 Replies

432 Views
Blackwolf
Contributor III

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 -

 

 

 

0 Kudos

432 Views
peg
Senior Contributor IV

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

 

0 Kudos

432 Views
rocco
Senior Contributor II
Besides the causes that David mentioned, this warning can occur if a value is referenced before it is defined. In that case, the assembler doesn't yet know that the address is in page zero.
0 Kudos