Download MIPSproTM Assembly Language Programmer`s Guide

Transcript
MIPSproTM Assembly Language Programmer’s Guide
int temp;
temp = i - *j;
if (i < *j) temp = -temp;
return atof(temp);
}
.globl
nonleaf
#
1
float
#
2
nonleaf(i, j)
#
3
int i, *j;
#
4
{
.ent
nonleaf 2
nonleaf;
.cpload $25
## Load $gp
subu
$sp, 32
## Create stackframe
sw
$31, 20($sp) ## Save the return
## address
sw
$sp, 24($sp) ## Save gp
.mask
0x80000000, -4
.frame
$sp, 32, $31
# 5
double atof();
# 6
int temp;
# 7
# 8
temp = i - *j;
lw
$2, 0($5)
## Arguments are in
## $4 and $5
subu
$3, $4, $2
# 9
if (i < *j) temp = -temp;
bge
$4, $2, $32
## Note: $32 is a label,
## not a reg
negu
$3, $3
$32:
# 10
return atof(temp);
move
$4, $3
jal
atof
cvt.s.
$f0, $f0
## Return value goes in $f0
lw
$gp, 24($sp)
## Restore gp
lw
$31, 20($sp)
## Restore return address
addu
$sp, 32
## Delete stackframe
j
$31
## Return to caller
.end
nonleaf
007–2418–006
97