Reading keyboard input ASM

0

I want to take the input from the MARS Keyboard simulator. When the user doesn't enter a character I want to print out "Please, enter a character...".

If he does enter a character, I want to output that character once.

This is my code:

#MIPS
#ND
#2 a

.data
    text:   .asciiz "Please enter a character...\n"
.text

j print
main:
        lw $t0, 0xffff0000  #t1 holds if input available

    li $a0, 2000    #Time to sleep (milliseconds)

    li $v0, 32  #Operation code for sleeping
    syscall

    beq $t0, 0, print   #If no input is typed in, goto print (else printIn)


printIn:        #Printing input
    li $v0, 4
    lw $a0, 0xffff0004
    syscall

    j main

print:      #Printing text asking for input
    la $a0, text
    li $v0, 4
    syscall

    j main

My code is working, until I enter a character in the keyboard simulator, than I get this error at runtime:

line 24: Runtime exception at 0x0040002c: address out of range 0x00000065

I really searched but really can't see what's wrong with my code... It's MIPS ASM by the way, and this information can be helpful as well: mips keyboard

assembly
mips
mars-simulator
asked on Stack Overflow Dec 1, 2017 by O'Niel

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0