我是汇编语言的新手,我试图让用户输入一个介于 1 和 26 之间的整数以保持简单,然后打印与该整数关联的 ASCII 字符。但是,当它打印出整数时,它会打印一些看起来很奇怪的符号而不是字母、字符等。这是我的代码:
.data
prompt1: .asciiz "Enter the value of n here: "
prompt2: .asciiz "The letter is: "
outside: .asciiz "?"
.globl main
.text
main:
li $t1, 1 #register to check for 1
li $t2, 27 #register for no numbers over 26
li $v0, 4 #prompt user for integer
la $a0, prompt1
syscall
li $v0, 5 #store the integer the user inputed
syscall
add $t0, $0, $v0 #store that number in register
blt $t0, $t1, outOfBounds #if less than 1, print a ?
blt $t0, $t2, print #if okay, go to print the ascii character
j outOfBounds
print:
li $v0, 11
move $a0, $t0
syscall
j Exit
outOfBounds:
li $v0, 4
la $a0, outside
syscall
j Exit
Exit:
li $v0, 10
syscall