Question

Write an assembly program which asks user to enter a character from ‘A’ to ‘Z’. If...

Write an assembly program which asks user to enter a character from ‘A’ to ‘Z’. If the user enters any other character, the program asks user to enter the character again. In this way the program inputs 300 characters and stores it in memory location from address $1000 to $112B. Hint: Use CPU register Y as counter

Homework Answers

Answer #1

Answer : Given data

.MODEL SMALL
 .STACK 100H

 .DATA
   PROMPT_1  DB  'Enter the character : $'
   PROMPT_2  DB  0DH,0AH,'The ASCII code of the given number in binary form is : $'
   PROMPT_3  DB  0DH,0AH,'The number of 1 bits in ASCII code are : $'

 .CODE
  A: MAIN PROC
     MOV AX, @DATA                ; initialize DS  
     MOV DS, AX

     LEA DX, PROMPT_1             ; load and display PROMPT_1   
     MOV AH, 9
     INT 21H

     MOV AH, 1                    ; read a character
     INT 21H

     XOR BX, BX                   ; clear BX
     MOV BL, AL                   ; move AL to BL

     LEA DX, PROMPT_2             ; load and display PROMPT_2
     MOV AH, 9
     INT 21H

     XOR BH, BH                   ; clear BH
     MOV CX, 8                    ; initialize loop counter
     MOV AH, 2                    ; set output function

     @OUTPUT:                     ; jump label
       SHL BL, 1                  ; shift left BX by 1 bit

       JNC @ZERO                  ; jump to label @ZERO if CF=0
       INC BH                     ; increment BH
       MOV DL, 31H                ; set DL=1
       JMP @DISPLAY               ; jump to label @DISPLAY

       @ZERO:                     ; jump label
         MOV DL, 30H              ; set DL=0

       @DISPLAY:                  ; jump label
         INT 21H                  ; display digit
     LOOP @OUTPUT                 ; jump to label @OUTPUT

     LEA DX, PROMPT_3             ; load and display the string PROMPT_3
     MOV AH, 9
     INT 21H

     OR BH, 30H                   ; convert the decimal to ascii code

     MOV AH, 2                    ; print the contents of BH
     MOV DL, BH
     INT 21H

     MOV AH, 4CH                  ; return control to DOS
     INT 21H
   MAIN ENDP
   JNE A
 END MAIN

__________________THE 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 a mips assembly language program that asks the user to enter and integer number and...
Write a mips assembly language program that asks the user to enter and integer number and read it. Then ask him to enter a bit position (between 0 and 31) and display the value of that bit.
write a program that asks the User to enter a letter, then asks the user to...
write a program that asks the User to enter a letter, then asks the user to enter a sentence. the program will then print out how many time that letter occurred in the sentence. in C Language
A. Write a Java program that asks the user to enter “bus” or “subway” or “walk”....
A. Write a Java program that asks the user to enter “bus” or “subway” or “walk”. If the user enters “bus” display “$1.00”. If they enter “subway” display “$1.50 and if they enter “walk” display “Free”. B. Write a java program that creates the following two arrays: String[] candidates = {“S Jones”,”Justin Fairfax”,”Clark Duncan”}; int[] votes = {7345,4324,3211}; Write the code that will search the votes array for the candidate with the largest number of votes and prints the name...
Write a program that asks the user to enter an odd number and prints out a...
Write a program that asks the user to enter an odd number and prints out a triangle pattern. For example, if the user enters 5, the output is note: There is one space between the numbers in each line 1 3 5 1 3 1 If the user enters 9 the output is: 1 3 5 7 9 1 3 5 7 1 3 5 1 3 1 program language: C++
Write a program that prompts the user to enter a string and displays the number of...
Write a program that prompts the user to enter a string and displays the number of characters it contains, fourth character, and last character. Note: The string may contain blanks. For example: “C++ programming is fun”. You should write a complete program.
Write a matlab program that takee a character (a-z) as an input and checks if that...
Write a matlab program that takee a character (a-z) as an input and checks if that is a vowel or not using switch statment? If the user inputs any other character, the program should display a proper error message.
C++ Write a program which accepts a character from the user. If the character is between...
C++ Write a program which accepts a character from the user. If the character is between 0 and 9, it will output that it's a digit. If the character is lowercase it will output that its a lowercase character. If it's an uppercase character it will output that it's uppercase. For all other cases it will output that it's neither a digit nor a letter. As an example of the output: Enter a digit or a letter: A You entered...
In Python only. Write a program that prompts the user to enter a hex character and...
In Python only. Write a program that prompts the user to enter a hex character and displays its corresponding decimal integer.
problem 1 Write a program that asks the user for an integer and then prints out...
problem 1 Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 84, the program should print 2 2 3 7 Validate the input to make sure that it is not a character or a string using do loop. in c plus plus
Write a NASM program that does the following: 1) Asks the user to enter three numbers...
Write a NASM program that does the following: 1) Asks the user to enter three numbers (each is a byte) A,B, and C 2) Adds up the numbers and stores the sum in variable D 3) Outputs the sum