Rag83
Rag83

Reputation: 19

Why my output in mips random numbers in MIPS?

THIS IS MY CODE it's simple but the output print as random! it's suppose to print 21

.data
            age: .word 21

.globl main

main:

.text
li $v0, 1
la $a0, age
syscall

li $v0, 10
syscall

and, this is my output

268500992

-- program is finished running (dropped off bottom) --

Upvotes: 0

Views: 365

Answers (1)

Hamza Hussain
Hamza Hussain

Reputation: 11

To print an integer, you have to make syscall #1 instead of syscall #4. Secondly, your .text is inside the main function, which is not right. Here is the revised code:

    .data
    age: .word  21

    .text
    .globl main

    main:

    li $v0, 1
    lw $a0, age
    syscall

    li $v0, 10
    syscall

Upvotes: 1

Related Questions