home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1995 / ARCHIVE95.iso / discs / shareware / share_46 / sasm / Examples / Local < prev   
Text File  |  1993-12-15  |  2KB  |  71 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. # sm  double_newline              ;define a macro to print two cr/lf pairs
  24.         swi 256+13
  25.         swi 256+10
  26.         swi 256+13
  27.         swi 256+10
  28. # em
  29.  
  30.  
  31.         adr r2,text               ;r2 points to the text
  32.  
  33. .00     ldrb r0,[r2],#1           ;first label at '00'
  34.         swi "OS_WriteC"           ;print text til LF found
  35.         cmp r0,10                 ;no need to use '#' for immediate cmp  
  36.         bne 00
  37.  
  38. .01     ldrb r0,[r2],#1           ;continue until 0 found
  39.         cmp r0,0
  40.         swine "OS_WriteC"
  41.         bne 01
  42.  
  43.         bal 04                    ;branch around the text
  44.  
  45. .text   db "Hello",13,10,"World",13,10,0   : align
  46.  
  47. ;------- This next bit is just calls to previously defined macros ------
  48.  
  49. .04     ; Now use the previously defined macro to print another string
  50.  
  51.  @ print_string , "This is an Expanded Macro"       ;this is a Macro call
  52.  
  53.  @ print_string , "This is another Expanded Macro"
  54.  
  55.  @ print_string , "This is a third Expanded Macro"
  56.  
  57.  @ double_newline                       ;just a couple of blank lines
  58.  
  59.         ;------ Back to normal style code -------
  60.  
  61.         mov r1,010                ;load  hex &10 into r0
  62. .00     subs r1,r1,#1             ;just a loop to start a new set of labels
  63.         bmi 01                    ;this will branch to the '01' below
  64.         bpl 00                    
  65.  
  66.    
  67. .01     swi "OS_Exit"
  68.  
  69. #end
  70.  
  71.