.data
numCodeWords:
.word 4
codeWords:
.word 626086716
.word 944197466
.word 906254600
.word 1459902484
pattern:
.word 0x57243C7A
# Your code goes below this line
dataLine: .asciiz ".data/n"
messageSizeLine: .asciiz "messageSize:/n"
messageLine: .asciiz "message:/n"
wordLine: .asciiz " .word "
alignLine: .asciiz " .align 2\n"
asciizLine: .asciiz " .asciiz ""
quoteLine: .asciiz """
newLine: .asciiz "\n"
.text
main:
# prologue
subu $sp, $sp, 24
sw $fp, 0($sp)
sw $ra, 4($sp)
addiu $fp, $sp, 24
# load codeWords into register $s0
la $s0, codeWords
# load numCodeWords into register $s1
la $t0, numCodeWords
lw $s1, 0($t0)
# load pattern into register $s2
la $t0, pattern
lw $s2, 0($t0)
# load counter into register $s7
li $s7, 0
# load a message size counter into $s6
li $s6, 0
loopBegin:
beq $s7, $s1, endLoop
# load first word of codeWords into register $t3
lw $t3, 0($s0)
# xor the word and put the value into $t2
xor $t2, $t3, $s2
# store the value into $s0 again
sw $t2, 0($s0)
# add 4 to get to the next word
addi $s0, 4
# increment the message size counter by 4
addi $s6, 4
# increment the loop counter by 1
addi $s7, 1
# repeat loop
j loopBegin
endLoop:
# print out dataLine
la $a0, dataLine
li $v0, 4
syscall
la $a0, newLine
li $v0, 4
syscall
# print out messageSizeLine
la $a0, messageSizeLine
li $v0, 4
syscall
# print out wordLine followed by the size of the message
la $a0, wordLine
li $v0, 4
syscall
la $a0, 0($s6)
li $v0, 1
syscall
la $a0, newLine
li $v0, 4
syscall
la $a0, newLine
li $v0, 4
syscall
# print out alignLine
la $a0, alignLine
li $v0, 4
syscall
# print out messageLine
la $a0, messageLine
li $v0, 4
syscall
# print out asciizLine and the string, followed by quoteLine
la $a0, asciizLine
li $v0, 4
syscall
la $a0, 0($s0)
li $v0, 4
syscall
la $a0, quoteLine
li $v0, 4
syscall
la $a0, newLine
li $v0, 4
syscall