I think this is what you are attempting to do:
mov ebp,str
mov eax,ebp
mov ebx,[eax]
test ebx,0xFF
jz low_byte_empty
do_something:
; some code here...
low_byte_empty:
test ebx,0xFFFF
jz low_word_empty
do_b_something:
; some code here.
low_word_empty:
Explanation:
First, as JasonD already mentions in his answer, you are loading a pointer to eax
, then doing a logical and
to it, then you are using the result still in eax
to address memory (some memory offset in the range 0x0
... 0xFF
).
So what goes wrong in your code: you can't keep in the same register both a pointer to a memory address and a value at the same time. So I chose to load the value from [eax]
to ebx
, you can also use some other 32-bit general register (ecx
, edx
, esi
, edi
) according to your needs.
Then, you don't need to use cmp
to check if a register is empty, because all cmp
does is that it does the subtraction and sets the flags. But ZF (zero flag) is already set by and
, so cmp
is absolutely unnecessary here. Then, as cmp
is not needed here and we do not need the result either, we only want to update the flags, it's better to use test
. test
does exactly the same logical AND as and
does, the only difference being that test
does not store the result, it only updates the flags.