In: Computer Science
Write a MIPS function using a MARS 4.5 complier named void makeRandomArray(int arr[], int size) that generates and stores a specified number of random numbers each of whose values are between 0 and 1000 in an array
Here i am providing the answer. Hope it helps.
.LC0:
.ascii "Enter the number of integers : \000"
.LC1:
.ascii "%d\000"
.LC2:
.ascii "\012The array numbers are : \000"
.LC3:
.ascii "%d \000"
main:
daddiu $sp,$sp,-144
sd $31,136($sp)
sd $fp,128($sp)
sd $28,120($sp)
sd $23,112($sp)
sd $22,104($sp)
sd $21,96($sp)
sd $20,88($sp)
sd $19,80($sp)
sd $18,72($sp)
sd $17,64($sp)
sd $16,56($sp)
move $fp,$sp
lui $28,%hi(%neg(%gp_rel(main)))
daddu $28,$28,$25
daddiu $28,$28,%lo(%neg(%gp_rel(main)))
move $2,$sp
sd $2,32($fp)
move $4,$0
ld $2,%call16(time)($28)
move $25,$2
nop
sll $2,$2,0
move $4,$2
ld $2,%call16(srand)($28)
move $25,$2
nop
ld $2,%got_page(.LC0)($28)
daddiu $4,$2,%got_ofst(.LC0)
ld $2,%call16(printf)($28)
move $25,$2
nop
daddiu $2,$fp,24
move $5,$2
ld $2,%got_page(.LC1)($28)
daddiu $4,$2,%got_ofst(.LC1)
ld $2,%call16(__isoc99_scanf)($28)
move $25,$2
nop
lw $2,24($fp)
move $3,$2
daddiu $3,$3,-1
sd $3,8($fp)
move $3,$2
move $23,$3
move $22,$0
dsrl $3,$23,59
dsll $18,$22,5
or $18,$3,$18
dsll $19,$23,5
move $3,$2
move $21,$3
move $20,$0
dsrl $3,$21,59
dsll $16,$20,5
or $16,$3,$16
dsll $17,$21,5
dsll $2,$2,2
daddiu $2,$2,3
daddiu $2,$2,15
dsrl $2,$2,4
dsll $2,$2,4
dsubu $sp,$sp,$2
move $2,$sp
daddiu $2,$2,3
dsrl $2,$2,2
dsll $2,$2,2
sd $2,16($fp)
sw $0,0($fp)
b .L2
nop
.L3:
ld $2,%call16(rand)($28)
move $25,$2
nop
li $3,1098383360 # 0x41780000
ori $3,$3,0x749f
mult $2,$3
mflo $3
mfhi $4
dins $3,$4,32,32
dsrl $3,$3,32
sll $3,$3,0
sra $4,$3,8
sra $3,$2,31
subu $4,$4,$3
li $3,1001 # 0x3e9
mul $3,$4,$3
subu $2,$2,$3
move $3,$2
ld $4,16($fp)
lw $2,0($fp)
dsll $2,$2,2
daddu $2,$4,$2
sw $3,0($2)
lw $2,0($fp)
addiu $2,$2,1
sw $2,0($fp)
.L2:
lw $2,24($fp)
lw $3,0($fp)
slt $2,$3,$2
bne $2,$0,.L3
nop
ld $2,%got_page(.LC2)($28)
daddiu $4,$2,%got_ofst(.LC2)
ld $2,%call16(printf)($28)
move $25,$2
nop
sw $0,0($fp)
b .L4
nop
.L5:
ld $3,16($fp)
lw $2,0($fp)
dsll $2,$2,2
daddu $2,$3,$2
lw $2,0($2)
move $5,$2
ld $2,%got_page(.LC3)($28)
daddiu $4,$2,%got_ofst(.LC3)
ld $2,%call16(printf)($28)
move $25,$2
nop
lw $2,0($fp)
addiu $2,$2,1
sw $2,0($fp)
.L4:
lw $2,24($fp)
lw $3,0($fp)
slt $2,$3,$2
bne $2,$0,.L5
nop
ld $sp,32($fp)
nop
move $sp,$fp
ld $31,136($sp)
ld $fp,128($sp)
ld $28,120($sp)
ld $23,112($sp)
ld $22,104($sp)
ld $21,96($sp)
ld $20,88($sp)
ld $19,80($sp)
ld $18,72($sp)
ld $17,64($sp)
ld $16,56($sp)
daddiu $sp,$sp,144
j $31
nop
IMAGE OF OUTPUT
Thnak you. give me a like. it helPs me a lot.