summaryrefslogtreecommitdiff
path: root/Debugger/debug_comm.S
diff options
context:
space:
mode:
authorTat-Chee Wan (USM)2011-03-24 09:29:15 +0800
committerTat-Chee Wan (USM)2011-03-24 09:29:15 +0800
commit13d2797ab2263a0703668feb8208eb3911524232 (patch)
tree17c22c3215c7d2aea48d0cbf998ecc5be243fee7 /Debugger/debug_comm.S
parenta44b042507e4e196e08b4367364526371053591f (diff)
rewrite char2hex to avoid trashing register r1
Diffstat (limited to 'Debugger/debug_comm.S')
-rw-r--r--Debugger/debug_comm.S35
1 files changed, 20 insertions, 15 deletions
diff --git a/Debugger/debug_comm.S b/Debugger/debug_comm.S
index 86ee823..af02d16 100644
--- a/Debugger/debug_comm.S
+++ b/Debugger/debug_comm.S
@@ -133,29 +133,34 @@ hex2char:
* equivalent byte sized hex value in R0(7:0).
* It accepts lowercase and uppercase ASCII Hex char inputs.
* Invalid inputs return -1 as the value
+* On entry:
+ * R0: ASCII character
+ * On exit:
+ * R0: Hex value
*/
.global char2hex
char2hex:
- and r1, r0, #BYTE0 /* make sure that input is sane */
- mov r0, #-1 /* Initialize Return value to Error value */
- cmp r1, #'0'
- blo exit_char2hex
- cmp r1, #'9'
+ and r0, r0, #BYTE0 /* make sure that input is sane */
+ cmp r0, #'0'
+ blo char2hex_error
+ cmp r0, #'9'
bls perform_char2hex
- cmp r1, #'A'
- blo exit_char2hex
- cmp r1, #'F'
+ cmp r0, #'A'
+ blo char2hex_error
+ cmp r0, #'F'
bls perform_char2hex
- cmp r1, #'a'
- blo exit_char2hex
- cmp r1, #'f'
- bhi exit_char2hex
+ cmp r0, #'a'
+ blo char2hex_error
+ cmp r0, #'f'
+ bhi char2hex_error
/* Validated Hex Char */
perform_char2hex:
- mov r0, r1 /* restore hex char */
- _char2hex r0
-exit_char2hex:
+ _char2hex r0 /* Return hex value in R0 */
+ bx lr
+
+char2hex_error:
+ mov r0, #-1 /* Set Return value to Error value */
bx lr
/* byte2ascii_cont