Question about constants
I have a program in which I have defined constants which are larger than 8 bits such as
I am wondering how I can access the LSB and MSB of these constants using the following convention doesn't seem to work
Any help is much appreciated
thanks
GC
A con 4000
I am wondering how I can access the LSB and MSB of these constants using the following convention doesn't seem to work
X=A_LSB
Any help is much appreciated
thanks
GC
Comments
X = A >> 8 ' use high byte, consumes code space (A>>8 will be computed runtime, not compile time)
X = A ' low byte (high byte thrown away) or more clearly:
X = A & $00FF ' consumes code space
Alternatively, you could define the derived constants...
A CON $F0F0
A_LSB CON A & $00FF
A_HSB CON A >> 8 ' no code space
In ASM you can use constructions like this that do not consume code...
ASM
MOV X, #A & $FF ' low byte
MOV X, #A >> 8 ' high byte -- literal manipulations do not consume code space
ENDASM
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
that worked perfectly thank you
GC