Label
A Label in a programming language is a sequence of characters that identifies a location within source code. In most languages labels take the form of an identifier, often followed by a punctuation character (e.g., a colon). In many high level programming languages the purpose of a label is to act as the destination of a GOTO or a GOSUB statement.
The BASIC V2 of the C64 can't directly use labels. In this case, the labels of GOTO or GOSUB statements are line numbers ranging from 0 to 63999 [1].
If the line number is outside the allowed range the error message ?SYNTAX ERROR is displayed. The distinct values 350720 to 353720 crashes BASIC V2.
Several BASIC extensions (such as Simons Basic and CBM BASIC 3.5) offer more flexibility regarding the handling of line numbers, but with the possibility of misnumbered elements being introduced if the RENUMBER function is used.
Example:
10 X = 1: GOTO 30 20 GOSUB 100: X = X + 2 30 ON X GOSUB 100, 200, 100, 200, 100 40 X = X - 1: IF X<1 THEN X = 1 50 PRINT X 60 ON X GOTO 20, 40, 20, 40, 20, 40 90 END 100 X = X + 1: PRINT X: RETURN 200 X = X - 0.5 : PRINT X: RETURN
In Commodore 64 assembly language, labels referring to code locations can be the destination of a jump instruction (JMP, JSR), or branching instruction (BCC, BCS, BEQ, BMI, BNE, BPL). Labels referring to data locations can be the arguments to loading and storing instructions (LDA, STA), arithmetic instructions (ADC,SBC, CMP) and logical instructions (AND, ORA, EOR), or other instruction referring a memory location.
Other programming languages sometimes use line numbers just because the screen editor needs them, but not the language itself (e.g. Comal or Hypra-Ass assembler). Usually labels are used as jump targets or referring data locations, also known as named code blocks, procedures, functions or data structures.
Source code editing for modern programming languages does not depend on line numbering. A text editor is a common tool for languages like Assembler, C, Forth, Pascal and Promal. Even modern BASIC variants tend to omit line numbers at all, providing the notion of structured programming and named subroutines.
References[edit | edit source]
- ↑ Line number maximum of 63999 is coming from the interpreter's implementation while parsing and build-up of the line number value: the according check compares to the value 6400 before it is to be multiplied with 10, but only for the high byte for sake of simplicity. See BASIC-ROM $A96B/43371 .