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.
In Java program: Write a program that takes a character from the user and classifies it...
In Java program: Write a program that takes a character from the user and classifies it as a number (‘1’,’2’, ‘3’,4, 5, 6, 7  …), a letter from the alphabet (‘A’, ‘a’, ‘B’, ‘b’, …, ‘Z’, ‘z’), an arithmetic operator (‘+’, ‘-‘, ‘/’, ‘*’, ‘%’), a comparison operator (‘<’, ‘>’, ‘=’), punctuation (‘!’, ‘?’, ‘,’, ‘,’, ‘:’, ‘;’), and all other characters as a Special Character, and informs the user of the same. If the user entered the character A, the...
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
Provide Python code that does the following: 4) Write a program that asks the user to...
Provide Python code that does the following: 4) Write a program that asks the user to enter a 9 character password. Test to see if it is a valid password. The validity test is a) they enter exactly 9 characters AND b) that every 3rd character, starting with the 1st character is the letter z. If it is valid print out the message “valid password” otherwise print the message “invalid password”. Sample output. Please enter a password: zaazbbz12 valid password...
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++
3. Removing a character from a string Write a function remove() that asks the user to...
3. Removing a character from a string Write a function remove() that asks the user to enter a string and an index, and displays the string with the character at that index removed. You may assume the given index is within the string. For example, removing the character at index 2 in "hello" should produce "helo". Hint: Use slicing.
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT