home *** CD-ROM | disk | FTP | other *** search
- ;--> Local
-
- ; Demonstrates local labels and expanded macros in SAsm
- ; Terrible example of code but just intended as a demo
- ; © D.J.Holden 1991
-
- # org &8000 ; Assemble code to run at &8000
-
- # type &FF8 ; 'Absolute' application to be loaded at &8000
-
- # size &400 ; Allocate 1K for assembled code
-
- ; define a simple macro to print a string
-
- # sm print_string , display$ ;this is the first line of the macro definition
-
- swi "OS_WriteS" ;call OS routine to display the string
- equs display$ ;the string that will be displayed
- db 13,10,0 ;cr/lf and a zero terminator
- align
- # em
-
- # sm double_newline ;define a macro to print two cr/lf pairs
- swi 256+13
- swi 256+10
- swi 256+13
- swi 256+10
- # em
-
-
- adr r2,text ;r2 points to the text
-
- .00 ldrb r0,[r2],#1 ;first label at '00'
- swi "OS_WriteC" ;print text til LF found
- cmp r0,10 ;no need to use '#' for immediate cmp
- bne 00
-
- .01 ldrb r0,[r2],#1 ;continue until 0 found
- cmp r0,0
- swine "OS_WriteC"
- bne 01
-
- bal 04 ;branch around the text
-
- .text db "Hello",13,10,"World",13,10,0 : align
-
- ;------- This next bit is just calls to previously defined macros ------
-
- .04 ; Now use the previously defined macro to print another string
-
- @ print_string , "This is an Expanded Macro" ;this is a Macro call
-
- @ print_string , "This is another Expanded Macro"
-
- @ print_string , "This is a third Expanded Macro"
-
- @ double_newline ;just a couple of blank lines
-
- ;------ Back to normal style code -------
-
- mov r1,010 ;load hex &10 into r0
- .00 subs r1,r1,#1 ;just a loop to start a new set of labels
- bmi 01 ;this will branch to the '01' below
- bpl 00
-
-
- .01 swi "OS_Exit"
-
- #end
-
-