Question: Introduction When we write an ARM Assembly Language program, we can represent immediate operands ( constant values ) by prefixing a value with ' #

Introduction
When we write an ARM Assembly Language program, we can represent immediate operands (constant values) by prefixing a value with '#'. For example, in the MOV instruction below, an immediate operand is represented in decimal (base 10) using the syntax #74.
MOV R1, #74
ARM Assembly Language programs are just strings of ASCII characters so the immediate operand #74 is just an ASCII string containing the characters '#','7' and '4'.
Part 1: Decimal Immediate Operand to Value
Write an ARM Assembly Language program that, given a NULL-terminated ASCII string representing an immediate operand in decimal form, will calculate the value of the operand and store it in R0. The input string starts in memory at the address in R1. The string is terminated by the NULL character (i.e. ASCII character code 0).
For example, given the string "#74", your program should store the value 74 in R0.
Part 2: Decimal Immediate Operand to Hexadecimal String
Extending your program from Part 1, write an ARM Assembly Language program that, given a NULL-terminated ASCII string representing an immediate operand in decimal form, will create a new ASCII string in which the same immediate operand is represented in hexadecimal form. For example, given the string " #74", your program should create the new string "#0x4A".
Your program should store the new string in memory at the address in R2. All alphabetic hexadecimal digits ('A'..'F') must be UPPERCASE and the 'x' in the prefix "0x" must be lowercase. Your program should also continue to store the value of the operand in R0. The new
string should be NULL-terminated. The value represented in the new string should not contain leading zeros (e.g. the new string should be "#0x4A" instead of "#0x0000004A").
Part 3: Decimal to Hexadecimal in an ARM Instruction
Given a string containing a line from an ARM Assembly Language program, modify and extend your program from Part 2 to create a copy of the original string in which any occurrence of an immediate operand in decimal form is replaced with its equivalent in hexadecimal form.
For example, given the string *.
"ADD R8, R8, #90"
Your program should create the new string ...
"ADD R8, R8, #0x5A"
Note that the string might not end with the immediate operand and your program should be able to handle strings such as ...
MOVR9,#180@y=180
The new copy of the string should again be stored in memory at the address in R2.
You can make the simplifying assumption that an occurrence of the character '#' always represents the start of a valid immediate operand in decimal form. You can identify the end of a immediate operand by the occurrence of any character other than '0'...'9'.
Introduction When we write an ARM Assembly

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!