XGATE LDW mnemonic does not work for 16bit immediate constatnt

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

XGATE LDW mnemonic does not work for 16bit immediate constatnt

2,038 Views
Pitrunner
Contributor I
I'm using CW 5.7 and a MC9S12XDP512 controller.
Flw. problem. If I want to load a 16bit wide constant in XGATE with the LDW instruction like LDW  R4,#$1234 (see example: datasheet HCS12X controller page 338) I got flw. error message:A22005: Number or type of opernads mismatch.  What I'm doing wrong?
Labels (1)
0 Kudos
4 Replies

565 Views
CompilerGuru
NXP Employee
NXP Employee
The version number 5.7 refers to the ide, the editor, the current product version of the HC12 is 4.7,
so I'm basically don't know what you are using, its not 4.7 as this version ships with an IDE 5.9.

Anyway, the LDW is not a real XGATE instruction, it is a pseudo instruction which generates 2 actual instructions when assembled. The support for LDW is mentioned in the release noted of the 4.7 release as new feature, so I guess you are using an older version which does not support this pseudo instruction.
With your version, use the actual assembly instructions instead:

Code:
  LDL R4,#$34  ORH R4,#$12

 
Daniel

BTW: I don't like those pseudo instruction, especially with assembly I like to see things explicitely.

0 Kudos

565 Views
Pitrunner
Contributor I
Daniel,
thanks for your answer and sorry for the mismatch with the CW version. I' m using CW 4.5 build 6037.
The answer for the LDW instruction for a 16bit constant, I did it in the same way. But my real intention was to load a 16bit address from the memory, like flw.
Code:
LDW R1,#16bitaddress
Constructions like
Code:
LDL R1,#16bitaddressORH R1,#(16bitaddress >> 8)
does not work. Any hint for me?

 

 

0 Kudos

565 Views
CompilerGuru
NXP Employee
NXP Employee
Check the assembler manual, it contains how to encode all the fixups.
For HC12 V4.7, it is located:
C:\Program Files\Freescale\CodeWarrior for HCS12 V4.7\Help\PDF\Assembler_XGATE.pdf

See below how to load a 16 bit label or value into a register for the XGATE.

Daniel

Code:
Freescale XGATE-Assembler (c) Copyright Freescale 1987-2008 Abs. Rel.   Loc    Obj. code   Source line ---- ----   ------ ---------   -----------    1    1                            2    2                      LDW_MACRO: MACRO    3    3                        LDL \1 #%XGATE_8(\2)    4    4                        LDH \1,#%XGATE_8_H(\2)    5    5                       ENDM    6    6                          7    7          0000 1234    value: EQU $1234    8    8   000000 F134          LDL R1,#%XGATE_8(value)    9    9   000002 F912          LDH R1,#%XGATE_8_H(value)   10   10                         11   11                       LDW_MACRO R1,value   12    3m  000004 F134       +  LDL R1 #%XGATE_8(value)   13    4m  000006 F912       +  LDH R1,#%XGATE_8_H(value)   14   12                          15   13                       LDW_MACRO R1,$1234    16    3m  000008 F134       +  LDL R1 #%XGATE_8($1234)   17    4m  00000A F912       +  LDH R1,#%XGATE_8_H($1234)   18   14                          19   15                       ; V4.7 and later   20   16   00000C F134 F912    LDW R1,#value   21   17   000010 F134 F912    LDW R1,#$1234   22   18                      

 

0 Kudos

565 Views
Pitrunner
Contributor I
Daniel,
thanks for your help. The macro does it, what I want.

0 Kudos