Folks,

I am having trouble with using a shr and testing for Carry and would appreciate some comments / assistance.

The following code provides some insight to my objective:

; Move an arbitrary value into AL
mov al,5
; Move the AL register to the right and test that a "1" moved into the bit bucket
shr eax,1
.IF CARRY?

// carry on shifting and testing

All that happens is that as each bit is tested, a message pops up. I would have expected that a message would only be produced (in this case) on the first and third shr.

Many Thanks for your help,

Timothy
Posted on 2003-11-23 22:09:24 by Timothy_B
Something like


mov eax, 5
_begin:
shr eax, 1
pushfd
jnc @F
invoke MessageBox,0,0,0,0
@@:
popfd
jnz _begin

?
Posted on 2003-11-24 04:37:37 by roticv
you need to preserve eax, not the s. flags. And
invoke MessageBox,0,0,0,0
will not show any message (it'll return immediately).


mov eax, 5
_begin:
shr eax, 1
jnc @F
push eax
invoke MessageBeep,MB_ICONEXCLAMATION
pop eax
@@:
or eax,eax
jnz _begin
Posted on 2003-11-24 11:32:15 by Ultrano
MY mistake. Actually I did not want the test whether eax is zero or not. Therefore I preserved the flags. Well if the value is in ebx, esi or edi, my code will work. :)
Posted on 2003-11-24 11:40:55 by roticv