0

我正在为我的汇编语言类编写代码,该代码接受用户输入并将其存储在内存中,然后再次为用户打印出来。我不知道问题是什么,但每当我调用系统调用代码来读取用户输入时,它总是会跳过前 2 个字母。以下是我的代码。

.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

我知道系统调用代码 8 需要我添加的 2 个参数才能正常运行。任何见解将不胜感激!

干杯

4

0 回答 0