Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.5) Write your own routine to convert an integer into a dexadecimal ASCII string places the result into a sequence of eight characters in a

4.5) Write your own routine to convert an integer into a dexadecimal ASCII string places the result into a sequence of eight characters in a buffer....

image text in transcribed

data asciiz apsed # Start of code section # Time counter # Adjustable Time Factor main: ss1.0 2i countdown: $s0, 2500000 waitloop: addi$0, Sso-1 bnez addi la sysca $so,waitloop $s1,$s1,5 sao, msg call $print string move sao, $sl syscall Sprint_ int addi bnez syscall exit # print amount Sto,$sl.-60 sto, countdown 4.4 Enter the program given in section 4.7 into the MIPSym simulator and report on the val- ues generated for each erroneous input. 4.5 (Challenging) Write your own routine to convert an integer into a hexadecimal ASCI string placing the result into a sequence of eight characters in a buffer. When your routine is called, Sa0 will contain the number to format, Sal will contain a pointer to the location in memory where the ASCII representation is to be placed, Because hexadecimal digits correspond to groups of four binary digits, You can generate the digits from left to right. Don't worry about negative values. You can convert individual decimal digits to the cor responding ASCII character by adding the value of an ASCII zero character (0x:30 or 0) to the integer digit. Values above nine will need to add an extra 7 to finish the con- version to the ASCII letters "A""F." 4.6 (Extra challenging) Write a general purpose routine to format integers into a string buffer in any number base between 2 and 36. $a0 should contain the number to format, $al a pointer to the string buffer, $a2 the base between 2 and 36 to use for this conversion and $a3 the size of the buffer including the terminal nul. You will need to generate the digits from right to left, using division by the base with the remainder giving the next digit while the quotient holds the balance of the number. When the quotient returns zero, it will signal the end of the loop. Space fill any remaining locations in the buffer. Negative num bers should be handled by placing a minus sign to the left of the most significant digit. To handle negative numbers, you will need to take the absolute value of the remainders

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

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions

Question

What is computer neworking ?

Answered: 1 week ago