In: Computer Science
IN MIPS ASSEMBLY LANGUAGE
Write an assembly program to read three 32-bit signed integers from the user. Determine the smallest of these three numbers and display this result. Don’t use loops. Prompt the user for each entered integer.
Your output should look something like the following example.
Enter an integer: 7556
Enter an integer: -22984
Enter an integer: 8875
-22984
.LC0:
.string " Enter three Integer numbers for x, y, z : "
.LC1:
.string "%d %d %d"
.LC2:
.string "\n x is smallest : %d"
.LC3:
.string "\n y is smallest : %d"
.LC4:
.string "\n z is smallest : %d"
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 edx, DWORD PTR [rbp-4]
mov eax, DWORD PTR [rbp-8]
cmp edx, eax
jge .L2
mov edx, DWORD PTR [rbp-4]
mov eax, DWORD PTR [rbp-12]
cmp edx, eax
jge .L2
mov eax, DWORD PTR [rbp-4]
mov esi, eax
mov edi, OFFSET FLAT:.LC2
mov eax, 0
call printf
jmp .L3
.L2:
mov edx, DWORD PTR [rbp-8]
mov eax, DWORD PTR [rbp-12]
cmp edx, eax
jge .L4
mov eax, DWORD PTR [rbp-8]
mov esi, eax
mov edi, OFFSET FLAT:.LC3
mov eax, 0
call printf
jmp .L3
.L4:
mov eax, DWORD PTR [rbp-12]
mov esi, eax
mov edi, OFFSET FLAT:.LC4
mov eax, 0
call printf
.L3:
mov eax, 0
leave
ret