Arm/hexstr

From ASMBits

arm/hex1Previous

Write a function that converts a 32-bit hexadecimal number into an ASCII character string. For digits 0xa through 0xf, use lower-case ('a' through 'f'). Don't include any leading zeros, but always output at least one digit (so 0x00001000 should print "1000", and 0x00000000 should output "0"). Make sure the output string is null-terminated.

There are two parameters to your function. The first parameter is the location to where you should write the output string. The second parameter is the number to process.

Sample Input

0x12345678

Sample Output

"12345678"

Write your solution here

x
 
1
// A test case to test your function with
2
MyString: .skip 12    // Reserve some space to hold the output string
3
4
.global _start
5
_start:
6
    ldr r0, =MyString     // First parameter: Where to write
7
    ldr r1, =0x12345678   // Second parameter: The number to process
8
    bl hexstr
9
    b _start        // End of testing code
10
11
// Convert number to string
12
hexstr:
13
    
14
    
Upload a source file...