好吧,所以我使用预制的PRNG(LFSR_Random)并调用它来获取一个随机数,然后我尝试将这个数字放入一个寄存器中,这样我就可以将它与我的猜测进行比较并得到响应。
我在使用JAL调用此生成器并将其发送到我想要存储的位置时遇到了重大问题,我认为我在这里有正确的逻辑,但是我甚至没有回复字符串只是要求("输入数字:"),所以寄存器中的值完全关闭或无法正确比较。
如果需要,我可以上传利用PRNG作为参考的整套其他功能(?)。 请问。
.data
start: .asciiz "Guess Game(1-100)"
entnum: .asciiz "\n Enter number: "
toolow: .asciiz "\n Too Low"
toohigh: .asciiz "\n Too High"
correct: .asciiz "\n Correct"
.text
.globl main
main:
li $v0, 4
la $a0, start #prints out the start string
syscall
li $v0, 0 #initiliaze register $v0
move $s1, $v0 #move the random number into $s0
jal LFSR_Random #call the random number generator
#LSFR_Random returns an upper
#32-bit unsigned number
#in $v0
#and a lower 32-bit number in $v1
move $s2, $s1 #moves rn into s2
remu $t0, $s2, 100 #divides so i can get it between 1-99
addi $t0, $10, 1 #now between 1-100
loop1:
li $v0, 4
la $a0, entnum #print query
syscall
li $v0, 5 #enter query
syscall
blt $v0, $t0, toolowc #calls if the guess is too low
bgt $v0, $t0, toohighc #calls if the guess is too high
beq $v0, $t0, correctc #calls if the guess is correct
#ending the loop and program.
toolowc:
la $a0, toolow #called from blt, prints response
syscall
j loop1 #resets to the loop
toohighc:
la $a0, toohigh #called from bgt, prints response
syscall
j loop1 #resets to the loop
correctc:
la $a0, correct #called from beq, prints response
syscall
j endcall #calls the ending call, ending the program
endcall:
li $v0, 10
syscall
########################