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

PLEASE USE MIPS ASSEMBLY LANGUAGE Assignment 2 Write a program in assembly langu

ID: 3598721 • Letter: P

Question

PLEASE USE MIPS ASSEMBLY LANGUAGE

Assignment 2 Write a program in assembly language that asks the user to input two integers in the range 1 to 1,000 and calculates their product. You can only use shift, add or sub instructions to calculate the multiplication (not the mult instruction). The program should verify that both integers are within the specified range. If either on the integers are outside this range, the program should display a message "input range error" and ask the user to input again. If user persist in entering the wrong integers more than two times, the program should exit and display message "error limit exceeded." Else it should exit after calculating the product of the two integers that are within the specified range.

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 "Error Limit Exceeded" .align 2 $LC1: .ascii "Enter the first number" .align 2 $LC2: .ascii "%d" .align 2 $LC3: .ascii "Enter the second number" .align 2 $LC4: .ascii "Input Range error " .align 2 $LC5: .ascii "The product of the number is %d" .section .text.startup,"ax",@progbits .align 2 .globl main .set nomips16 .set nomicromips .ent main .type main, @function main: .frame $sp,56,$31 # vars= 8, regs= 5/0, args= 16, gp= 8 .mask 0x800f0000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro addiu $sp,$sp,-56 sw $18,44($sp) sw $16,36($sp) lw $18,%got($LC1)($28) lw $16,%got($LC2)($28) movz $31,$31,$0 sw $19,48($sp) lw $19,%got($LC3)($28) sw $17,40($sp) .cprestore 16 sw $31,52($sp) li $17,3 # 0x3 addiu $18,$18,%lo($LC1) addiu $16,$16,%lo($LC2) $L2: addiu $17,$17,-1 $L10: bne $17,$0,$L3 li $4,1 # 0x1 lw $5,%got($LC0)($28) lw $25,%call16(__printf_chk)($28) nop .reloc 1f,R_MIPS_JALR,__printf_chk 1: jalr $25 addiu $5,$5,%lo($LC0) lw $28,16($sp) nop lw $25,%call16(exit)($28) nop .reloc 1f,R_MIPS_JALR,exit 1: jalr $25 move $4,$0 $L3: lw $25,%call16(puts)($28) nop .reloc 1f,R_MIPS_JALR,puts 1: jalr $25 move $4,$18 lw $28,16($sp) addiu $5,$sp,28 lw $25,%call16(__isoc99_scanf)($28) nop .reloc 1f,R_MIPS_JALR,__isoc99_scanf 1: jalr $25 move $4,$16 lw $28,16($sp) nop lw $25,%call16(puts)($28) nop .reloc 1f,R_MIPS_JALR,puts 1: jalr $25 addiu $4,$19,%lo($LC3) lw $28,16($sp) addiu $5,$sp,24 lw $25,%call16(__isoc99_scanf)($28) nop .reloc 1f,R_MIPS_JALR,__isoc99_scanf 1: jalr $25 move $4,$16 lw $2,28($sp) lw $28,16($sp) blez $2,$L4 nop lw $2,24($sp) nop slt $2,$2,1001 bne $2,$0,$L5 nop $L4: lw $4,%got($LC4)($28) lw $25,%call16(puts)($28) nop .reloc 1f,R_MIPS_JALR,puts 1: jalr $25 addiu $4,$4,%lo($LC4) lw $28,16($sp) $L5: lw $2,24($sp) lw $3,28($sp) bgez $2,$L6 move $6,$2 move $6,$0 $L6: mult $6,$3 mflo $6 blez $3,$L2 slt $2,$2,1001 beq $2,$0,$L10 addiu $17,$17,-1 lw $5,%got($LC5)($28) lw $25,%call16(__printf_chk)($28) addiu $5,$5,%lo($LC5) .reloc 1f,R_MIPS_JALR,__printf_chk 1: jalr $25 li $4,1 # 0x1 lw $31,52($sp) lw $19,48($sp) lw $18,44($sp) lw $17,40($sp) lw $16,36($sp) move $2,$0 j $31 addiu $sp,$sp,56 .set macro .set reorder .end main .size main, .-main .ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"

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