Question

In: Computer Science

How to write an assembly program that simply counts how many A’s, C’s, T’s, and G’s...

How to write an assembly program that simply counts how many A’s, C’s, T’s, and G’s the input string contain.

Solutions

Expert Solution

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.


.data
prompt: .asciiz "\nEnter a string: " #prompt for string
input: .space 1000 #string butter of 100 digit
.text
main:


li $v0, 4   
la $a0, prompt #prompt for string
syscall

li $v0, 8   
la $a0, input #ask for input
li $a1, 1000
syscall
move $s0, $a0 #move data to s0

li $t0,0 #count of C
li $t1,0 #count of T
li $t2,0 #count of A
li $t3,0 #count of G

loop: #loop while end of string
lb $a0, 0($s0) #load first character to a0
addi $s0, $s0, 1 #add index by one
beq $a0, $zero, done #else print character
sge $s5,$a0,'a' #check for lower case range
sle $s6,$a0,'z'
and $s5,$s5,$s6
beq $s5,1,lowercaseCount
j calculate
lowercaseCount:
sub $a0,$a0,32

calculate:
beq $a0,'C',cCount
beq $a0,'T',tCount
beq $a0,'A',aCount
beq $a0,'G',gCount
j exitCount
gCount:
add $t3,$t3,1 #c count ++
j exitCount
cCount:
add $t0,$t0,1 #c count ++
j exitCount
aCount:
add $t2,$t2,1 #c count ++
j exitCount
tCount:
add $t1,$t1,1 #c count ++
exitCount:

j loop
done:


li $a0,'C'
move $a1,$t0
jal printCount

li $a0,'T'
move $a1,$t1
jal printCount

li $a0,'A'
move $a1,$t2
jal printCount


li $a0,'G'
move $a1,$t3
jal printCount


li $v0,10
syscall

printCount:
move $v0,$a0 #print character
li $v0,11
syscall
li $a0,':' #print character
li $v0,11
syscall
move $a0,$a1 #print count
li $v0,1
syscall
li $a0,'\n' #print character
li $v0,11
syscall
jr $ra


Related Solutions

Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than...
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than 1000. The program prints the resulting number. You may only use while loops. Use python language
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than...
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than 1000. The program prints the resulting number. You may only use while loops. Use python language
Write an 8088/8086 assembly program that counts the length of a null terminated string that starts...
Write an 8088/8086 assembly program that counts the length of a null terminated string that starts at location STR.Assume string length will not exceed 255 character.Print the result on the screen?
Write an assembly code the counts the number of accuracies of the byte AAh in memory...
Write an assembly code the counts the number of accuracies of the byte AAh in memory from address 120Ah to address 130Ah. You need to use a subroutine and call it 'COUNT' to do so. You also need to provide the count in BCD if it was less than 64h so that you need to include another subroutine called 'ToBCD' to do so. assembly 8086
Write a program that accepts a string and character as input, then counts and displays the...
Write a program that accepts a string and character as input, then counts and displays the number of times that character appears (in upper- or lowercase) in the string. Use C++ Enter a string: mallet Enter a character: a "A" appears 1 time(s) Enter a string: Racecar Enter a character: R "R" appears 2 time(s)
Write a C program that counts the number of repeated characters in a phrase entered by...
Write a C program that counts the number of repeated characters in a phrase entered by the user and prints them. If none of the characters are repeated, then print “No character is repeated” For example: If the phrase is “full proof” then the output will be Number of characters repeated: 3 Characters repeated: f, l, o Note: Assume the length of the string is 10. ###Note: the output should print exactly as it is stated in the example if...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
How many distinct arrangements of the letters in MANANGATANG have no A’s in the first six...
How many distinct arrangements of the letters in MANANGATANG have no A’s in the first six places? NOTE: MANANGATANG has 11 letters, so the last five places must have four A's and one other letter. PLEASE SHOW FULL LEGIBLE WORKING.
Python Program Write a program that will ask a user on how many input colored balls...
Python Program Write a program that will ask a user on how many input colored balls of the following codes: R-red, B-blue, W-white, G-green and O-orange -will he or she would like to enter in the program and print the total number of Red balls were encountered. Assume an uppercase and lower case letter will be accepted.
using Dr java Objective: Write a program that takes a phrase and then counts the number...
using Dr java Objective: Write a program that takes a phrase and then counts the number of vowels (case does not matter) in the phrase. It then should display all of the vowels in sorted ascending order according to their count. Only consider {AEIOU} as the vowels. Hint: It may be a good idea to keep track and sort two arrays: Has the vowels in alphabetic order Has the number of said vowels Whenever one would swap then it swaps...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT