Question

Write an assembly language code for the following pseudo code i. if(op1 == op2) x=1; else...

Write an assembly language code for the following pseudo code

i. if(op1 == op2)

x=1;

else x=2;

using x86 assembly language

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

MOV AX,op1
MOV BX,op2
IF: CMP AX,BX
   JE TAG
   JNE ELSE
  
ELSE:
MOV CX,#2
   MOV X,CX
   JMP ENFIF
  
TAG:
   MOV CX,#1
   MOV X,CX
   JMP ENFIF
  
ENDIF:

Explanation:

Initially we move op1 and op2 to AX and BX registers.

Now we check the if condition, compare AX and BX.

JE - Jump if equal

JNE - Jump if not equal.

If AX and BX are equal, TAG label statements gets executed.

Else the Else label statements gets executed.

TAG:

We move value 1 to CX register and then to location X

ELSE:

We move value 2 to CX register and then to location X

Add a comment
Know the answer?
Add Answer to:
Write an assembly language code for the following pseudo code i. if(op1 == op2) x=1; else...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT