Home » Archimedes archive » Acorn User » AU 1994-06.adf » !StarInfo_StarInfo » NCW/LocalLabel

NCW/LocalLabel

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1994-06.adf » !StarInfo_StarInfo
Filename: NCW/LocalLabel
Read OK:
File size: 0619 bytes
Load address: 0000
Exec address: 0000
File contents
;**************************************************************************
;These macros are for making named local labels and registers in code and in
;MACROs.  Just call LocalLabels when you want a new set of local labels.
;Use like
;
;		LocalLabels
;counter$l	RN	6
;loop$l		SUBS	counter$l,counter$l,#1
;		BGT	loop$l
;
;The labels will be local between each call to LocalLabels
;
;In a macro just write
;
;		MACRO
;$label		a_macro
;$label		MacroLabels
;
;		;Body of macro using local objects
;counter$l	RN	6
;loop$l		SUBS	counter$l,counter$l,#1
;		BGT	loop$l
;
;		MLEND
;		MEND
;
;You can pass local labels into macros either as the label or as an argument
;and they will do what you want even if the macro uses local labels.  This is
;because strings are substituted when they are passed, not when used.
;
;You can also use the labels in the forms local$l or $l.local
;you might like to add a _ : local_$l  whatever you fancy just be consistent!
;**************************************************************************

		GBLA	LocalLabel
		GBLA	LocalLabelLevel
		GBLA	LabelNumber
		GBLS	l

		MACRO
$label		LocalLabels
$label
LabelNumber	SETA	LocalLabel
l		SETS	"Local$LabelNumber"
LocalLabel	SETA	LocalLabel + 1
		MEND


		MACRO
$label		MacroLabels
$label
		GBLA	MacroLabel$LocalLabelLevel
MacroLabel$LocalLabelLevel	SETA	LabelNumber
LocalLabelLevel	SETA	LocalLabelLevel + 1
		LocalLabels
		MEND


		MACRO
$label		MLEND
$label
LocalLabelLevel	SETA	LocalLabelLevel - 1
LabelNumber	SETA	MacroLabel$LocalLabelLevel
l		SETS	"Local$LabelNumber"
		MEND

		END
