0

I am working on a code for my assembly language class that takes user input and stores it in memory and then prints it out again for the user. I don't know what the problem is but ever time I invoke the system call code to read the users input it always skips the first 2 letters. The following is my code.

.data

myname: .asciiz "Please Type Your Name:"
ram1:   .word 4
ram2:   .word 4
blank:  .asciiz "\n"

.text
.globl main

main:

    li $v0, 4        #loads the system call code to print a string
    la $a0, myname
    syscall

    la $a0, ram1
    li $a1, 20
    li $v0, 8        #this is the opcode that reads a user input in the console
    syscall

    li   $v0, 4      #loads the call code to print a string
    la   $a0, blank
    andi $a1, $a1, 0
    syscall
    syscall
    syscall

    la $a0, myname
    syscall
    la $a0, ram1
    syscall

I understand that the system call code 8 requires 2 arguments to function properly which I added. Any insight would be greatly appreciated!

Cheers

Konrad Lindenbach
  • 4,911
  • 1
  • 26
  • 28
Samuel
  • 5
  • 4
  • Why did you only reserve one word (four bytes) for you buffer? Many people have longer names than that. And why are there three `syscall` instructions in a row at one point in your program? – Michael Mar 05 '16 at 09:54
  • I reserved 8 bytes for my buffer that is why there is ram 1 and ram 2. The three syscall instructions are to print spaces in between the user input and the final output. It's part of the instructions for this assignment. – Samuel Mar 05 '16 at 20:01

0 Answers0