Loops 带预制RNG的MIPS猜谜游戏
好的,我用一个预制的PRNG LFSR_随机数,调用它得到一个随机数,然后我试着把这个数放入寄存器,这样我就可以把它和我的猜测进行比较,并得到响应 我用JAL调用这个生成器并将其存储到我想存储它的位置时遇到了重大问题,我认为我在这里有正确的逻辑,但我一直没有得到响应,甚至没有返回字符串,只是要求输入数字:再次,所以要么寄存器中的值完全关闭,要么比较不正确 如果需要的话,我可以上传使用PRNG作为参考的整个其他功能集。 问问吧Loops 带预制RNG的MIPS猜谜游戏,loops,assembly,mips,Loops,Assembly,Mips,好的,我用一个预制的PRNG LFSR_随机数,调用它得到一个随机数,然后我试着把这个数放入寄存器,这样我就可以把它和我的猜测进行比较,并得到响应 我用JAL调用这个生成器并将其存储到我想存储它的位置时遇到了重大问题,我认为我在这里有正确的逻辑,但我一直没有得到响应,甚至没有返回字符串,只是要求输入数字:再次,所以要么寄存器中的值完全关闭,要么比较不正确 如果需要的话,我可以上传使用PRNG作为参考的整个其他功能集。 问问吧 .data start: .asciiz
.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
########################
你的移动$s1、$v0和日航LFSR_随机顺序错误。你不能移动你还没有调用的函数的结果。我以前做过,它没有太大的变化,我得到的是和现在一样的输出。另外我猜addi$t0,$10,1应该是addi$t0,$t0,1$10是$t2。如果它仍然不起作用,使用调试器/模拟器单步执行你的代码。哦,哇,那是我的一个误算,现在一切都正常了,我真的很感激。