Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in assembly language that loads register R2 with the word in mem

ID: 1996303 • Letter: W

Question

Write a program in assembly language that loads register R2 with the word in memory location which is 10 bytes above the address in R0; and loads register R3 with the word in memory location which is 10 bytes below the address in R1. Your program must compare the two numbers in R2 and R3. If number in R2 is less than or equal to the number in R3 it must add the two numbers and save the result in the memory location pointed to by R4. Otherwise, your program must subtract the number in R3 from R2 and save the result in the memory location pointed to by R5.

Explanation / Answer

CLR psw.3

SETB psw.4

MOV R2,1A

MOV R3, 06H

MOV A, R2

CJNE A,@R3, NEXT ; Jump to next if not equal and if r2>r3 then cy=0

ADD R3

MOV @R4, A

NEXT : JC NOW ; Jump to Now if CY=1

SUB R3

MOV @R5,A

NOW : ADD R3

MOV @R4, A

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote