Question: .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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!