Question: ( ASSEMBLY LANGUAGE ) Building on the program from the last assignment, a null - terminated string of ASCII character codes, representing decimal digits as

(ASSEMBLY LANGUAGE)Building on the program from the last assignment, a null-terminated string of ASCII character codes,
representing decimal digits as might be entered from a keyboard, are stored in consecutive bytes of memory
beginning at address STRG in RAM. Write a program to convert the decimal number represented by this
string of characters to the equivalent 32-bit binary number, storing the result at address BINARY in RAM.
(This is essentially a decimal to binary conversion.) This program should be able to process strings of any
number of digits from one to the number corresponding to the maximum 32-bit unsigned binary number.
For example, if you were to type the decimal number "13587609" on the keyboard, the corresponding
characters would be stored in memory at STRG as follows:
STRG=>'1'(0x31)- Most significant digit (10,000,000's)
STRG+1=>'3'(0x33)- Next most significant digit (1,000,000's)
STRG+2=>'5'(0x35)- Next most significant digit (100,000's)
STRG+3=>'8'(0x38)- Next most significant digit (10,000's)
STRG+4=>'7'(0x37)- Next most significant digit (1,000's)
STRG+5=>'6'(0x36)- Next most significant digit (100's)
STRG+6=>'0'(030)- Next most significant digit (10's)
STRG+7=>'9'(0x39)- Least significant digit (1's)
STRG+8=>000,- Null character
The corresponding BINARY value would be 00000000110011110101010010011001=0x00CF5499.
Recall that the kth decimal digit of a number is weighted by a factor of 10k.
D=1*107+3*106+5*105+8*104+7*103+6*102+0*101+9
This can also be computed by factoring out 10 s as:
D=((((((1)*10+3)*10+5)*10+8)*10+7)*10+6)*10+0
The latter form might be easier to process for variable-length numbers since for each digit you multiply the
previous total by 10 and add the new digit.
Execute the program two times - once for each of the following character strings stored at STRG.
STRG: .asciz "13587609"//first test string
STRG: .asciz "457"//second test string
For the second test run, you can reset the processor and then enter the following command in the Debugger
Console to change the string and rerun the program without exiting the debugger.
set char [4]* STRG =457
( ASSEMBLY LANGUAGE ) Building on the program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!