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

Write pseudocode for a program which allows the user to input two numbers (X and

ID: 3813036 • Letter: W

Question

Write pseudocode for a program which allows the user to input two numbers (X and Y) and a code

C. If the code has value 1, the program should output the larger of X and Y and otherwise output the smaller. Now convert your pseudocode to an assembly language program use the attached image to help.

Message load x x R. R ->x store 0 ->x clear x R x R. add x increment x x 1 x subtract x R. decrement x x 1 x if x R then. Compare 100 CCR else if x R then 001 CCR else if x R then 010 CCR jump x goto goto x if CCR. 100 jumpgt jumpeq goto x if CCR. 010 x jumplt x goto x if CCR. 001 goto x if CCR 010 jumpneq x in x store input in x (out X output halt

Explanation / Answer

Pseudo code:
begin
read x,y
read code
if code==1
begin
if x>y
display x is larger
else
display y is larger
end if
else
begin
if x>y
dispay y is smaller
else
display x is smaller
end else
end

assembly language program :

.LC0:
.string "Enter value of x y and code "
.LC1:
.string "%d %d %d"
.LC2:
.string "X is greater"
.LC3:
.string "y is greater"
.LC4:
.string "Y is smaller"
.LC5:
.string "X is smaller"
main:
push rbp
mov rbp, rsp
sub rsp, 16
mov edi, OFFSET FLAT:.LC0
mov eax, 0
call printf
lea rcx, [rbp-12]
lea rdx, [rbp-8]
lea rax, [rbp-4]
mov rsi, rax
mov edi, OFFSET FLAT:.LC1
mov eax, 0
call scanf
mov eax, DWORD PTR [rbp-12]
cmp eax, 1
jne .L2
mov edx, DWORD PTR [rbp-4]
mov eax, DWORD PTR [rbp-8]
cmp edx, eax
jle .L3
mov edi, OFFSET FLAT:.LC2
mov eax, 0
call printf
jmp .L5
.L3:
mov edi, OFFSET FLAT:.LC3
mov eax, 0
call printf
jmp .L5
.L2:
mov edx, DWORD PTR [rbp-4]
mov eax, DWORD PTR [rbp-8]
cmp edx, eax
jle .L6
mov edi, OFFSET FLAT:.LC4
mov eax, 0
call printf
jmp .L5
.L6:
mov edi, OFFSET FLAT:.LC5
mov eax, 0
call printf
.L5:
mov eax, 0
leave
ret

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