Created
March 8, 2022 07:57
-
-
Save aflaag/0980eaa28786e04991f7a6a88e8a822b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.globl main | |
.data | |
DNA1: | |
.asciiz "GAGCCTACTAACGGGAT" | |
DNA2: | |
.asciiz "CATCGTAATGACGGCCT" | |
.text | |
main: | |
li $v0, 11 # print char | |
move $s0, $zero # set s0 = 0, the char counter | |
move $s1, $zero # set s1 = 0, the diff char counter | |
la $a1, DNA1 # load DNA1 in a1 | |
la $a2, DNA2 # load DNA2 in a2 | |
li $t0, 1 # load any non-zero number in t0 | |
jal loop_string | |
loop_string: | |
add $t0, $a1, $s0 # address of byte to examine next (first char + char counter) | |
add $t2, $a2, $s0 | |
lb $t1, 0($t0) # load *(first char + char counter) in t1 | |
lb $t3, 0($t2) | |
beq $t1, $zero, exit # exit if null character is met | |
bne $t1, $t3, increment # increment diff char counter if the chars are different | |
addi $s0, $s0, 1 # increment char counter by 1 | |
j loop_string | |
increment: | |
addi $s1, $s1, 1 # inrement diff char counter by 1 | |
addi $s0, $s0, 1 # increment char counter by 1 | |
jal loop_string | |
exit: | |
move $a0, $s1 # print the diff curr counter | |
li $v0, 1 # print int | |
syscall | |
li $v0, 10 # exit | |
syscall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment