oldtoddler, This is how I would approch it:
BUSD VAR PORTD
A VAR BYTE
B VAR BYTE
LET A=10 (sets A bits 0..3 into %1010 = "10")
LET B=12 (sets B bits 0..3 into %1100 = "12")
BUSD = (B << 4) + A
Dave Purola,
N8NTA
oldtoddler, This is how I would approch it:
BUSD VAR PORTD
A VAR BYTE
B VAR BYTE
LET A=10 (sets A bits 0..3 into %1010 = "10")
LET B=12 (sets B bits 0..3 into %1100 = "12")
BUSD = (B << 4) + A
Dave Purola,
N8NTA
Thnx a lot Dave, my binary operations "department" needs little training... o:-)Originally Posted by Dave
Excellent, this will work fine for me.
For curiosity, what will happen if A>%1111 - does it have any effect ? (+ operand)
/MRa
oldtoddler, You should mask variable A for $1111 as adding it to B would be incorrect as far as binary. You should use something like A=A & %00001111 or A=A MIN 15. These statements will limit variable A to a maximum value of 15 or binary %00001111. You could just add the mask as such:
BUSD = (B << 4) + (A & 15)
Dave Purola,
N8NTA
Neat! Getting better all the time..Originally Posted by Dave
Thnx Dave, I'm getting the idea..
--
a = (b>c) ? (d=e,d+f) : (g=h,g+i);
Bookmarks