Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITE THE FUNCTION DESCRIBED IN SECTION 5.7 AND A MAIN ROUTINE TO TEST IT. 5.7 A FUNCTION TO READ IN HEXADECIMAL VALUES To input characters

WRITE THE FUNCTION DESCRIBED IN SECTION 5.7 AND A MAIN ROUTINE TO TEST IT.

image text in transcribedimage text in transcribed

5.7 A FUNCTION TO READ IN HEXADECIMAL VALUES To input characters from the keyboard one uses a system service to read a string (syscall sread_string) the specific set of instructions used to read a string appear below: la li syscall $read-string # Place keystrokes into buffe $a0, buffer $a1,9 # load address of input buffer into ao # Length of buffer, n The read string system service will monitor the keyboard and as the keys are pressed, the corresponding ASCII codes will be placed sequentially into the input buffer in memory. When the "Enter" key is pressed or the buffer has n-1 characters, the string is terminated by the nul code (0x00), and control is returned to the user program Notice this particular syscall has two parameters passed to it: The value in register $ao specifies the address of the input buffer in memory, and the value in register $al specifies the length of the buffer. To allocate space in memory for a nine-character buffer, the following assembler directives can be used . data buffer: . space 9 The capability to input values in hexadecimal representation is already present in the sread_int syscall. You can input a hexadecimal integer by prefixing the number with 0x. If you want to restrict the user to entering only in hexadecimal this routine could be used. In gen- eral, this algorithm involves reading in a string of characters from the keyboard into a buffer and then scanning through the string of characters, converting each ASClII code to the corre- sponding 4-bit value. The process is essentially the inverse of the hexadecimal output function, except that lower case characters as well as upper case should be accepted for "a" through "f ch new valid hexadecimal ASCII code is found, we shift our accumulator register left four bits and then insert the new 4-bit code into the accumulator. We can avoid getting more al digits in the input string by setting the buffer size to nine. If any other When ea 5.7 A FUNCTION TO READ IN HEXADECIMAL VALUES To input characters from the keyboard one uses a system service to read a string (syscall sread_string) the specific set of instructions used to read a string appear below: la li syscall $read-string # Place keystrokes into buffe $a0, buffer $a1,9 # load address of input buffer into ao # Length of buffer, n The read string system service will monitor the keyboard and as the keys are pressed, the corresponding ASCII codes will be placed sequentially into the input buffer in memory. When the "Enter" key is pressed or the buffer has n-1 characters, the string is terminated by the nul code (0x00), and control is returned to the user program Notice this particular syscall has two parameters passed to it: The value in register $ao specifies the address of the input buffer in memory, and the value in register $al specifies the length of the buffer. To allocate space in memory for a nine-character buffer, the following assembler directives can be used . data buffer: . space 9 The capability to input values in hexadecimal representation is already present in the sread_int syscall. You can input a hexadecimal integer by prefixing the number with 0x. If you want to restrict the user to entering only in hexadecimal this routine could be used. In gen- eral, this algorithm involves reading in a string of characters from the keyboard into a buffer and then scanning through the string of characters, converting each ASClII code to the corre- sponding 4-bit value. The process is essentially the inverse of the hexadecimal output function, except that lower case characters as well as upper case should be accepted for "a" through "f ch new valid hexadecimal ASCII code is found, we shift our accumulator register left four bits and then insert the new 4-bit code into the accumulator. We can avoid getting more al digits in the input string by setting the buffer size to nine. If any other When ea

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

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

Prepare a short profile of Henry words worth Longfellow?

Answered: 1 week ago

Question

What is RAM as far as telecommunication is concerned?

Answered: 1 week ago

Question

Question 1: What is reproductive system? Question 2: What is Semen?

Answered: 1 week ago

Question

Describe the sources of long term financing.

Answered: 1 week ago