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

Use SPIM to write the program, do not use C++ or JAVA, or C!!! Problem 2 (50 pts

ID: 3734614 • Letter: U

Question

Use SPIM to write the program, do not use C++ or JAVA, or C!!!

Problem 2 (50 pts.): Write a complete program to calculate the area of a square in square inches. You would need to: Prompt the user to input side dimension in feet as declared with label com: in the data section Read the input from the keyboard Calculate the area in square inches Print a header as declared with label ans: in the data section . Print the area Terminate the program What would be printed on the console if the user inputs 5 when prompted? The data section is given below data com: asciiz "Input side dimension in feet" ans: asciz "Area in square inches is"

Explanation / Answer

$LC0: .ascii "Input side dimension in feet:" .align 2 $LC1: .ascii "%f" .align 2 $LC3: .ascii "Area in square inches is: %f" .section .text.startup,"ax",@progbits .align 2 .globl main main: .frame $sp,40,$31 # vars= 8, regs= 1/0, args= 16, gp= 8 .mask 0x80000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro lw $5,%got($LC0)($28) addiu $sp,$sp,-40 lw $25,%call16(__printf_chk)($28) addiu $5,$5,%lo($LC0) sw $31,36($sp) movz $31,$31,$0 .cprestore 16 .reloc 1f,R_MIPS_JALR,__printf_chk 1: jalr $25 li $4,1 # 0x1 lw $28,16($sp) addiu $5,$sp,24 lw $4,%got($LC1)($28) lw $25,%call16(__isoc99_scanf)($28) nop .reloc 1f,R_MIPS_JALR,__isoc99_scanf 1: jalr $25 addiu $4,$4,%lo($LC1) lw $28,16($sp) lwc1 $f0,24($sp) lw $2,%got($LC2)($28) mul.s $f0,$f0,$f0 lwc1 $f2,%lo($LC2)($2) lw $5,%got($LC3)($28) lw $25,%call16(__printf_chk)($28) mul.s $f0,$f0,$f2 addiu $5,$5,%lo($LC3) cvt.d.s $f0,$f0 mfc1 $7,$f0 mfc1 $6,$f1 .reloc 1f,R_MIPS_JALR,__printf_chk 1: jalr $25 li $4,1 # 0x1 lw $31,36($sp) move $2,$0 j $31 addiu $sp,$sp,40