Write a recursive function in MIPS Assembly Language that computes the smallest
ID: 3857353 • Letter: W
Question
Write a recursive function in MIPS Assembly Language that computes the smallest integer in a given array of integers. Use the following algorithm:
int Min( int[] A, int low, int high)
{ if (low== high) return A[low];
int mid = (low+high)/2;
int min1 = Min( int[] A, low, mid);
int min2 =Min( int[] A, mid +1, high);
if(min1>min2) return min2;
return min1;
}
Please only answer if you're going to write this in MIPS assembly language, no psuedo, no C, no java, no other assembly language (it is not helpful) thank you.
Explanation / Answer
.file 1 "" .section .mdebug.abi32 .previous .gnu_attribute 4, 1 .abicalls .text .align 2 .globl _Z3MinPiii $LFB0 = . .set nomips16 .ent _Z3MinPiii .type _Z3MinPiii, @function _Z3MinPiii: .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 sw $4,48($fp) sw $5,52($fp) sw $6,56($fp) lw $3,52($fp) lw $2,56($fp) nop bne $3,$2,$L2 nop lw $2,52($fp) nop sll $2,$2,2 lw $3,48($fp) nop addu $2,$3,$2 lw $2,0($2) b $L3 nop $L2: lw $3,52($fp) lw $2,56($fp) nop addu $2,$3,$2 srl $3,$2,31 addu $2,$3,$2 sra $2,$2,1 sw $2,32($fp) lw $4,48($fp) lw $5,52($fp) lw $6,32($fp) lw $2,%got(_Z3MinPiii)($28) nop move $25,$2 jalr $25 nop lw $28,16($fp) sw $2,28($fp) lw $2,32($fp) nop addiu $2,$2,1 lw $4,48($fp) move $5,$2 lw $6,56($fp) lw $2,%got(_Z3MinPiii)($28) nop move $25,$2 jalr $25 nop lw $28,16($fp) sw $2,24($fp) lw $3,28($fp) lw $2,24($fp) nop slt $2,$2,$3 beq $2,$0,$L4 nop lw $2,24($fp) b $L3 nop $L4: lw $2,28($fp) $L3: move $sp,$fp lw $31,44($sp) lw $fp,40($sp) addiu $sp,$sp,48 j $31 nop .set macro .set reorder .end _Z3MinPiii $LFE0: .size _Z3MinPiii, .-_Z3MinPiii .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"
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.