TASM command to checking even or odd number?
Hi guys. I was just wondering if there is a command in TASM to check if the register (16 or 8 bit registers) value is in odd or even number? I'm suppose to do this project where i will add 2 array value into the register. If it check it is odd value it will add 1 into a specific location in an array. If it is even then it will add 0 into a specific array as well. If this command doesn't exist, what other method can i use to check if it is even or odd? Hope you could help me guys. Thanks!
Re: TASM command to checking even or odd number?
I'm not sure in TASM - but the concept of checking for ODD or EVEN involves seeing if BIT 0 (value 1) is set in the integer. If 1 is set, then the value is odd - otherwise it's even.
Re: TASM command to checking even or odd number?
let say ax (8 bits) is 3F,
so,
3F is 63 is odd
ax strcuture
0011 1111
and
0000 0001
so u got
1 and that is odd
Code:
0AE6:0100 B83F00 MOV AX,003F
0AE6:0103 250100 AND AX,0001
so, the ax after third trace would contained 1 and u know that is odd, if zero, that mean it is even.
Re: TASM command to checking even or odd number?
Or just use the BitTest instruction (bt) that doesn't disrupt the contents of ex...
Code:
mov ax, 3fh
bt ax, 0
jnc EVEN
ODD:
; blah
jmp DONE
EVEN:
; blah
DONE: