Question

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

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

Homework Answers

Answer #1

; Initialization

; .ORIG x3000

AND R2, R2, #0 ; R2 is counter, initially 0

LD R3, PTR ; R3 is pointer to characters

GETC ; R0 gets character input

LDR R1, R3, #0 ; R1 gets first character

; Test character for end of file

; TEST ADD R4, R1, #-4 ; Test for EOT (ASCII x04)

BRz OUTPUT ; If done, prepare the output

; Test character for match. If a match, increment count.

NOT R1, R1

ADD R1, R1, R0 ; If match, R1 = xFFFF

NOT R1, R1 ; If match, R1 = x0000

BRnp GETCHAR ; If no match, do not increment

ADD R2, R2, #1

; Get next character from file.

GETCHAR ADD R3, R3, #1 ; Point to next character.

LDR R1, R3, #0 ; R1 gets next char to test

BRnzp TEST

;Output the count

OUTPUT LD R0, ASCII ; Load the ASCII template

ADD R0, R0, R2 ; Covert binary count to ASCII

OUT ; ASCII code in R0 is displayed

HALT ; Halt machine

; Storage for pointer and ASCII template

ASCII .FILL x0030

PTR .FILL x4000

.END

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write an assembly program that reads characters from standard input until the “end of file” is...
Write an assembly program that reads characters from standard input until the “end of file” is reached. The input provided to the program contains A, C, T, and G characters. The file also may have new line characters (ASCII code 10 decimal), which should be skipped/ignored. The program then must print the count for each character. You can assume (in this whole assignment) that the input doe not contain any other kinds of characters.  the X86 assembly program that simply counts...
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. Print the result on the screen.
Write a program in assembly language for x86 Processors, that uses a loop to calculate the...
Write a program in assembly language for x86 Processors, that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n -1) + Fib(n - 2)
Convert this C++ program exactly as you see it into x86 assembly language: // Use the...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the Irvine library for the print function #include <iostream> // The string that needs to be printed char word[] = "Golf\0"; // Pointer to a specific character in the string char * character = word; //NOTE: This main() function is not portable outside of Visual Studio void main() { // Set up a LOOP - See the while loop's conditional expression below int ecx =...
In Assembly x86 please Write an assembly program(call it lab6_file1.asm)that contains 10 double words in memory...
In Assembly x86 please Write an assembly program(call it lab6_file1.asm)that contains 10 double words in memory in the .data section where the first five initialized to 0 and the last five are initialized to 1. In addition, reserve ten uninitialized double words in .bss section. Using a loop, write an assembly program that copies the ten initialized values into the ten reserved double words, starting at the last position, moving to the first(reverse order the data in your uninitialized array)....
Assembly using "Atmel" : 1- Write a program that counts from 0 to 255 and show...
Assembly using "Atmel" : 1- Write a program that counts from 0 to 255 and show the result on PORTD (shown on 8 LEDs). 2- Write a program that adds two numbers and show their sum on PORTD.
Write a C program. Many user-created passwords are simple and easy to guess. Write a program...
Write a C program. Many user-created passwords are simple and easy to guess. Write a program that takes a simple password and makes it stronger by replacing characters using the key below, and by appending "q*s" to the end of the input string. You may assume that the string does not contain spaces and will always contain less than 50 characters. i becomes ! a becomes @ m becomes M B becomes 8 o becomes . Ex: If the input...
In x86-64 Windows Assembly Language. Program that adds two unsigned integer values and produces formatted console...
In x86-64 Windows Assembly Language. Program that adds two unsigned integer values and produces formatted console output using the 'C' library function printf(). The two unsigned integer values are input by the user from the keyboard at runtime using the 'C' library function scanf().
Write an ARM assembly language program that counts the number of 1’s for any value in...
Write an ARM assembly language program that counts the number of 1’s for any value in R0. The program must assemble/compile in KEIL and must be able to run in the KEIL simulator. Generally, R0 may contain any value, but for purpose of this exercise, you may move 0x2345ABCD into R0. The number in R0 does not need be preserved. You may use any other registers as you need. The result, total count of 1’s in R0, should be in...
Using Kip irvine32 X86 assembly language using Visual Studios. Please use CORRECT SYNTAX and actually run...
Using Kip irvine32 X86 assembly language using Visual Studios. Please use CORRECT SYNTAX and actually run on Visual Studio as asm file before posting. I keep getting answers that simply solve the problem without writing an actual program that runs on visual studio. Write a program that evaluates the following arithmetic expression: ((A+B)/C) * ((D-A)+E) Assign test values to the variables and display the resulting value.