i made a polling sequence and when i first open the program (on QtSpim) it polls perfectly, when i reinitialize and reload the program a second time it just falls through and doesnt poll at all and have to close and reopen QTSpim for the program to properly poll again. am i reopening the program wrong?
loopst: li $a3, 0xffff0000 # base of memory-mapped IO area
rloop: lw $t2,($a3)
nop
andi $t2, $t2, 1
beqz $t2, rloop
nop
this is my little poll program im trying to run, just to catch a key pressed on the keyboard.
I would guess this is some kind of bug/flaw/feature in QtSpim.
I wrote some code code to clear the input buffer in a loop until it is emptied, and it works way too well. I was going to have a loop that printed and emptied each character in the buffer, then printed a message saying it had done so.
However, this turned out to be overkill: merely doing one single read from the data transfer location is sufficient to cause clearing the input buffer between Reloads, so suggest you add this to the beginning of your code, maybe as the first two lines of
main
.Once that's executed in your simulation, QtSpim seems to reinitialize the input buffer upon Reinitialize and Reload menu command. If you never read from the data transfer MMIO location during the simulation, QtSpim apparently won't clear the input buffer on Reinit & Reload.
I would venture that this issue is avoided in most situations, since all the simulation has to do a read just one character from the input buffer at any point in the simulation.
So what it takes to elicit this annoying behavior is that some characters are entered in the input buffer, but the program/simulation is stopped & restarted before reading even one character (and that the next program is using MMIO keyboard input).