assembly - Stack allocations with a negative offset in a recursive function of more than 4 parameters -
okay, have function takes 5 arguments passed main.
$a0-$a3 , $t0
# prologue: set stack , frame poiters search addiu $sp, $sp, -28 # allocate stack space -- 28 needed here sw $fp, 0($sp) # save caller's frame pointer sw $ra, 4($sp) # save return address addi $fp, $sp, 24 # setup search frame pointer # preserve $a register arguments sw $a0, 0($sp) # addr of element in array sw $a1, 4($sp) # searchvalue sw $a2, 8($sp) # indexleft sw $a3, 12($sp) # indexright # 5th argument lw $s5, 44($sp) # level = 28 + 16
i how works. however, main doesn't store $t0 in 16($sp). instead stores $t0 in -4($sp).
what mean? set offset in order load value stored $t0 onto stack $s5 register? i'm leaning towards 24($sp) (28 + (-4)) i'm not sure.
this recursive function, want make sure each register loads proper values every time function calls , allocates 28 bytes stack pointer.
and far actual recursive call, don't understand how use $v0? if explain how used, appreciate it
Comments
Post a Comment