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 to do the following. Do not use any pseud

ID: 3749357 • Letter: W

Question

Write a MIPS assembly language program to do the following. Do not use any pseudo or extended instructions, No Functions.

1. Print your name

2. Using a bottom testing loop, prompt the user to enter a number from 1 to 5. If the number entered is not in the range from1 to 5, print an error message. Your program should continue to prompt for and read input until a value from 1 to 5 is entered.

3. Once the number is 1 to 5, then using a top testing loop, repeat the following the number of times that you finally got in the range from 1 to 5.

a. Prompt for and read two integers.

   b. Print the absolute value of the difference of the numbers.

   c. If the first integer is less than or equal to the second integer, print the sum of the integers from the first integer THROUGH the second integer. Otherwise if the first integer is    greater than the first integer, print an error message.

4. Print “program complete” and then stop

Example input and output:

Ima Student

Enter a number from 1 to 5: 0

Input is out of range

Enter a number from 1 to 5: 3 This means that next section is done 3 times.

Enter the first number: 3

Enter the second number: 3

Absolute value of the difference = 0

Sum of the values = 3

Enter the first number: 2

Enter the second number: 8

Absolute value of the difference = 6

Sum of values = 35

Enter the first number: 5

Enter the second number: -2

Absolute value of the difference = 7

Sum of values cannot be determined

Program ending Specifics: Use only the instructions covered to date. No functions, etc. Document every instruction.

Explanation / Answer

------------------------------------------------

.file 1 ""

.section .mdebug.abi32

.previous

.nan legacy

.module fp=32

.module nooddspreg

.abicalls

.section .rodata.str1.4,"aMS",@progbits,1

.align 2

$LC0:

.ascii "Maria Dhinesh"

.align 2

$LC1:

.ascii "Enter the number of times to test: %d"

.align 2

$LC2:

.ascii "Error message: input should be greater than 1"

.align 2

$LC3:

.ascii "Enter a number %d"

.align 2

$LC4:

.ascii "Error: There is no number to test"

.align 2

$LC5:

.ascii "The smallest number %d The largest number %d"

.align 2

$LC6:

.ascii "Program complete"

.text

.align 2

.globl main

.set nomips16

.set nomicromips

.ent main

.type main, @function

main:

.frame $sp,64,$31 # vars= 8, regs= 7/0, args= 16, gp= 8

.mask 0x803f0000,-4

.fmask 0x00000000,0

.set noreorder

.cpload $25

.set nomacro

addiu $sp,$sp,-64

sw $31,60($sp)

sw $21,56($sp)

sw $20,52($sp)

sw $19,48($sp)

movz $31,$31,$0

sw $18,44($sp)

sw $17,40($sp)

sw $16,36($sp)

.cprestore 16

lw $5,%got($LC0)($28)

nop

addiu $5,$5,%lo($LC0)

li $4,1 # 0x1

lw $25,%call16(__printf_chk)($28)

nop

.reloc 1f,R_MIPS_JALR,__printf_chk

1: jalr $25

nop

lw $28,16($sp)

addiu $5,$sp,24

lw $4,%got($LC1)($28)

nop

addiu $4,$4,%lo($LC1)

lw $25,%call16(__isoc99_scanf)($28)

nop

.reloc 1f,R_MIPS_JALR,__isoc99_scanf

1: jalr $25

nop

lw $28,16($sp)

lw $2,24($sp)

nop

bgtz $2,$L2

li $4,1 # 0x1

lw $5,%got($LC2)($28)

nop

addiu $5,$5,%lo($LC2)

lw $25,%call16(__printf_chk)($28)

nop

.reloc 1f,R_MIPS_JALR,__printf_chk

1: jalr $25

nop

lw $28,16($sp)

b $L3

move $2,$0

$L2:

lw $18,%got($LC3)($28)

nop

addiu $18,$18,%lo($LC3)

lw $21,%got($LC5)($28)

nop

addiu $21,$21,%lo($LC5)

lw $20,%got($LC4)($28)

nop

addiu $20,$20,%lo($LC4)

$L10:

addiu $5,$sp,28

move $4,$18

lw $25,%call16(__isoc99_scanf)($28)

nop

.reloc 1f,R_MIPS_JALR,__isoc99_scanf

1: jalr $25

nop

lw $28,16($sp)

lw $16,28($sp)

nop

beq $16,$0,$L4

move $2,$16

move $17,$16

addiu $19,$sp,28

slt $3,$2,$16

$L16:

beq $3,$0,$L14

slt $3,$17,$2

move $16,$2

$L14:

beq $3,$0,$L15

move $5,$19

move $17,$2

$L15:

move $4,$18

lw $25,%call16(__isoc99_scanf)($28)

nop

.reloc 1f,R_MIPS_JALR,__isoc99_scanf

1: jalr $25

nop

lw $28,16($sp)

lw $2,28($sp)

nop

bne $2,$0,$L16

slt $3,$2,$16

bne $16,$0,$L8

move $7,$17

$L4:

move $5,$20

li $4,1 # 0x1

lw $25,%call16(__printf_chk)($28)

nop

.reloc 1f,R_MIPS_JALR,__printf_chk

1: jalr $25

nop

lw $28,16($sp)

b $L9

nop

$L8:

move $6,$16

move $5,$21

li $4,1 # 0x1

lw $25,%call16(__printf_chk)($28)

nop

.reloc 1f,R_MIPS_JALR,__printf_chk

1: jalr $25

nop

lw $28,16($sp)

$L9:

lw $2,24($sp)

nop

addiu $2,$2,-1

bgtz $2,$L10

sw $2,24($sp)

lw $5,%got($LC6)($28)

nop

addiu $5,$5,%lo($LC6)

li $4,1 # 0x1

lw $25,%call16(__printf_chk)($28)

nop

.reloc 1f,R_MIPS_JALR,__printf_chk

1: jalr $25

nop

lw $28,16($sp)

li $2,1 # 0x1

$L3:

lw $31,60($sp)

lw $21,56($sp)

lw $20,52($sp)

lw $19,48($sp)

lw $18,44($sp)

lw $17,40($sp)

lw $16,36($sp)

j $31

addiu $sp,$sp,64

.set macro

.set reorder

.end main

.size main, .-main

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