I can\'t decide if it is b or c. jle means jump if desitination <= source, so wi
ID: 3687372 • Letter: I
Question
I can't decide if it is b or c. jle means jump if desitination <= source, so will it skip the je line given that je means jump if deistinatoin =source?
Select the pseudo-code that most closely corresponds to the following assembly code. Assume that the variables a, b, c, and d are initialized elsewhere in the program. Pay close attention to the conditional jumps, the corresponding pseudo code may surprise you!
.data
; General purpose variables
a DWORD ?
b DWORD ?
c BYTE ?
d BYTE ?
upperLevel DWORD 18
lowerLevel DWORD 3
; Strings
yes BYTE "Yes",0
no BYTE "No",0
maybe BYTE "Maybe",0
.code
main PROC
mov eax, a
cmp eax, b
jle option1
je option2
jmp option3
option1:
mov edx, OFFSET yes
call WriteString
jmp endOfProgram
option2:
mov edx, OFFSET no
call WriteString
jmp endOfProgram
option3:
mov edx, OFFSET maybe
call WriteString
endOfProgram:
exit
main ENDP
END main
a) if (a > b)
print (yes);
else if (a == b)
print (no);
else
print (maybe);
b) if (a < b) OR (a == b)
print (yes);
else
print (maybe);
c) if (a < b)
print (yes);
else if (a == b)
print (no);
else
print (maybe);
d) if (a > b) OR (a == b)
print (yes);
else
print (maybe);
Explanation / Answer
jle-jump is destination is less than or equal to source->This is for the signed numbers
JE->jump if destination is equal to source->This is for unsigned numbers
As a result JE will also be checked because its not mentioned the inputs are signed numbers or not...They will be considered as unsigned numbers,In the pogram the numbers 18 and 3 .This means they are positive .
As a result
b) if (18< 3) OR (18 == 3)
print (yes);// this is true so this will be executed
As a result the code corresponsind to this will be TO DISPLAY THE YES:
option1:
mov edx, OFFSET yes
call WriteString
jmp endOfProgram
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.