#data declarations: numbers: .space 36 message1: .asciiz \"Enter an integer: \ \
ID: 3638356 • Letter: #
Question
#data declarations:
numbers:
.space 36
message1: .asciiz "Enter an integer: "
message2: .asciiz "The array contains the following: "next_line: .asciiz " "
.text
.globl main
main:
la $a1, numbers # $a1 is the base address of the array
li $a2, 9 # $a2 = 9;
jal readArray
jalprintArray
jr $ra
readArray:
li $t0, 0 # i = 0;
loop:
bge $t0, $a2, Exit1 #if (i = 9)Exit the loop
la $a0, message1
li $v0, 4syscall
li $v0, 5
syscall
sw $v0, ($a1)
addi $a1, $a1, 4# move the array over by 1 element
addi $t0, $t0, 1 #i++
j loop
printArray:
la $a1,numbers
li $t0, 0 #1 = 0;
la $a0, message2
li $v0, 4
syscall
loop1:
bge $t0, $a2, Exit1 #if (i = 9) Exit the loop
li $v0, 1
lw $a0, 0($a1)
syscall
la $a0, next_line
li $v0, 4
syscall
addi $a1, $a1, 4
addi $t0, $t0, 1
j loop1
Exit1:
jr $ra
My code isn't printing the array, i got an error at line 27, where it's not reading i=0 "27: li $t0, 0 # i = 0"
Can anyone help?
Explanation / Answer
#include typedef union { int i; float f; } U; int main(void) { U u; u.f = 10.0; printf("%g = %#x ", u.f, u.i); return 0; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.