.data
messageSize:
.word 20
.align 2
message: .asciiz "Four score and seven"
pattern: .word 0x57243C7A
# Your code goes below this line
.data
numCodeWords:
.word 5
codeWords:
.word 626086716
.word 944197466
.word 906254600
.word 604264468
.word 960580127
.text
# prologue
subu $sp, $sp, 24
sw $fp, 0($sp)
sw $ra, 4($sp)
addiu $fp, $sp, 24
# load a counter (0-3) into register $s7
li $s7, 0
# load another counter (0-20) into register $s6
li $s6, 0
# load message into register $s0
la $s0, message
# load messageSize into register $s1
la $t0, messageSize
lw $s1, 0($t0)
# load pattern into register $s2
la $t0, pattern
lw $s2, 0($t0)
# load numCodeWords into register $s5
la $t0, numCodeWords
lw $s5, 0($t0)
# first loop : loops through the entire message using messageSize
# and the 0-20 counter
loopBegin:
beq $s1, $s6, loopingEnd
# load the first four bytes of $s0 into $t3
lw $t3, 0($s0)
# xor these bytes and put the result into $t2
xor $t2, $t3, $s2
# store the value into $s0 again
sw $t2, 0($s0)
# increment the counter by 4
addi $s6, 4
# move the address over by 4 bytes
addi $s0, 4
# jump back to the beginning
j loopBegin
loopingEnd: