Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions