MIPS assembler language How do represent the following code MIPS instruction Iam
ID: 3826759 • Letter: M
Question
MIPS assembler language
How do represent the following code MIPS instruction Iam trying to create a method that takes in a double and returns the sin of that double but I am having trouble understanding how to work with float and double precesion numbers in MIPS and keep getting weird numbers
double sin( double x )
{
double sum = 0.0
double term = x
double n = 1.0
while (|term| >= 10^-15)
sum = sum + term
n = n + 1.0
term = - term * x / n
n = n + 1.0
term = term * x / n
return sum
}
Explanation / Answer
$LFB0 = . .set nomips16 .ent sin .type sin, @function sin: .frame $fp,40,$31 # vars= 24, regs= 1/0, args= 0, gp= 8 .mask 0x40000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro addiu $sp,$sp,-40 $LCFI0: sw $fp,36($sp) $LCFI1: move $fp,$sp movz $31,$31,$0 $LCFI2: .cprestore 0 swc1 $f12,44($fp) swc1 $f13,40($fp) sw $0,28($fp) sw $0,24($fp) lwc1 $f0,44($fp) nop lwc1 $f1,40($fp) nop swc1 $f0,20($fp) swc1 $f1,16($fp) lw $4,%got($LC0)($28) nop lwc1 $f0,%lo($LC0+4)($4) nop lwc1 $f1,%lo($LC0)($4) nop swc1 $f0,12($fp) swc1 $f1,8($fp) $L2: lwc1 $f2,28($fp) nop lwc1 $f3,24($fp) lwc1 $f0,20($fp) nop lwc1 $f1,16($fp) nop add.d $f0,$f2,$f0 swc1 $f0,28($fp) swc1 $f1,24($fp) lwc1 $f2,12($fp) nop lwc1 $f3,8($fp) lw $4,%got($LC0)($28) nop lwc1 $f0,%lo($LC0+4)($4) nop lwc1 $f1,%lo($LC0)($4) nop add.d $f0,$f2,$f0 swc1 $f0,12($fp) swc1 $f1,8($fp) lw $5,16($fp) li $4,-2147483648 # 0xffffffff80000000 xor $2,$5,$4 lw $3,20($fp) lwc1 $f0,44($fp) nop lwc1 $f1,40($fp) mtc1 $3,$f4 nop mtc1 $2,$f5 nop mul.d $f2,$f4,$f0 lwc1 $f0,12($fp) nop lwc1 $f1,8($fp) nop div.d $f0,$f2,$f0 swc1 $f0,20($fp) swc1 $f1,16($fp) lwc1 $f2,12($fp) nop lwc1 $f3,8($fp) lw $4,%got($LC0)($28) nop lwc1 $f0,%lo($LC0+4)($4) nop lwc1 $f1,%lo($LC0)($4) nop add.d $f0,$f2,$f0 swc1 $f0,12($fp) swc1 $f1,8($fp) lwc1 $f2,20($fp) nop lwc1 $f3,16($fp) lwc1 $f0,44($fp) nop lwc1 $f1,40($fp) nop mul.d $f2,$f2,$f0 lwc1 $f0,12($fp) nop lwc1 $f1,8($fp) nop div.d $f0,$f2,$f0 swc1 $f0,20($fp) swc1 $f1,16($fp) b $L2 nop .set macro .set reorder .end sin $LFE0: .size sin, .-sin .rdata .align 3
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.