assemblymipsqtspim

reading and printing an integer in Qtspim


Before i explain what's going on i'm working with Qtspim.The program is simple: All it does is read an integer (from the user) and output the number that was typed in.This is the code:

###################################################
# text segment                  #
###################################################
 .text
 .globl __start

__start:

    li $v0,4
    la $a0,message
    syscall

    li $v0, 5      #read_int#
    syscall
    move $a0,$v0

    li $v0, 1      #print_int#
    syscall

    li $v0,10
    syscall
###################################################
# data segment                  #
###################################################
.data
message: .asciiz "please enter in a single number:"
###################################################
#                    #
# End of File                   #
#                    #

and this is the output:

please enter in a single number:0

Note:when you type the input, it doesn't print what you typed in.So the 0 is the output of the program


Solution

  • yeah turns out i didn't press enter after my input.....yeeahhhh........