I tried to solve a question shown below;
By just using and, and jg or jle, how can one implement following code?
if %eax > 4
jmp do
else
jmp l1
of course without changing value of eax
This question is taken from a textbook, but it has no answer. Can you show me how to solve it?
EDIT:
I have tried ;
subl $4, %eax
andl %eax, %eax
jg do
jmp l1
.
.
.
do :
addl $4, %eax
.
.
.
l1:
addl $4, %eax
The below sequence of
andandjlesolves the problem (NASM syntax is used):The caveat here is that this is a use-once piece of code because it irreversibly modifies 2 (or 3) variables.