home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / program / d / extasm / Examples_Macros < prev    next >
Encoding:
Text File  |  1993-10-24  |  908 b   |  23 lines

  1.  
  2. macro PROG_INIT {
  3.    #set StackSize = 1024                  ; how large stack do we want?   
  4.    .Start
  5.       b        Main                       ; jump over the stack   
  6.    .Stack_Ceiling                         ; top-of-stack   
  7.       dbb      StackSize,0                ; allocate stack space here   
  8.    .Stack_Floor                           ; bottom-of-stack   
  9.    .Old_Stack  dcd   0                    ; place to store old r13   
  10.    .Main   
  11.       str      r13,Old_Stack              ; save old r13   
  12.       adr      r13,Stack_Floor            ; r13-> new stack   
  13.       stmfd    r13!,{r0-r12,r14}          ; push all registers on our stack   
  14.    .Begin
  15. }
  16.  
  17. macro PROG_EXIT {
  18.    .End
  19.       ldmfd    r13!,{r0-r12,r14}          ; pop all registers from our stack   
  20.       ldr      r13,Old_Stack              ; get old r13   
  21.       movs     pc,r14                     ; return with all registers intact
  22. }
  23.