Question: Writing a Base 6 4 Decoder program using MIPS with the format below: # # base 6 4 decode.s ( incomplete ) # # by
Writing a Base Decoder program using MIPS with the format below:
#
# basedecode.s incomplete
#
# by Deborah Pickett
#
# This MIPS program reads lines of Base encoded text from standard
# input, and outputs the decoded bytes to standard output.
#
# INSERT YOUR CODE AT THE POINT INDICATED BELOW.
#
# Data segment
#
data
# Space to read a line into.
inbuffer: space
# The Base alphabet, in order.
sequence: asciiz "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
#
# Text segment
#
text
# Program entry.
main:
# The first byte we're expecting is byte of a group of
la $t byte
# Read a string from standard input.
loop: li $v
la $a inbuffer
li $a
syscall
# Is this an empty line? Since SPIM can't detect when end of
# file has been reached, we need to use another way to indicate
# the end of the Base data. We'll use a completely
# blank line for this.
lb $t inbuffer
# First character newline means there was no text on this line,
# so end the program.
beq $t alldone
# Walk along the string. Start at the beginning.
la $t inbuffer
# Go back to where we left off last time byte or
jr $t
# Get four characters at a time.
byte: lbu $s$t
add $t $t
beq $s linedone
# Now up to byte
la $t byte
byte: lbu $s$t
add $t $t
beq $s linedone
# Now up to byte
la $t byte
byte: lbu $s$t
add $t $t
beq $s linedone
# Now up to byte
la $t byte
byte: lbu $s$t
add $t $t
beq $s linedone
# Now all bytes in this block are read.
# Four Base characters are now in $s $s $s $s
bytesdone:
#
# DO NOT DELETE THIS LINE.
######
#
# PUT YOUR ANSWER HERE.
# Your answer should not modify $t or $t as they are used by
# the above code.
#
######
# DO NOT DELETE THIS LINE.
#
endgroup:
# Go back to do next bunch of four bytes. We're now expecting
# byte of
la $t byte
j byte
linedone:
# Line is finished; go get another one.
j loop
alldone:
# Exit.
li $v
syscall
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
