Good day
I am trying to use a microcontroller HCS12
I have a module built in Assembler, and I would like to automatically exchange the "BRA" and "LBRA" command on assembler code
I built this macro in which it should automatically recognize if the jump distance is too big for the BRA command.
MyBRA macro
if ( \1 < (*)+256)
BRA \1
else
LBRA \1
endif
endm
Unfortunately the compiler shows me an error on line "if( \1 <(*)+256)" : "A2314 expression must be absolute"
Is there a method in assembler to make this macro work? ... or another method that works
My purpose is to make the assembler decide whether to use LBRA or BRA
Thanks to all
Hi
You have error A2314. This error description.
OFFSET, ORG, ALIGN, SET, BASE,
DS, LLEN, PLEN, SPC, TABS, IF, IFEQ, IFNE, IFLE, IFLT, IFGE, IFGT.
The first operand in a DCB directive must be absolute:Thanks ZhangJennie ....To simplify everything ..... I tried to create new project ... a small example of testing in "relocable assembler":
main.asm:
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
; export symbols
XDEF Entry, _Startup, main
XREF __SEG_END_SSTACK ; symbol defined by the linker for the end of the stack
MyBRA macro
if (\1<(*+256))
BRA \1
else
LBRA \1
endif
endm
; variable/data section
MY_EXTENDED_RAM: SECTION
Counter ds.w 1
; code section
MyCode: SECTION
main:
_Startup:
Entry:
LDS #__SEG_END_SSTACK ; initialize the stack pointer
EndlessLoop:
LDX #1 ; X contains counter
CouterLoop:
STX Counter ; update global.
LDX Counter
INX
CPX #24 ; larger values cause overflow.
BNE CouterLoop
MyBRA EndlessLoop ; restart. ;<<<<<<<<<<<<<<<< My macro <<<<<<<<
Unfortunately now it gives me a different mistake
A2401:Complex relocable expression not supported
Macro Expression "if(EndlessLoop <* + 256)"
Hi Molibdeno
Please follow this tips to fix error
XDEF offset DataSec1: SECTION SHORT DataLbl1: DS.B 10 DataSec2: SECTION SHORT DataLbl2: DS.W 15 offset: EQU DataLbl2 - DataLbl1
If both DataSec1 and DataSec2 are in the same section and defined in this module, the assembler can compute the difference:
DataSec1: SECTION SHORT DataLbl1: DS.B 10 DataLbl2: DS.W 15 offset: EQU DataLbl2 - DataLbl1
Have a nice day
Jun Zhang