00000000  3b 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |;***************|
00000010  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00000040  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 0a 3b 54 68 65  |***********.;The|
00000050  73 65 20 6d 61 63 72 6f  73 20 61 72 65 20 66 6f  |se macros are fo|
00000060  72 20 6d 61 6b 69 6e 67  20 6e 61 6d 65 64 20 6c  |r making named l|
00000070  6f 63 61 6c 20 6c 61 62  65 6c 73 20 61 6e 64 20  |ocal labels and |
00000080  72 65 67 69 73 74 65 72  73 20 69 6e 20 63 6f 64  |registers in cod|
00000090  65 20 61 6e 64 20 69 6e  0a 3b 4d 41 43 52 4f 73  |e and in.;MACROs|
000000a0  2e 20 20 4a 75 73 74 20  63 61 6c 6c 20 4c 6f 63  |.  Just call Loc|
000000b0  61 6c 4c 61 62 65 6c 73  20 77 68 65 6e 20 79 6f  |alLabels when yo|
000000c0  75 20 77 61 6e 74 20 61  20 6e 65 77 20 73 65 74  |u want a new set|
000000d0  20 6f 66 20 6c 6f 63 61  6c 20 6c 61 62 65 6c 73  | of local labels|
000000e0  2e 0a 3b 55 73 65 20 6c  69 6b 65 0a 3b 0a 3b 09  |..;Use like.;.;.|
000000f0  09 4c 6f 63 61 6c 4c 61  62 65 6c 73 0a 3b 63 6f  |.LocalLabels.;co|
00000100  75 6e 74 65 72 24 6c 09  52 4e 09 36 0a 3b 6c 6f  |unter$l.RN.6.;lo|
00000110  6f 70 24 6c 09 09 53 55  42 53 09 63 6f 75 6e 74  |op$l..SUBS.count|
00000120  65 72 24 6c 2c 63 6f 75  6e 74 65 72 24 6c 2c 23  |er$l,counter$l,#|
00000130  31 0a 3b 09 09 42 47 54  09 6c 6f 6f 70 24 6c 0a  |1.;..BGT.loop$l.|
00000140  3b 0a 3b 54 68 65 20 6c  61 62 65 6c 73 20 77 69  |;.;The labels wi|
00000150  6c 6c 20 62 65 20 6c 6f  63 61 6c 20 62 65 74 77  |ll be local betw|
00000160  65 65 6e 20 65 61 63 68  20 63 61 6c 6c 20 74 6f  |een each call to|
00000170  20 4c 6f 63 61 6c 4c 61  62 65 6c 73 0a 3b 0a 3b  | LocalLabels.;.;|
00000180  49 6e 20 61 20 6d 61 63  72 6f 20 6a 75 73 74 20  |In a macro just |
00000190  77 72 69 74 65 0a 3b 0a  3b 09 09 4d 41 43 52 4f  |write.;.;..MACRO|
000001a0  0a 3b 24 6c 61 62 65 6c  09 09 61 5f 6d 61 63 72  |.;$label..a_macr|
000001b0  6f 0a 3b 24 6c 61 62 65  6c 09 09 4d 61 63 72 6f  |o.;$label..Macro|
000001c0  4c 61 62 65 6c 73 0a 3b  0a 3b 09 09 3b 42 6f 64  |Labels.;.;..;Bod|
000001d0  79 20 6f 66 20 6d 61 63  72 6f 20 75 73 69 6e 67  |y of macro using|
000001e0  20 6c 6f 63 61 6c 20 6f  62 6a 65 63 74 73 0a 3b  | local objects.;|
000001f0  63 6f 75 6e 74 65 72 24  6c 09 52 4e 09 36 0a 3b  |counter$l.RN.6.;|
00000200  6c 6f 6f 70 24 6c 09 09  53 55 42 53 09 63 6f 75  |loop$l..SUBS.cou|
00000210  6e 74 65 72 24 6c 2c 63  6f 75 6e 74 65 72 24 6c  |nter$l,counter$l|
00000220  2c 23 31 0a 3b 09 09 42  47 54 09 6c 6f 6f 70 24  |,#1.;..BGT.loop$|
00000230  6c 0a 3b 0a 3b 09 09 4d  4c 45 4e 44 0a 3b 09 09  |l.;.;..MLEND.;..|
00000240  4d 45 4e 44 0a 3b 0a 3b  59 6f 75 20 63 61 6e 20  |MEND.;.;You can |
00000250  70 61 73 73 20 6c 6f 63  61 6c 20 6c 61 62 65 6c  |pass local label|
00000260  73 20 69 6e 74 6f 20 6d  61 63 72 6f 73 20 65 69  |s into macros ei|
00000270  74 68 65 72 20 61 73 20  74 68 65 20 6c 61 62 65  |ther as the labe|
00000280  6c 20 6f 72 20 61 73 20  61 6e 20 61 72 67 75 6d  |l or as an argum|
00000290  65 6e 74 0a 3b 61 6e 64  20 74 68 65 79 20 77 69  |ent.;and they wi|
000002a0  6c 6c 20 64 6f 20 77 68  61 74 20 79 6f 75 20 77  |ll do what you w|
000002b0  61 6e 74 20 65 76 65 6e  20 69 66 20 74 68 65 20  |ant even if the |
000002c0  6d 61 63 72 6f 20 75 73  65 73 20 6c 6f 63 61 6c  |macro uses local|
000002d0  20 6c 61 62 65 6c 73 2e  20 20 54 68 69 73 20 69  | labels.  This i|
000002e0  73 0a 3b 62 65 63 61 75  73 65 20 73 74 72 69 6e  |s.;because strin|
000002f0  67 73 20 61 72 65 20 73  75 62 73 74 69 74 75 74  |gs are substitut|
00000300  65 64 20 77 68 65 6e 20  74 68 65 79 20 61 72 65  |ed when they are|
00000310  20 70 61 73 73 65 64 2c  20 6e 6f 74 20 77 68 65  | passed, not whe|
00000320  6e 20 75 73 65 64 2e 0a  3b 0a 3b 59 6f 75 20 63  |n used..;.;You c|
00000330  61 6e 20 61 6c 73 6f 20  75 73 65 20 74 68 65 20  |an also use the |
00000340  6c 61 62 65 6c 73 20 69  6e 20 74 68 65 20 66 6f  |labels in the fo|
00000350  72 6d 73 20 6c 6f 63 61  6c 24 6c 20 6f 72 20 24  |rms local$l or $|
00000360  6c 2e 6c 6f 63 61 6c 0a  3b 79 6f 75 20 6d 69 67  |l.local.;you mig|
00000370  68 74 20 6c 69 6b 65 20  74 6f 20 61 64 64 20 61  |ht like to add a|
00000380  20 5f 20 3a 20 6c 6f 63  61 6c 5f 24 6c 20 20 77  | _ : local_$l  w|
00000390  68 61 74 65 76 65 72 20  79 6f 75 20 66 61 6e 63  |hatever you fanc|
000003a0  79 20 6a 75 73 74 20 62  65 20 63 6f 6e 73 69 73  |y just be consis|
000003b0  74 65 6e 74 21 0a 3b 2a  2a 2a 2a 2a 2a 2a 2a 2a  |tent!.;*********|
000003c0  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00000400  2a 0a 0a 09 09 47 42 4c  41 09 4c 6f 63 61 6c 4c  |*....GBLA.LocalL|
00000410  61 62 65 6c 0a 09 09 47  42 4c 41 09 4c 6f 63 61  |abel...GBLA.Loca|
00000420  6c 4c 61 62 65 6c 4c 65  76 65 6c 0a 09 09 47 42  |lLabelLevel...GB|
00000430  4c 41 09 4c 61 62 65 6c  4e 75 6d 62 65 72 0a 09  |LA.LabelNumber..|
00000440  09 47 42 4c 53 09 6c 0a  0a 09 09 4d 41 43 52 4f  |.GBLS.l....MACRO|
00000450  0a 24 6c 61 62 65 6c 09  09 4c 6f 63 61 6c 4c 61  |.$label..LocalLa|
00000460  62 65 6c 73 0a 24 6c 61  62 65 6c 0a 4c 61 62 65  |bels.$label.Labe|
00000470  6c 4e 75 6d 62 65 72 09  53 45 54 41 09 4c 6f 63  |lNumber.SETA.Loc|
00000480  61 6c 4c 61 62 65 6c 0a  6c 09 09 53 45 54 53 09  |alLabel.l..SETS.|
00000490  22 4c 6f 63 61 6c 24 4c  61 62 65 6c 4e 75 6d 62  |"Local$LabelNumb|
000004a0  65 72 22 0a 4c 6f 63 61  6c 4c 61 62 65 6c 09 53  |er".LocalLabel.S|
000004b0  45 54 41 09 4c 6f 63 61  6c 4c 61 62 65 6c 20 2b  |ETA.LocalLabel +|
000004c0  20 31 0a 09 09 4d 45 4e  44 0a 0a 0a 09 09 4d 41  | 1...MEND.....MA|
000004d0  43 52 4f 0a 24 6c 61 62  65 6c 09 09 4d 61 63 72  |CRO.$label..Macr|
000004e0  6f 4c 61 62 65 6c 73 0a  24 6c 61 62 65 6c 0a 09  |oLabels.$label..|
000004f0  09 47 42 4c 41 09 4d 61  63 72 6f 4c 61 62 65 6c  |.GBLA.MacroLabel|
00000500  24 4c 6f 63 61 6c 4c 61  62 65 6c 4c 65 76 65 6c  |$LocalLabelLevel|
00000510  0a 4d 61 63 72 6f 4c 61  62 65 6c 24 4c 6f 63 61  |.MacroLabel$Loca|
00000520  6c 4c 61 62 65 6c 4c 65  76 65 6c 09 53 45 54 41  |lLabelLevel.SETA|
00000530  09 4c 61 62 65 6c 4e 75  6d 62 65 72 0a 4c 6f 63  |.LabelNumber.Loc|
00000540  61 6c 4c 61 62 65 6c 4c  65 76 65 6c 09 53 45 54  |alLabelLevel.SET|
00000550  41 09 4c 6f 63 61 6c 4c  61 62 65 6c 4c 65 76 65  |A.LocalLabelLeve|
00000560  6c 20 2b 20 31 0a 09 09  4c 6f 63 61 6c 4c 61 62  |l + 1...LocalLab|
00000570  65 6c 73 0a 09 09 4d 45  4e 44 0a 0a 0a 09 09 4d  |els...MEND.....M|
00000580  41 43 52 4f 0a 24 6c 61  62 65 6c 09 09 4d 4c 45  |ACRO.$label..MLE|
00000590  4e 44 0a 24 6c 61 62 65  6c 0a 4c 6f 63 61 6c 4c  |ND.$label.LocalL|
000005a0  61 62 65 6c 4c 65 76 65  6c 09 53 45 54 41 09 4c  |abelLevel.SETA.L|
000005b0  6f 63 61 6c 4c 61 62 65  6c 4c 65 76 65 6c 20 2d  |ocalLabelLevel -|
000005c0  20 31 0a 4c 61 62 65 6c  4e 75 6d 62 65 72 09 53  | 1.LabelNumber.S|
000005d0  45 54 41 09 4d 61 63 72  6f 4c 61 62 65 6c 24 4c  |ETA.MacroLabel$L|
000005e0  6f 63 61 6c 4c 61 62 65  6c 4c 65 76 65 6c 0a 6c  |ocalLabelLevel.l|
000005f0  09 09 53 45 54 53 09 22  4c 6f 63 61 6c 24 4c 61  |..SETS."Local$La|
00000600  62 65 6c 4e 75 6d 62 65  72 22 0a 09 09 4d 45 4e  |belNumber"...MEN|
00000610  44 0a 0a 09 09 45 4e 44  0a                       |D....END.|
00000619