| 1 | * local labels |
| 2 | * two forms, $[0-9] and label? are allowed |
| 3 | * Local labels are undefined/reset in one of four ways: |
| 4 | * .newblock |
| 5 | * changing sections |
| 6 | * entering an include file |
| 7 | * leaving an include file |
| 8 | .global addra, addrb, addrc |
| 9 | label1: ld addra,a |
| 10 | sub addrb,a |
| 11 | bc $1, alt ; generates frag! |
| 12 | ld addrb, a |
| 13 | b $2 |
| 14 | $1: ld addra,a |
| 15 | $2 add addrc,a |
| 16 | .newblock |
| 17 | bc $1,alt |
| 18 | stl a, addrc |
| 19 | $1 nop |
| 20 | |
| 21 | * #1, First definition of local label 'lab' |
| 22 | nop |
| 23 | lab? add #1,a ; reports as line 17? |
| 24 | b lab? |
| 25 | * #2, Included file also defines local label 'lab' |
| 26 | .copy labels.inc |
| 27 | * #3, Next definition; exit from .copy clears all locals |
| 28 | lab? add #3,a ; reports as line 22? |
| 29 | b lab? |
| 30 | * #4, Next definition is within macro; supersedes previous definition while |
| 31 | * within the macro |
| 32 | mac .macro |
| 33 | lab? add #4,a ; line 31? |
| 34 | b lab? |
| 35 | .endm |
| 36 | * Macro invocation |
| 37 | mac |
| 38 | * This reference should resolve to definition #3 |
| 39 | after_macro: |
| 40 | b lab? |
| 41 | * Section change clears all definitions; it's a CODE section if we see insns |
| 42 | .sect new_section |
| 43 | nop |
| 44 | lab? add #5,a |
| 45 | nop |
| 46 | nop |
| 47 | b lab? |
| 48 | * Newblock directive clears local labels |
| 49 | .newblock |
| 50 | lab? add #6,a |
| 51 | nop |
| 52 | nop |
| 53 | b lab? |
| 54 | .end |
| 55 | |