Advertisement
Guest User

No$gba debug

a guest
Mar 29th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.  
  4.  
  5.  
  6.     .global NoCash_Print    @int NoCash_Print(const char* str);
  7.     .global NoCash_Msg      @EWRAM_CODE void NoCash_Msg(void);
  8.     .global NoCash_Buffer   @extern EWRAM_DATA char NoCash_Buffer[80];
  9.  
  10.  
  11.     .text               @ Put the following stuff in the "text" (== code) section
  12.     .align 2            @ align to 1<<2 bytes
  13.     .thumb_func         @ Call as thumb function
  14.     .global NoCash_Print
  15. NoCash_Print:                
  16.     @ start of function
  17.     push    {r4, lr}            @pushes r4 and the Link Register onto the stack
  18.     ldr     r4, =NoCash_Msg     @Stores the address for the NoCash_Msg function
  19.     ldr     r1, =NoCash_Buffer  @Stores the address of the buffer
  20.  
  21.     mov     r2, #0              @initalise r2 to 0
  22.     mov     r12, r2             @mover the value of r2 into r12 as well
  23.    
  24. .Lmsg_loop:
  25.         mov r2, #0
  26.  
  27. .Lmsg_cpy:
  28.             ldrb    r3, [r0, r2]    @loads the data from r0 (per byte) and stores it in r3
  29.             strb    r3, [r1, r2]    @puts the data sent to the function into the buffer
  30.             cmp     r3, #0          @check to see if r3 == '\0' in which case it has hit
  31.                                     @the end of the string
  32.             beq     .Lmsg_print     @break to print the mesage
  33.             add     r2, #1          @increase the loop by 1
  34.             cmp     r2, #80         @if the loop hits 80 then it needs to break as there is
  35.                                     @only space for 80 character and we would buffer overflow if
  36.                                     @any more data was copied
  37.             bne     .Lmsg_cpy       @if it has not reached 80 character then loop
  38.  
  39. .Lmsg_print:
  40.         bl      .Lmsg_out
  41.  
  42.         @if '\0' was not hit then we need to carry on the message
  43.         add     r0, r2              @this should increase the string by 80 characters
  44.         add     r12, r2             @increases r12 by 80 as well (this is used to print the message)
  45.         cmp     r3, #0              @check to see if '\0' was hit just incase
  46.         bne     .Lmsg_loop
  47.  
  48.     @this will output the int value though I have no idea
  49.     @why r1 is poped maybe its from the stack which will be the int data
  50.     mov     r0, r12
  51.     pop     {r4}
  52.     pop     {r1}
  53.     bx      r1
  54.  
  55. .Lmsg_out:
  56.     bx      r4
  57.  
  58.  
  59.  
  60.  
  61. .section .ewram , "ax", %progbits
  62. .thumb_func
  63. .align 2;                              
  64. .global NoCash_Msg
  65.  
  66. NoCash_Msg:
  67.     mov     r12, r12
  68.     b       .Lmsg_end
  69.     .hword 0x6464
  70.     .hword 0
  71.  
  72. NoCash_Buffer:
  73.     .space  82
  74.  
  75. .Lmsg_end:
  76.     bx lr
  77.  
  78. @ end of function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement