In: Computer Science
Below code is tested on MIPS64 gcc 5.4 version . Please run below given code on this compiler and if not then make necessary changes to run on your platform. Thanks
.LC0:
.word 20
.word 3
.word 5
.word 4
.word 2
main:
daddiu $sp,$sp,-64
sd $31,56($sp)
sd $fp,48($sp)
sd $28,40($sp)
move $fp,$sp
lui $28,%hi(%neg(%gp_rel(main)))
daddu $28,$28,$25
daddiu $28,$28,%lo(%neg(%gp_rel(main)))
ld $2,%got_page(.LC0)($28)
daddiu $3,$2,%got_ofst(.LC0)
ldl $4,%got_ofst(.LC0)($2)
ldr $4,7($3)
daddiu $3,$2,%got_ofst(.LC0)
ldl $5,8($3)
ldr $5,15($3)
move $3,$5
sd $4,8($fp)
sd $3,16($fp)
daddiu $2,$2,%got_ofst(.LC0)
lw $2,16($2)
sw $2,24($fp)
sw $0,0($fp)
sw $0,4($fp)
.L3:
lw $2,4($fp)
slt $2,$2,5
beq $2,$0,.L2
nop
lw $2,4($fp)
dsll $2,$2,2
daddu $2,$fp,$2
lw $2,8($2)
lw $3,0($fp)
addu $2,$3,$2
sw $2,0($fp)
lw $2,4($fp)
addiu $2,$2,1
sw $2,4($fp)
b .L3
nop
.L2:
lw $5,0($fp)
move $4,$5
move $3,$4
dsll $2,$3,1
move $3,$2
dsll $2,$3,2
dsubu $2,$2,$3
dsll $3,$2,4
daddu $2,$2,$3
dsll $3,$2,8
daddu $2,$2,$3
dsll $3,$2,16
daddu $2,$2,$3
daddu $2,$2,$4
dsrl $2,$2,32
sll $2,$2,0
sra $3,$2,1
sra $2,$5,31
subu $2,$3,$2
sw $2,0($fp)
lw $2,0($fp)
move $5,$2
ld $2,%got_page(.LC1)($28)
daddiu $4,$2,%got_ofst(.LC1)
ld $2,%call16(printf)($28)
move $25,$2
1: jalr $25
nop
move $2,$0
move $sp,$fp
ld $31,56($sp)
ld $fp,48($sp)
ld $28,40($sp)
daddiu $sp,$sp,64
j $31
nop