home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / utilities / utilss / sasm / SAsm / Source / Local < prev   
Text File  |  1993-10-06  |  2KB  |  61 lines

  1. ;--> Local
  2.  
  3. ; Demonstrates local labels and expanded macros in SAsm
  4. ; Terrible example of code but just intended as a demo
  5. ; © D.J.Holden 1991
  6.  
  7. # org  &8000            ; Assemble code to run at &8000
  8.  
  9. # type &FF8             ; 'Absolute' application to be loaded at &8000
  10.  
  11. # size &400             ; Allocate 1K for assembled code
  12.  
  13. ; define a simple macro to print a string
  14.  
  15. # sm  print_string , display$     ;this is the first line of the macro definition
  16.  
  17.         swi  "OS_WriteS"          ;call OS routine to display the string
  18.         equs display$             ;the string that will be displayed
  19.         db   13,10,0              ;cr/lf and a zero terminator
  20.         align
  21. # em
  22.  
  23.  
  24.  
  25.  
  26.         adr r2,text               ;r2 points to the text
  27.  
  28. .00     ldrb r0,[r2],#1           ;first label at '00'
  29.         swi "OS_WriteC"           ;print text til LF found
  30.         cmp r0,10                 ;no need to use '#' for immediate cmp  
  31.         bne 00
  32.  
  33. .01     ldrb r0,[r2],#1           ;continue until 0 found
  34.         cmp r0,0
  35.         swine "OS_WriteC"
  36.         bne 01
  37.  
  38.         bal 04                    ;branch around the text
  39.  
  40. .text   db "Hello",13,10,"World",13,10,0   : align
  41.  
  42. .04     ; Now use the previously defined macro to print another string
  43.  
  44.  @ print_string , "This is an Expanded Macro"       ;this is a Macro call
  45.  
  46.  @ print_string , "This is another Expanded Macro"
  47.  
  48.  @ print_string , "This is a third Expanded Macro"
  49.  
  50.  
  51.         mov r1,010                ;load  hex &10 into r0
  52. .00     subs r1,r1,#1             ;just a loop to start a new set of labels
  53.         bmi 01                    ;this will branch to the '01' below
  54.         bpl 00                    
  55.  
  56.    
  57. .01     swi "OS_Exit"
  58.  
  59. #end
  60.  
  61.