Label

From C64-Wiki
(Redirected from Line Number)
Jump to navigationJump to search
Disambiguation The title of this article is ambiguous. Label (Disambiguation).

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.

In the BASIC V2 of the C64 can't directly use a label. The labels of these GOTO or GOSUB statements are line numbers. Line numbers are ranging from 0 to 63999 [1]. In case the line number is outside the allowed range the error message ?SYNTAX ERROR is raised. Distinct values (350720 to 353720) crashes BASIC V2.
Other and several BASIC extensions (like Simons Basic or CBM BASIC 3.5) offer more flexibility and comfort to handle line numbers. However possibly with the disadvantage a RENUMBER oversees to adjust calculated line number.

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 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]

  1. 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 Language:english.