Question: Assembly Language A. Write a macro that accepts a string address as input and prints the string. B. Write 4 procedures as described below: 1.
Assembly Language
A. Write a macro that accepts a string address as input and prints the string.
B. Write 4 procedures as described below:
1. The readInput procedure reads in the user input number and returns a valid input.
-
The procedure uses the stack to receive 2 input arguments: the address of the prompt string and the address of the error string
-
The procedure returns a valid user input on the stack.
-
The procedure prompts the user, checks that the user input number is within the range of a signed 8-bit integer. If the input is not in a valid range, it keeps printing an error message and re-prompting until there is a valid number to return. Use the macro to print the prompt string and error string.
2. The convert procedure converts the input number into a binary text string
-
The procedure uses the stack to receive 2 input arguments: the user input number and the address of the output array of characters.
-
The procedure uses a loop to get the value of each bit, and since you now know bit-wise instructions, you should extract each bit without using division.
-
As you find each bit, call a toChar procedure to convert the bit to its ASCII character. See the description for toChar in step 3. When calling toChar, pass to it the bit value through a register, and receive the returned ASCII character through a register.
-
Store each returned character in the output array of characters.
3. The toChar procedure converts the input bit into its ASCII character.
-
The procedure uses a register for the input value
-
It converts the input value into a character and returns the character through a register.
4. The main procedure has a loop with the following steps:
-
call readInput (pass input arguments through the stack)
-
call convert (pass input arguments through the stack)
-
invoke the macro to print the output array of characters
The loop ends when the use enters 0.
When the loop ends, print a "goodbye" message before ending the program.
Sample Output
Enter a number within 8 bits: 2000
Must be between -- and --
Enter a number within 8 bits: -3
1111 1101
Enter a number within 8 bits: 2
0000 0010
Enter a number within 8 bits: -800
Must be between -- and --
Enter a number within 8 bits: 0
Goodbye
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
