Skip to content

Instantly share code, notes, and snippets.

@mntmn
Created June 6, 2014 20:36
Show Gist options
  • Save mntmn/89fab4ff5cb8f1f9b796 to your computer and use it in GitHub Desktop.
Save mntmn/89fab4ff5cb8f1f9b796 to your computer and use it in GitHub Desktop.
@ dumps memory. r1: address
print_memory:
push {r0-r6}
ldr r6, =uart0
ldr r6, [r6]
mov r5, r1 @ store memory begin address
mov r1, #'\n'
strb r1, [r6]
mov r0, #0xff @ dump 256 bytes
print_memory_loop:
ldrb r1, [r5]
mov r2, r1
and r1, r1, #0xf0 @ high nybble
lsr r1, r1, #4
add r1, r1, #'0'
cmp r1, #'9' @ greater than 9?
addgt r1, r1, #8 @ then shift to A-F range
strb r1, [r6] @ output
and r1, r2, #0x0f @ low nybble
add r1, r1, #'0'
cmp r1, #'9' @ greater than 9?
addgt r1, r1, #7 @ then shift to A-F range
strb r1, [r6] @ output
mov r1, #' '
strb r1, [r6]
add r5, r5, #1
lsr r2, r0, #4
lsl r2, r2, #4
cmp r0, r2
sub r0, r0, #1
bne print_memory_loop
mov r1, #'\n'
strb r1, [r6]
cmp r0, #16
bgt print_memory_loop
pop {r0-r6}
bx lr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment