Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

.data .space 40 # set aside 40 bytes for 10 integers prompt: .asciiz Enter a number # address 0x10010028 comma: .asciiz , #

.data

.space 40 # set aside 40 bytes for 10 integers

prompt: .asciiz "Enter a number " # address 0x10010028

comma: .asciiz ", " # address 0x10010038

.globl main

.text

main:

lui $a0, 0x1001 # get start of data segment

jal getdata # call getdata function

lui $a0, 0x1001 # get start of data segment

jal print # call print function

ori $v0, $0, 10 # set command to exit

syscall # end program

# printstr

# paramters: $a0 holds address of string to print

# purpose: print the string parameter

printstr:

la $a0, prompt # address of prompt goes in

li $v0, 4 # service code for print string

syscall

jr $ra #return from call by putting value to ra

jr $ra

getdata:

addi $sp, $sp, -4 # allocate space on stack

sw $ra, 0($sp) # save $ra

ori $t1, $a0, 0 # address of array

lui $t1, 0x1001 #start of data

ori $a0, $a0, 0x0028 # address of prompt

ori $t0, $0, 10 # counter

top: beq $t0, $0, ret # while not 0

jal printstr # call function to print prompt

ori $v0, $0, 5 # set command to read integer

syscall # read int

sw $v0, 0($t1) # save int in memory

addi $t1, $t1, 4 # increment to next location

addi $t0, $t0, -1 # decrement counter

j top # repeat

ret: lw $ra, 0($sp) # restore return address

addi $sp, $sp, 4 # clean up stack

jr $ra # return from call

# print

# parameter: $a0 holds address of list in memory

# purpose: print the list separated by commas

print:

addi $t2, $t2, 10

addi $t0, $t0,1 #increment by 1 before entering into loop

ori $v0, $0, 4 #print 1st value ,as loop start from 2nd value

syscall

jal loop #jump to loop

loop: beq $t0, $t2, end

lui $t3, 0x1001

or $a0, $0, $t3

ori $v0, $0, 1

syscall

addi $t3, $t3, 4

ori $a0, $a0, 0x0038

ori $v0, $0, 4 #command to print string at $a0

syscall

addi $t0, $t0, 1

j top

jr $ra

Please help me I am writing this code and i need the correct code for print. On the line with beq it says that the word end is not found in the table. Please help me ASAP

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

LO1 Discuss four different views of motivation at work.

Answered: 1 week ago

Question

LO6 Summarize various ways to manage retention.

Answered: 1 week ago

Question

LO3 Define the difference between job satisfaction and engagement.

Answered: 1 week ago