Skip to content

Commit

Permalink
Nucleotide Count: output counts as list
Browse files Browse the repository at this point in the history
  • Loading branch information
keiravillekode committed Oct 13, 2023
1 parent 6c57a00 commit 8b41e17
Showing 1 changed file with 38 additions and 20 deletions.
58 changes: 38 additions & 20 deletions exercises/practice/nucleotide-count/runner.mips
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ expectedmsg: .asciiz ". expected "
tobemsg: .asciiz " to be "
okmsg: .asciiz "all tests passed"

listprefix: "["
listseparator: ", "
listsuffix: "]"

.text

Expand Down Expand Up @@ -109,51 +112,66 @@ exit_fail:
li $v0, 4
syscall

lw $a0, 0($s5) # print actual A that failed on
li $v0, 1
move $a0, $s5 # address of actual counts
jal print_list

la $a0, tobemsg
li $v0, 4
syscall

lw $a0, 4($s5) # print actual C that failed on
li $v0, 1
move $a0, $s2 # address of expected counts
jal print_list

li $a0, 1 # set error code to 1
li $v0, 17 # 17 is exit with error
syscall

lw $a0, 8($s5) # print actual G that failed on
li $v0, 1
clear_output:
sw $zero, 0($s5) # zero out output by storing 4 words (16 bytes) of zeros
sw $zero, 4($s5)
sw $zero, 8($s5)
sw $zero, 12($s5)
jr $ra

print_list:
move $t2, $a0

la $a0, listprefix
li $v0, 4
syscall

lw $a0, 12($s5) # print actual T that failed on
lw $a0, 0($t2) # A count
li $v0, 1
syscall

la $a0, tobemsg
la $a0, listseparator
li $v0, 4
syscall

lw $a0, 0($s2) # print expected A that failed on
lw $a0, 4($t2) # C count
li $v0, 1
syscall

lw $a0, 4($s2) # print expected C that failed on
li $v0, 1
la $a0, listseparator
li $v0, 4
syscall

lw $a0, 8($s2) # print expected G that failed on
lw $a0, 8($t2) # G count
li $v0, 1
syscall

lw $a0, 12($s2) # print expected T that failed on
la $a0, listseparator
li $v0, 4
syscall

lw $a0, 12($t2) # T count
li $v0, 1
syscall

li $a0, 1 # set error code to 1
li $v0, 17 # 17 is exit with error
la $a0, listsuffix
li $v0, 4
syscall

clear_output:
sw $zero, 0($s5) # zero out output by storing 4 words (16 bytes) of zeros
sw $zero, 4($s5)
sw $zero, 8($s5)
sw $zero, 12($s5)
jr $ra

# # Include your implementation here if you wish to run this from the MARS GUI.
Expand Down

0 comments on commit 8b41e17

Please sign in to comment.