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

Write a MIPS assembly language program that will cover the following steps: Prom

ID: 3696700 • Letter: W

Question

Write a MIPS assembly language program that will cover the following steps: Prompt the user to enter a first negative integer in the range [-30, 0) named integer1 Prompt the user to enter a second negative integer in the range [-20, -5] named integer2 Compute (int1 - 2*int2) // don’t use subi; If the result is a positive number, print a message saying “the result is a positive number equal to result_value” Else, if the result is a negative number, print a message saying “the result is a negative number equal to result_value” Repeat until sentinel value entered The program should enforce the rule that the two entered integers must be in the correct intervals. If the entered integer is not in the specified range, prompt again the user to enter an integer in the specified range. Use 99 for the sentinel value. It will allow the user to exit the program

Explanation / Answer

.Ltext0:
.section   .rodata
.align 8
.LC0:
.string   "Enter the first number between -30 to 0"
.LC1:
.string   "%d"
.align 8
.LC2:
.string   "Enter the second number between -20 to -5"
.align 8
.LC3:
.string   "the result is a positive number equal to %d "
.align 8
.LC4:
.string   "Sentinel value entered....exiting from program"
.text
.globl   main
main:
.LFB0:
.cfi_startproc
pushq   %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq   %rsp, %rbp
.cfi_def_cfa_register 6
subq   $32, %rsp
movq   %fs:40, %rax
movq   %rax, -8(%rbp)
xorl   %eax, %eax
movl   $0, -16(%rbp)
.L2:
movl   $.LC0, %edi
call   puts
movl   -20(%rbp), %eax
testl   %eax, %eax
jns   .L3
movl   -20(%rbp), %eax
cmpl   $-30, %eax
jl   .L3
leaq   -20(%rbp), %rax
movq   %rax, %rsi
movl   $.LC1, %edi
movl   $0, %eax
call   __isoc99_scanf
jmp   .L4
.L3:
movl   -20(%rbp), %eax
cmpl   $99, %eax
je   .L14
EBC1   jmp   .L2
.L4:
movl   $.LC2, %edi
call   puts
cmpl   $-4, -12(%rbp)
   jge   .L7
cmpl   $-19, -12(%rbp)
jl   .L7
leaq   -20(%rbp), %rax
movq   %rax, %rsi
movl   $.LC1, %edi
movl   $0, %eax
call   __isoc99_scanf
movl   -12(%rbp), %edx
movl   $0, %eax
subl   %edx, %eax
addl   %eax, %eax
movl   %eax, %edx
movl   -20(%rbp), %eax
addl   %edx, %eax
movl   %eax, -16(%rbp)
cmpl   $0, -16(%rbp)
jg   .L8
jmp   .L13
.L7:
cmpl   $99, -12(%rbp)
je   .L15
jmp   .L4
.L8:
movl   -20(%rbp), %eax
movl   %eax, %esi
movl   $.LC3, %edi
movl   $0, %eax
call   printf
jmp   .L6
.L13:
movl   -12(%rbp), %eax
movl   %eax, %esi
movl   $.LC3, %edi
movl   $0, %eax
call   printf
jmp   .L6
.L14:
nop
jmp   .L6
.L15:
nop
.L6:
movl   $.LC4, %edi
movl   $0, %eax
call   printf
movl   $0, %eax
movq   -8(%rbp), %rcx
xorq   %fs:40, %rcx
je   .L12
call   __stack_chk_fail
.L12:
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.Letext0:

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