Integer BASIC is the BASIC Steve Wozniak wrote for the Apple II: whole numbers from -32768 to 32767, no floating point. It lives in the ROM of the
original Apple II and is loaded from disk (the DOS 3.3 System Master has it as the INTBASIC file) on later machines. A DOS 3.3
I file is the program preceded by a 2-byte length; a ProDOS INT ($FA) file is the program alone.
Lines
| Field | Size | Meaning |
|---|---|---|
| Length | 1 | The length of the whole line in bytes, this byte and the end byte included |
| Line number | 2 | Low byte first; 0 to 32767 |
| Tokens | length − 4 | The statements |
| End | 1 | $01 |
The next line follows at once: there is no link, only the length. The program ends with its last line. A real example, the loader APPLESOFT on the DOS 3.3 System Master (its line 10, after
the 2-byte DOS length): the viewer reads it as TEXT : CALL -936: DIM A$(40).
Tokens
Bytes below $80 are keywords and punctuation; bytes from $B0 are digits and letters (below). The same word has several tokens:
Integer BASIC picks one by the syntax that follows it (PRINT has three, INPUT three, DIM two; the meaning of each is not described here); $28 and $29 are the opening and the closing quotation mark. A listing shows the word whichever token it was.
| Token | Text | Token | Text | Token | Text | Token | Text |
|---|---|---|---|---|---|---|---|
$00 | HIMEM: | $01 | none | $02 | _ | $03 | : |
$04 | LOAD | $05 | SAVE | $06 | CON | $07 | RUN |
$08 | RUN | $09 | DEL | $0A | , | $0B | NEW |
$0C | CLR | $0D | AUTO | $0E | , | $0F | MAN |
$10 | HIMEM: | $11 | LOMEM: | $12 | + | $13 | - |
$14 | * | $15 | / | $16 | = | $17 | # |
$18 | >= | $19 | > | $1A | <= | $1B | <> |
$1C | < | $1D | AND | $1E | OR | $1F | MOD |
$20 | ^ | $21 | + | $22 | ( | $23 | , |
$24 | THEN | $25 | THEN | $26 | , | $27 | , |
$28 | " (opens a string) | $29 | " (closes it) | $2A | ( | $2B | ! |
$2C | ! | $2D | ( | $2E | PEEK | $2F | RND |
$30 | SGN | $31 | ABS | $32 | PDL | $33 | RNDX |
$34 | ( | $35 | + | $36 | - | $37 | NOT |
$38 | ( | $39 | = | $3A | # | $3B | LEN( |
$3C | ASC( | $3D | SCRN( | $3E | , | $3F | ( |
$40 | $ | $41 | $ | $42 | ( | $43 | , |
$44 | , | $45 | ; | $46 | ; | $47 | ; |
$48 | , | $49 | , | $4A | , | $4B | TEXT |
$4C | GR | $4D | CALL | $4E | DIM | $4F | DIM |
$50 | TAB | $51 | END | $52 | INPUT | $53 | INPUT |
$54 | INPUT | $55 | FOR | $56 | = | $57 | TO |
$58 | STEP | $59 | NEXT | $5A | , | $5B | RETURN |
$5C | GOSUB | $5D | REM | $5E | LET | $5F | GOTO |
$60 | IF | $61 | $62 | $63 | |||
$64 | POKE | $65 | , | $66 | COLOR= | $67 | PLOT |
$68 | , | $69 | HLIN | $6A | , | $6B | AT |
$6C | VLIN | $6D | , | $6E | AT | $6F | VTAB |
$70 | = | $71 | = | $72 | ) | $73 | ) |
$74 | LIST | $75 | , | $76 | LIST | $77 | POP |
$78 | NODSP | $79 | DSP | $7A | NOTRACE | $7B | DSP |
$7C | DSP | $7D | TRACE | $7E | PR# | $7F | IN# |
How sure the table is. It was written from the published token list. The anchors REM = $5D, GOTO = $5F, IF = $60,
FOR = $55 and PEEK = $2E are fixed by the real programs: all 67 lines of the two Integer BASIC programs on the DOS 3.3 System
Master (APPLESOFT and COPY) read as sensible BASIC with every token resolved and every GOTO, GOSUB and THEN number a line that exists. The Integer BASIC ROM image on the same disk (INTBASIC) was
searched for its keyword text and does not keep it as plain text, so the table could not be compared with it. Tokens that those two programs never use are therefore not confirmed.
Numbers, names and strings
- A number is one byte from
$B0to$B9(the first digit typed, with the high bit set) followed by the 16-bit value, low byte first.A=5isC1 56 B5 05 00: the nameA, the token$56(=), and the number 5. A line number afterGOTOis such a number. - A name is letters
$C1to$DA(A to Z with the high bit set); digits$B0to$B9after a letter are part of the name. A name ending in$is a string, its$a token ($40or$41). - A string is between the tokens
$28and$29; its characters have the high bit set. - REM (
$5D) is followed by its text up to the$01, characters with the high bit set.