Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im using QT Spim to run a MIPS Program that does the following prompts the user to enter ten floating-point, real, or decimal numbers then

Im using QT Spim to run a MIPS Program that does the following prompts the user to enter ten floating-point, real, or decimal numbers then the program stores the numbers in an array. Each number is entered on a separate line. The program then computes and displays the sum and average each on a separate line.

When I complie the code it gives me the sytax error below ??

spim: (parser) syntax error on line 2 of file /Users/TheKid/Documents/WilliamsMylanProject1.s .section .mdebug.abi32 ^

.file 1 ""

.section .mdebug.abi32

.previous

.nan legacy

.module fp=32

.module nooddspreg

.abicalls

.globl arr

.section .bss,"aw",@nobits

.align 2

.type arr, @object

.size arr, 40

arr:

.space 40

.rdata

.align 2

$LC0:

.ascii "Enter 10 elements in the array : \000"

.align 2

$LC1:

.ascii "%f\000"

.text

.align 2

.globl createArray

.set nomips16

.set nomicromips

.ent createArray

.type createArray, @function

createArray:

.frame $fp,40,$31 # vars= 8, regs= 2/0, args= 16, gp= 8

.mask 0xc0000000,-4

.fmask 0x00000000,0

.set noreorder

.cpload $25

.set nomacro

addiu $sp,$sp,-40

sw $31,36($sp)

sw $fp,32($sp)

move $fp,$sp

.cprestore 16

movz $31,$31,$0

sw $4,40($fp)

lw $2,%got($LC0)($28)

nop

addiu $4,$2,%lo($LC0)

lw $2,%call16(printf)($28)

nop

move $25,$2

.reloc 1f,R_MIPS_JALR,printf

1: jalr $25

nop

lw $28,16($fp)

sw $0,24($fp)

b $L2

nop

$L3:

lw $2,24($fp)

nop

sll $2,$2,2

lw $3,40($fp)

nop

addu $2,$3,$2

move $5,$2

lw $2,%got($LC1)($28)

nop

addiu $4,$2,%lo($LC1)

lw $2,%call16(__isoc99_scanf)($28)

nop

move $25,$2

.reloc 1f,R_MIPS_JALR,__isoc99_scanf

1: jalr $25

nop

lw $28,16($fp)

lw $2,24($fp)

nop

addiu $2,$2,1

sw $2,24($fp)

$L2:

lw $2,24($fp)

nop

slt $2,$2,10

bne $2,$0,$L3

nop

nop

move $sp,$fp

lw $31,36($sp)

lw $fp,32($sp)

addiu $sp,$sp,40

j $31

nop

.set macro

.set reorder

.end createArray

.size createArray, .-createArray

.align 2

.globl sumArray

.set nomips16

.set nomicromips

.ent sumArray

.type sumArray, @function

sumArray:

.frame $fp,24,$31 # vars= 8, regs= 1/0, args= 0, gp= 8

.mask 0x40000000,-4

.fmask 0x00000000,0

.set noreorder

.set nomacro

addiu $sp,$sp,-24

sw $fp,20($sp)

move $fp,$sp

sw $4,24($fp)

sw $0,12($fp)

movz $31,$31,$0

sw $0,8($fp)

b $L5

nop

$L6:

lw $2,8($fp)

nop

sll $2,$2,2

lw $3,24($fp)

nop

addu $2,$3,$2

lwc1 $f0,0($2)

lwc1 $f2,12($fp)

nop

add.s $f0,$f2,$f0

swc1 $f0,12($fp)

lw $2,8($fp)

nop

addiu $2,$2,1

sw $2,8($fp)

$L5:

lw $2,8($fp)

nop

slt $2,$2,10

bne $2,$0,$L6

nop

lwc1 $f0,12($fp)

move $sp,$fp

lw $fp,20($sp)

addiu $sp,$sp,24

j $31

nop

.set macro

.set reorder

.end sumArray

.size sumArray, .-sumArray

.align 2

.globl averageArray

.set nomips16

.set nomicromips

.ent averageArray

.type averageArray, @function

averageArray:

.frame $fp,24,$31 # vars= 8, regs= 1/0, args= 0, gp= 8

.mask 0x40000000,-4

.fmask 0x00000000,0

.set noreorder

.cpload $25

.set nomacro

addiu $sp,$sp,-24

sw $fp,20($sp)

move $fp,$sp

.cprestore 0

swc1 $f12,24($fp)

movz $31,$31,$0

lwc1 $f2,24($fp)

lw $2,%got($LC2)($28)

nop

lwc1 $f0,%lo($LC2)($2)

nop

div.s $f0,$f2,$f0

swc1 $f0,8($fp)

lwc1 $f0,8($fp)

move $sp,$fp

lw $fp,20($sp)

addiu $sp,$sp,24

j $31

nop

.set macro

.set reorder

.end averageArray

.size averageArray, .-averageArray

.rdata

.align 2

$LC3:

.ascii "Sum = %f\012Average = %f\000"

.text

.align 2

.globl main

.set nomips16

.set nomicromips

.ent main

.type main, @function

main:

.frame $fp,48,$31 # vars= 8, regs= 2/0, args= 24, gp= 8

.mask 0xc0000000,-4

.fmask 0x00000000,0

.set noreorder

.cpload $25

.set nomacro

addiu $sp,$sp,-48

sw $31,44($sp)

sw $fp,40($sp)

move $fp,$sp

.cprestore 24

movz $31,$31,$0

lw $4,%got(arr)($28)

lw $2,%got(createArray)($28)

nop

move $25,$2

.reloc 1f,R_MIPS_JALR,createArray

1: jalr $25

nop

lw $28,24($fp)

nop

lw $4,%got(arr)($28)

lw $2,%got(sumArray)($28)

nop

move $25,$2

.reloc 1f,R_MIPS_JALR,sumArray

1: jalr $25

nop

lw $28,24($fp)

swc1 $f0,32($fp)

lwc1 $f12,32($fp)

lw $2,%got(averageArray)($28)

nop

move $25,$2

.reloc 1f,R_MIPS_JALR,averageArray

1: jalr $25

nop

lw $28,24($fp)

swc1 $f0,36($fp)

lwc1 $f0,32($fp)

nop

cvt.d.s $f2,$f0

lwc1 $f0,36($fp)

nop

cvt.d.s $f0,$f0

swc1 $f0,20($sp)

swc1 $f1,16($sp)

mfc1 $7,$f2

mfc1 $6,$f3

lw $2,%got($LC3)($28)

nop

addiu $4,$2,%lo($LC3)

lw $2,%call16(printf)($28)

nop

move $25,$2

.reloc 1f,R_MIPS_JALR,printf

1: jalr $25

nop

lw $28,24($fp)

move $2,$0

move $sp,$fp

lw $31,44($sp)

lw $fp,40($sp)

addiu $sp,$sp,48

j $31

nop

.set macro

.set reorder

.end main

.size main, .-main

.rdata

.align 2

$LC2:

.word 1092616192

.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions