Question

In: Computer Science

The first program is to count the number of zeros in $3855. Please     add comments...

The first program is to count the number of zeros in $3855. Please

    add comments to each line

         

      org   $1000

array     db $38, $55 ; data to be tested

          

          org $1100

zero_cnt ds.b   1

lp_cnt     ds.b   1

             org   $1500

             clr   zero_cnt       ;initialize the 0 count to 0

             movb #16,lp_cnt     

             ldd   array        

again     lsrd

            bcs   chk_end         ;

            inc   zero_cnt

chk_end   dec   lp_cnt              

            bne   again                  

            swi             

            end

Solutions

Expert Solution

org   $1000 #  set the location counter to $1000

array     db $38, $55 # data to be tested

initializes 2 bytes in memory to 
$38
$55

and the assembler will use array as the symbolic address of the first byte whose initial value is 
$38. The program can also force these 2 bytes to a certain address by adding the org directive. 
For example, the sequence
org $1000 

db $38,$55 


array 

          

   org $1100 #  set the location counter to $1100

zero_cnt ds.b   1 # variable to store the number of zeroes

lp_cnt     ds.b   1 # variable for the loop counter

             org   $1500 # set the location counter to $1500

             clr   zero_cnt # initialize the 0 count to 0

             movb #16,lp_cnt    # initialize lp_cnt  to 16

             ldd   array #place 16 bit number in D

again     lsrd #shift the lsb of D to the C flag

            bcs   chk_end #branch if the C flag (= LSB bits) is 1

            inc   zero_cnt #increment 0s count if the lsb is a 0

chk_end   dec   lp_cnt #check to see if D is already 0

            bne   again #check to see if we tested all   

            swi             

            end


Related Solutions

Python3  Please add comments Write a program that implements the word guessing game - There is a...
Python3  Please add comments Write a program that implements the word guessing game - There is a secret word - The user enters letters one at a time, if the letter appears in the secret word, it is revealed. Otherwise, it counts as a wrong guess. If the user reveals all the letters in the word before getting too many wrong guesses then they win! Otherwise, they lose. 1 - define secret word 2 - create a revealed letter list that...
Please add to this Python, Guess My Number Program. Add code to the program to make...
Please add to this Python, Guess My Number Program. Add code to the program to make it ask the user for his/her name and then greet that user by their name. Please add code comments throughout the rest of the program If possible or where you add in the code to make it ask the name and greet them before the program begins. import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the...
****user comments: PLEASE READ INSTRUCTIONS THOROUGHLY AND KEEP THE STRUCTURE OF THE PROGRAM. JUST ADD THE...
****user comments: PLEASE READ INSTRUCTIONS THOROUGHLY AND KEEP THE STRUCTURE OF THE PROGRAM. JUST ADD THE ADDITIVES NEEDED IN ORDER TO SUFFICE THE PROGRAM. PLEASE MAKE SURE IT IS IN C++ AND WORKS! THANK YOU!**** Write a program that uses a structure to store the following information for a particular month at the local airport: Total number of planes that landed Total number of planes that departed Greatest number of planes that landed in a given day that month Least...
Write an assembly program for the MSP430 to calculate the number of zeros and ones in...
Write an assembly program for the MSP430 to calculate the number of zeros and ones in an array. If the number of zeros is more than the number of ones, the red LED(connected to P1.0 on the MSP430 launchpad) will turn on. Otherwise, the green LED (connected to P1.6 on the MSP430 launchpad) will turn on.
In this program: ================================================================== /* Program to count number of occurrences of a given string in...
In this program: ================================================================== /* Program to count number of occurrences of a given string in original string*/ #include <iostream> #include <cstring> #include <stdio.h> #include <iostream> using namespace std; int main() { const int SIZE = 40; char str[SIZE]; char str1[SIZE]; char searchString[SIZE]; int n; int l1, l2; int count = 0; printf("Enter a sentence: \n"); fgets(str,SIZE,stdin); printf("Enter a search word: \n"); fgets(searchString,SIZE,stdin); if (str1[strlen(str1) - 1] == '\n') { str1[strlen(str1)-1] = '\0'; } if (str[strlen(str) - 1] == '\n')...
Develop a python program to create a quiz with limited time and attempts!!! Add comments and...
Develop a python program to create a quiz with limited time and attempts!!! Add comments and screenshot of running the program quiz could be of anything like , what's the sum of 2&2. There should be number of attempts(limited) suppose if the answer is wrong.
Also please add comments on the code and complete in C and also please use your...
Also please add comments on the code and complete in C and also please use your last name as key. The primary objective of this project is to increase your understanding of the fundamental implementation of Vigenere Cipher based program to encrypt any given message based on the Vignere algorithm. Your last name must be used as the cipher key. You also have to skip the space between the words, while replicating the key to cover the entire message. Test...
Here is a program that computes Fibonacci series. Can you add comments to variables and functions...
Here is a program that computes Fibonacci series. Can you add comments to variables and functions of every functions? For example, what are these variables meaning? What "for" function do on this program? Describe important section of code to text file. For example, which section of this code important? Why? Thank you all of help. #include<iostream> using namespace std; int main() { int arr[100]; int n1, n2; cin>>n1; arr[0] = 0; arr[1] = 1; for(int i = 2;i<n1;i++){ arr[i] =...
2.c++ if and loop statement Write a program that will count the number of even number...
2.c++ if and loop statement Write a program that will count the number of even number and odd numbers between two inputted numbers. Display the numbers and compute the sum and average of all the even numbers and the sum and average all the odd numbers. Sample outputs: Enter starting number:3 Enter starting number:4 Enter ending number:10 Enter ending number:10 odd numbers Even number 3 4 5 6 7 8 9 10 number of even numbers=4 number of even numbers=4...
(Python Code please) Guess the number! You will add to the program you created last week....
(Python Code please) Guess the number! You will add to the program you created last week. This week you will add quite a bit of code to your project. You will add an option for the computer to guess as well as the user to guess a number. In addition, you will add a menu system. Be sure to import random at the beginning of your code and use a comment block explaining what your program does #Guess the number...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT