Note that there are some explanatory texts on larger screens.

plurals
  1. POMIPS randomized word scrambler
    primarykey
    data
    text
    <p>I am trying to write code that uses the MARS (my MIPS simulator) pseudorandom number generator to pick a random char in the string, take it out of memory and into a register, and replace that char in memory with an asterisk, '*'.</p> <p>So far, it only scrambles part of the word, and it's driving me insane. I can't find what in this code isn't working. I don't even need a direct answer, just hints/tips would be SO helpful. </p> <p>Here is the code:</p> <pre><code>#this loop extracts a char at random from a string in memory, stores it in a register, and replaces the char in the string with an asterisk '*' .data .align 2 string0: .ascii "Tyler\n" .align 2 endString: .asciiz "Loop completed!\n" .align 2 scrambleString: .asciiz .text #counter li $t0, 5 #pointer to string0 la $s0, string0 loop2: #is counter = 0? go to loop3 if so beq $t0, $0, loop3 #seed &amp; prepare randomized number generator li $v0, 30 syscall li $v0, 40 #sets seed syscall #generates random number in $a0, with the coUnter $t0 being the upper bound addi $a1, $t0, 1 li $v0, 42 syscall #add STRING POINTER by random number in $a0, store this new address in $t1 #addi $a0, $a0, 1 add $t1, $s0, $a0 #srlv $t1, $s0, $a0 #isolates that bytesized char, puts it into $t2 lbu $t2, ($t1) #beq $t2, 0x5c, loop2 #replaces char in original string with "*" li $t3, 0x2a sb $t3, ($t1) beq $t1, $t3, loop2 #decrement counter addi $t0, $t0, -1 #loop return j loop2 loop3: la $a0, string0 li $v0, 4 syscall li $v0, 10 syscall </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload