SHARE
TWEET

Untitled

a guest Jan 12th, 2020 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   param:
  3.     r0: byte in range 0x00-0x0F
  4.   result:
  5.     r0: ascii
  6. */
  7. NibbleToAscii:
  8.   and r0,#0xF
  9.   add r0,#'0'
  10.   cmp r0,#'9'
  11.   movls pc,lr
  12.   add r0,#7
  13.   mov pc,lr
  14.  
  15. /*
  16.   param:
  17.     r0: 8bit unsigned int
  18.     r1: x
  19.     r2: y
  20.   result:
  21.     r0: x
  22.     r1: y
  23. */
  24. .globl PrintU8
  25. PrintU8:
  26.   push {r4,r5,r6,lr}
  27.   n .req r4
  28.   x .req r5
  29.   y .req r6
  30.   mov n,r0
  31.  
  32.   lsr r0,n,#4
  33.   mov x,r1
  34.   mov y,r2
  35.   bl NibbleToAscii
  36.   bl DrawCharacter
  37.   add x,r0
  38.  
  39.   mov r0,n
  40.   mov r1,x
  41.   mov r2,y
  42.   bl NibbleToAscii
  43.   bl DrawCharacter
  44.   add r0,x,r0
  45.   mov r1,y
  46.  
  47.   pop {r4,r5,r6,pc}
  48.   .unreq n
  49.   .unreq x
  50.   .unreq y
  51.  
  52. /*
  53.   param:
  54.     r0: 32bit unsigned int
  55.     r1: x
  56.     r2: y
  57.   result:
  58.     r0: x
  59.     r1: y
  60. */
  61. .globl PrintU32
  62. PrintU32:
  63.   push {r4,r5,lr}
  64.   n .req r4
  65.   mask .req r5
  66.  
  67.   mov n,r0
  68.   mov mask,#0xFF
  69.   lsl mask,#24
  70.  
  71.   and r0,n,mask
  72.   lsr r0,#24
  73.   bl PrintU8
  74.   mov r2,r1
  75.   mov r1,r0
  76.   lsr mask,#8
  77.   and r0,n,mask
  78.   lsr r0,#16
  79.   bl PrintU8
  80.   mov r2,r1
  81.   mov r1,r0
  82.   lsr mask,#8
  83.   and r0,n,mask
  84.   lsr r0,#8
  85.   bl PrintU8
  86.   mov r2,r1
  87.   mov r1,r0
  88.   lsr mask,#8
  89.   and r0,n,mask
  90.   bl PrintU8
  91.  
  92.   pop {r4,r5,pc}
  93.   .unreq mask
  94.   .unreq n
  95.  
  96. /*
  97.   param:
  98.     r0: addr aligned to 16byte boundary
  99.     r1: size
  100.     r2: x
  101.     r3: y
  102.   return:
  103.     r0: x
  104.     r1: y
  105. */
  106. .globl PrintMemory16
  107. PrintMemory16:
  108.   push {r4,r5,r6,r7,r8,lr}
  109.   addr .req r4
  110.   size .req r5
  111.   x0 .req r6
  112.   x .req r7
  113.   y .req r8
  114.   mvn r4,#0xFF
  115.   and addr,r0,r4
  116.   mov size,r1
  117.   mov x0,r2
  118.   mov y,r3
  119.  
  120. printMemLineLoop$:
  121.     mov x,x0
  122.  
  123.     mov r0,addr
  124.     mov r1,x
  125.     mov r2,y
  126.     bl PrintU32
  127.     mov x,r0
  128.     mov y,r1
  129.  
  130.     mov r0,#':'
  131.     mov r1,x
  132.     mov r2,y
  133.     bl DrawCharacter
  134.     add x,r0
  135.  
  136.     mov r0,#' '
  137.     mov r1,x
  138.     mov r2,y
  139.     bl DrawCharacter
  140.     add x,r0
  141.  
  142.   printMemLoop$:
  143.     ldrb r0,[addr]
  144.     mov r1,x
  145.     mov r2,y
  146.     bl PrintU8
  147.     mov x,r0
  148.  
  149.     mov r0,#' '
  150.     mov r1,x
  151.     mov r2,y
  152.     bl DrawCharacter
  153.     add x,r0
  154.  
  155.     subs size,#1
  156.     teq size,#0
  157.     beq printMemLoopEnd$
  158.     adds addr,#1
  159.     tst addr,#0xF
  160.     bne printMemLoop$
  161.     add y,r1
  162.     b printMemLineLoop$
  163. printMemLoopEnd$:
  164.   mov r0,x0
  165.   add r1,y
  166.   pop {r4,r5,r6,r7,r8,pc}
  167.   .unreq addr
  168.   .unreq size
  169.   .unreq x0
  170.   .unreq x
  171.   .unreq y
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top