Name one instruction that can be used to explicitly set the

Name one instruction that can be used to explicitly set the condition codes without altering any other registers. What flags does this instruction alter? B) In how many ways can you categorize jump instructions in x86-IA32 architecture? Write a short piece of assembly code to illustrate in an example each category of jump instruction?

Solution

A) TEST operand1, operand2

Test calculates operand1&operand2 and sets the condition codes accordingly. The TEST instruction works same as the AND operation, but unlike AND instruction, it does not change the first operand. It alters the ZF(zero) and SF(sign) flags accordingly

B) Jump istructions can be catogorised as:

1) Unconditional jump: Aa unconditional jump branches always

   2) Conditional Jump: A conditional jump branches if a condition is met.The conditional Jump instruction check the flag conditions and make decisions either to change or not change the sequence of the program.

cmp (var1 , ecx); //compare ecx with var1

setg(bl); // store var1>exc in bl

cmp(ecx, edx);

setg(bh);

and(bh,bl)

jz L1; //jump to L1 if zero

mov(x, 1);

jmp Endcase; // jump without any condition

L1:

mov(x,2);

Endcase:

 Name one instruction that can be used to explicitly set the condition codes without altering any other registers. What flags does this instruction alter? B) In

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site