aliases and modifiers
Speaker337
Posts: 14
I have a variable.
code var byte
It has three parts. XXX,YY,ZZZ. I want to name these three parts.
I want to name XXX as mode and ZZZ as arrow.
Reading the manual, it should be something like
code var byte
mode var code.bit5...bit7. Yes?
But it doesn't work. I get "variable is already bit sized."
mode var code.highnib gives the expected result, but is 4 bits rather than three.
Can someone point me to an example?
code var byte
It has three parts. XXX,YY,ZZZ. I want to name these three parts.
I want to name XXX as mode and ZZZ as arrow.
Reading the manual, it should be something like
code var byte
mode var code.bit5...bit7. Yes?
But it doesn't work. I get "variable is already bit sized."
mode var code.highnib gives the expected result, but is 4 bits rather than three.
Can someone point me to an example?
Comments
To extract xxx, use: result = value >> 5
To extract yy, use: result = (value >> 3) & 3
To extract zzz, use: result = value & 7
To insert xxx, use: result = (result & $1F) | (value << 5)
To insert yy, use: result = (result & $18) | (value << 3)
To insert zzz, use: result = (result & $F8) | value