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

Write a MIPS function that given two user inputed integers, returns the product

ID: 3808429 • Letter: W

Question

Write a MIPS function that given two user inputed integers, returns the product of those two integers. You may NOT use arithmetic instructions in the code as primitives.

The eligible primitives for this programming exercise include:

·       Logical instructions such as: and, or, not, xor

·       Shift and rotate instructions such as: sll, srl, ror, rol, sra

·       Branch and jump instructions such as: beq, bne, bls, ble, bgt, bge, j, jal, jr

EXCEPTION : You may use the addi instruction to change the stack pointer register, $sp, in the push and pop operations.

Explanation / Answer

main: .frame $fp,48,$31 # vars= 16, regs= 2/0, args= 16, gp= 8 .mask 0xc0000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro addiu $sp,$sp,-48 $LCFI0: sw $31,44($sp) $LCFI1: sw $fp,40($sp) movz $31,$31,$0 $LCFI2: move $fp,$sp $LCFI3: .cprestore 16 addiu $3,$fp,28 addiu $2,$fp,32 lw $4,%got($LC0)($28) nop addiu $4,$4,%lo($LC0) move $5,$3 move $6,$2 lw $2,%call16(scanf)($28) nop move $25,$2 jalr $25 nop lw $28,16($fp) lw $3,28($fp) lw $2,32($fp) nop mult $3,$2 mflo $2 sw $2,24($fp) lw $2,24($fp) move $sp,$fp lw $31,44($sp) lw $fp,40($sp) addiu $sp,$sp,48 j $31 nop .set macro .set reorder .end main $LFE0: .size main, .-main .section .eh_frame,"aw",@progbits $Lframe1: .4byte $LECIE1-$LSCIE1 $LSCIE1: .4byte 0x0 .byte 0x1 .globl __gxx_personality_v0 .ascii "zP" .uleb128 0x1 .sleb128 -4 .byte 0x1f .uleb128 0x5 .byte 0x0 .4byte __gxx_personality_v0 .byte 0xc .uleb128 0x1d .uleb128 0x0 .align 2 $LECIE1: $LSFDE1: .4byte $LEFDE1-$LASFDE1 $LASFDE1: .4byte $LASFDE1-$Lframe1 .4byte $LFB0 .4byte $LFE0-$LFB0 .uleb128 0x0 .byte 0x4 .4byte $LCFI0-$LFB0 .byte 0xe .uleb128 0x30 .byte 0x4 .4byte $LCFI2-$LCFI0 .byte 0x11 .uleb128 0x1e .sleb128 2 .byte 0x11 .uleb128 0x1f .sleb128 1 .byte 0x4 .4byte $LCFI3-$LCFI2 .byte 0xd .uleb128 0x1e .align 2 $LEFDE1: .ident "GCC: (Debian 4.4.5-8) 4.4.5"

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