Write assembly language programs to solve the following problems. Run each program within DEBUG to make sure that the code works.

computer science

Description

Write assembly language programs to solve the following problems. Run each program within DEBUG to make sure that the code works.


 

Write a separate program for each problem, and remember to use TEMPLATE.ASM as a template. 


Before writing any code, develop an algorithm using either pseudocode or a flowchart. Even though these questions are short, you still should use this practice. 


1. Define variable VAR in the data segment to be 6 bytes long with random numbers in each byte (just put any numbers in the variable spaces). Define a one-byte variable ANSWER that is initially zero. Add VAR[0] through VAR[5] (6 bytes in total) and place the sum in ANSWER. Use a looping technique and any addressing mode that you find acceptable. 


2. Change question one so as to keep track of each time the carry bit is set in a new variable called ANSWER1. Note: the word size sum of all the bytes is: ANSWER1 for the high byte, ANSWER for the low byte. Save the Q2 source file as Q:/CISDATA/COMP256AB1/Your Name/assignment2/Q2.s


3. Write a program that reads 20 bytes of character data that are stored at location STRING1 (store a string at this location that includes upper case, lower case and other ASCII characters). The program is to count the number of lower case characters and store the result in location LOWER, and count the number of upper case characters and store this total in location UPPER. 


4. Change question three so as to keep reading any number of data bytes until the value 0FF16 is encountered. Make sure that the last byte stored at location STRING1 has the value 0FF16. Save the Q4 source file as Q:/CISDATA/COMP256AB1/Your Name/assignment2/Q4.s


Related Questions in computer science category