Skip to content

Integer BASIC reference ​

Every command, function and operator in Integer BASIC — Woz's interpreter, in two revisions: Apple 1 Integer BASIC, written in 1976 for the machine it ran on, and Apple II Integer BASIC, in the 1977 machine's ROM sockets with the colour graphics, cursor and cassette the Apple I never had.

Rows the Apple II added are badged Apple II only in the table below, and the four the Apple I kept for itself — HIMEM=, LOMEM=, OFF and SCR — are badged Apple I only. Everything else is on both machines, and where the two behave differently the row says how.

In this reference: Hardware · Escape codes · File formats · Argument notation

Notes and caveats ​

  • This is not Applesoft. The BASIC most Apple II programs were written in came later, on tape and then in the II Plus's ROM. Nothing of it is here: no floating point, no HGR or HPLOT, no CHR$, MID$ or STR$, no DATA/READ, no ONERR and no DEF FN. A listing using any of them is Applesoft, and has a reference of its own.
  • Variable names differ between the two machines. On the Apple I a name is one letter and at most one digit: A and A1 are variables, while AB and A12 are each a syntax error, and a string variable is a bare letter with $. This is the tightest naming of any machine here. On the Apple II a name may be as long as you like, but AND, AT, MOD, OR, STEP, THEN and TO end a name where they appear in it from the second character on — RATE is read as RA, TO and a syntax error, while TOTAL and ANDY are fine.
  • Numbers are 16-bit signed integers, −32767 to 32767, and / truncates towards zero, so 7/2 is 3. There is no floating point and no maths library. The Apple II raises to a power with ^; the Apple I has no power operator — ^ has a token and reaches no handler, so a program using it stops there and never returns, and the editor refuses it rather than letting that happen.
  • A string must be DIMed before use, and assigning at a position truncates what follows — A$(5)="X" leaves a five-character string. There is no concatenation: a string is extended by assigning past its end, as A$(LEN(A$)+1)="C". Strings compare with = and # and nothing else.
  • AND, OR and NOT reduce their operands to a truth value rather than combining bits: 5 AND 3 and 5 OR 3 are both 1, and NOT 5 is 0. A true comparison is 1, not -1. # is this BASIC's "not equal"; <> is accepted as well, for numbers only.
  • Multiple statements per line are allowed with :, and line numbers run 0 to 32767. What limits an Apple II line is the entry buffer, which holds the text and the tokens made from it at once: together they may reach 255, and at 256 the machine answers *** TOO LONG ERR.
  • PEEK, POKE and CALL take signed decimal addresses — there is no hexadecimal notation anywhere in this BASIC, which is why an I/O address is written negative. PEEK(-12272) reads the Apple I's keyboard and PEEK(-16384) the Apple II's.

Command Function Operator

Syntax & description
-<number> - <number> | -<number>
Subtracts, or negates.
*<number> * <number>
Multiplies. A product over 32767 answers *** >32767 ERR rather than wrapping.
/<number> / <number>
Divides, truncating towards zero: 7/2 is 3 and -7/2 is -3. There are no fractions to keep, so a calculation needing one is rescaled - work in tenths and divide at the end. Dividing by zero answers *** >32767 ERR.
#<number> # <number> | <string> # <string>
Not equal, in this BASIC's own spelling. With = it is the whole of what a string comparison can be.
^Apple II only<number> ^ <number>
Raises to a power: 2^10 is 1024. The Apple 1 has a token for it and no working code behind that token; here it runs.
+<number> + <number> | +<number>
Adds, or marks a positive number. Never joins strings: there is no concatenation - append by assigning past the end instead, as A$(LEN(A$)+1)="C".
<<number> < <number>
Less than. Numbers only: strings have no ordering here, so IF A$<B$ is a syntax error.
<=<number> <= <number>
Less than or equal.
<><number> <> <number>
Not equal, the familiar spelling. It stores a token of its own, distinct from #, and unlike # it does not compare strings.
=<number> = <number> | <string> = <string>
Equal, and also the assignment in LET. A true comparison is 1 here, not the -1 of the Microsoft BASICs.
><number> > <number>
Greater than.
>=<number> >= <number>
Greater than or equal.
ABSABS(<number>)
The value without its sign.
AND<number> AND <number>
Logical and: 1 when both operands are non-zero, 0 otherwise. Not bitwise - 5 AND 3 is 1, not the 1 the bits would give by coincidence.
ASCApple II onlyASC(<string>)
The code of a string's first character, with bit 7 already set - ASC("H") is 200, not 72 - because that is the form the machine stores characters in. It therefore compares directly with what PEEK(-16384) reads from the keyboard.
ATApple II onlyHLIN <x>, <x> AT <y> | VLIN <y>, <y> AT <x>
Names the row HLIN draws along, or the column VLIN draws down. It belongs to those two statements and appears nowhere else - but it is still a keyword everywhere, so a variable called CAT is read as C, AT and a syntax error.
AUTOAUTO <line>[, <number>]
Numbers lines for you as you type them, from the given line and in the given steps (10 by default). Cancelled with OFF on the Apple I and with MAN on the Apple II. A prompt command: inside a numbered line it answers *** SYNTAX ERR.
CALLCALL <addr>
Calls a machine-code routine, which returns with RTS. The address is signed decimal like every address here, so a routine above 32767 is called with a negative number: on the Apple II, CALL -936 is the monitor call that clears the screen.
CLRCLR
Discards every variable, array and string, leaving the program itself alone. A prompt command: refused inside a numbered line, and accepted on an unnumbered line of its own, though a program the IDE builds starts with no variables anyway.
COLOR=Apple II onlyCOLOR=<colour>
Sets the colour PLOT, HLIN and VLIN draw in, 0 (black) to 15 (white). The number is taken modulo 16, so COLOR=19 draws in colour 3, and colours 5 and 10 are two bit patterns that beat to the same grey.
CONApple II onlyCON
Continues a program stopped by a break or an error, from where it stopped. A prompt command.
DELDEL <line>[, <line>]
Deletes one line, or every line from the first to the second inclusive. A prompt command: refused inside a numbered line, and the IDE builds every line the listing holds, so delete them from the listing instead.
DIMDIM <numvar>(<number>) | DIM <strvar>(<length>)
Declares an array or a string, and both must be declared before they are touched at all - an undeclared subscript answers *** RANGE ERR. A string is a fixed buffer of the declared length, allocated once and never grown, of at most 255 characters. Numeric arrays are indexed from 1 on the Apple I and from 0 on the Apple II, so DIM A(3) holds three numbers there and four here. There are no string arrays and nothing two-dimensional.
DSPApple II onlyDSP <var>
Watches one variable: every assignment to it prints the line number and the new value. NODSP stops the watch. No other BASIC here has it.
ENDEND
Stops the program and returns to the > prompt. Every program needs one: falling off the last line reports *** END ERR on the Apple I and *** NO END ERR on the Apple II.
FORFOR <numvar> = <number> TO <number> [STEP <number>]
Opens a counting loop that runs up to the matching NEXT. STEP sets the increment, which may be negative; the body always runs at least once.
GOSUBGOSUB <line>
Calls a subroutine, which returns with RETURN. Eight levels deep on the Apple I, which answers *** >8 GOSUBS ERR beyond that, and sixteen on the Apple II, which answers *** 16 GOSUBS ERR.
GOTOGOTO <line>
Jumps to a line number. The target may be an expression, which is this BASIC's whole computed jump - there is no ON … GOTO.
GRApple II onlyGR
Switches on the lo-res screen and clears it to black: a 40 by 40 grid of coloured blocks with four lines of text under it. The page is really 40 by 48, and PLOT reaches the eight rows hidden behind the text window. TEXT switches back.
HIMEM:Apple II onlyHIMEM:<addr>
Sets the top of the workspace, which is where the program text starts and grows down from. The cold start leaves it at the top of RAM, and since a constant stops at 32767 that address is typed HIMEM:-16384. The colon is part of the spelling; HIMEM= is the Apple 1. A prompt command.
HIMEM=Apple I onlyHIMEM= <addr>
Sets the top of the workspace, which the program grows down from. `=`, not the Apple II's `:`. A stock machine has 4K fitted and the cold start already puts HIMEM at the top of it, so raising this needs more RAM on the board. Refused inside a program line; on an unnumbered line of its own - the way a listing writes it - it sets the workspace the IDE builds the program into.
HLINApple II onlyHLIN <x>, <x> AT <y>
Draws a horizontal run of lo-res blocks in the current colour, from the first column to the second inclusive, along row <y>.
IFIF <number> THEN <line> | IF <number> THEN <statement>
Runs the consequent when the condition is non-zero. There is no ELSE: write a second IF, and note that a true comparison here is 1 rather than the -1 of the Microsoft BASICs.
IN#Apple II onlyIN#<slot>
Reads input from the card in a peripheral slot instead of from the keyboard; IN#0 gives the keyboard back. No cards are fitted to the emulated machine, so 0 is the only slot with anything on the other end of it.
INPUTINPUT [<prompt>,] <var>[, <var>]…
Prints the prompt, then a ?, and waits for a whole line to be typed. On the Apple I it is the only key read a program has, the interpreter taking any keypress first and stopping with STOPPED AT; the Apple II can also read the keyboard without stopping, with PEEK(-16384).
LENLEN(<string>)
How many characters a string holds. The Apple I's only string function; on the Apple II, ASC( joins it and the two are the whole of the library. Either way there is no MID$, LEFT$, RIGHT$, CHR$, STR$ or VAL, and no concatenation.
LETLET <var> = <expr>
Assigns a value. Optional, as on every BASIC here; the interpreter stores the same bytes either way.
LISTLIST [<line>[, <line>]]
Lists the whole program, one line, or a range. On the Apple II, alone among the commands the interpreter takes at its prompt, it is also legal inside a numbered line, so a program can list itself as it runs; the Apple I refuses it there.
LOADApple II onlyLOAD
Reads a program from cassette into the top of whatever workspace the machine already has. The tape carries no name and no bounds, so a HIMEM: is typed before the LOAD rather than after it. A prompt command.
LOMEM:Apple II onlyLOMEM:<addr>
Sets the bottom of the workspace, where the variables start and grow up. The cold start leaves it at 2048, just above the text page, and lowering it claims the page of RAM a machine-code block would otherwise use. A prompt command.
LOMEM=Apple I onlyLOMEM= <addr>
Sets the bottom of the workspace, which the variables grow up from, and discards every variable. Lowering it to 768 buys a larger workspace at the cost of the free RAM a machine-code block would go in. Refused inside a program line; on an unnumbered line of its own - the way a listing writes it - it sets the workspace the IDE builds the program into.
MANApple II onlyMAN
Cancels AUTO and hands the line numbering back to you. The Apple 1 spells the same command OFF. A prompt command.
MOD<number> MOD <number>
The remainder after dividing. Exact, division here truncating rather than rounding.
NEWApple II onlyNEW
Erases the program and every variable with it. The Apple 1 spells the same command SCR. A prompt command.
NEXTNEXT <numvar>[, <numvar>]…
Closes a FOR loop and jumps back to it. The variable is not optional, unlike most BASICs of the period; several may be named at once, innermost first.
NODSPApple II onlyNODSP <var>
Stops the DSP watch on one variable.
NOTNOT <number>
Logical not: 1 when the operand is zero, 0 otherwise. NOT 5 is 0, not the -6 a bitwise BASIC would give.
NOTRACEApple II onlyNOTRACE
Stops TRACE printing line numbers.
OFFApple I onlyOFF
Cancels AUTO line numbering. Refused inside a program line - which is a difficulty, AUTO being on while you type one. On an unnumbered line of its own it is accepted and kept.
OR<number> OR <number>
Logical or: 1 when either operand is non-zero, 0 otherwise. Not bitwise - 5 OR 3 is 1.
PDLApple II onlyPDL(<number>)
How far a paddle is turned, 0 to 255 with 128 at the centre. The game connector carries four of them, numbered 0 to 3; the on-screen controller drives 0 and 1 as the two axes of a stick.
PEEKPEEK(<addr>)
The byte at an address, written in signed decimal. On the Apple I the keyboard port at $D010 is read as PEEK(-12272), though a program cannot usefully poll it, the interpreter taking any keypress first; on the Apple II, PEEK(-16384) is the keyboard latch and a value over 127 there means a key is waiting. Reading one of the Apple II's soft switches throws it exactly as writing to it would.
PLOTApple II onlyPLOT <x>, <y>
Lights one lo-res block in the current colour. <x> runs 0 to 39 and <y> 0 to 47; outside that the program stops with *** RANGE ERR.
POKEPOKE <addr>, <byte>
Stores a byte in memory. The address is signed decimal - there is no hexadecimal anywhere in this BASIC - so the Apple I's display port at $D012 is written as POKE -12270, and the Apple II's keyboard strobe at $C010 is cleared with POKE -16368,0.
POPApple II onlyPOP
Discards the innermost GOSUB return address, so the next RETURN goes back one level further out. How a subroutine leaves without returning to whoever called it.
PR#Apple II onlyPR#<slot>
Sends everything PRINT writes to the card in a peripheral slot instead of to the screen; PR#0 gives the screen back. As with IN#, the emulated machine has no cards fitted.
PRINTPRINT [<expr>[;|,]]…
Prints numbers and strings. A trailing ; holds the cursor where it is - which is how a program stops the screen scrolling - and a trailing , steps to the next tab zone; a bare PRINT ends the line. On the Apple I each character costs one video field, so filling the screen takes about sixteen seconds.
REMREM <comment>
A comment, to the end of the line. The text is stored as typed, a byte a character, and comes back unchanged in a listing - and on the Apple I it shares the 2048 bytes the program and its variables already compete for, so a long comment is a real cost.
RETURNRETURN
Returns from a subroutine to the statement after its GOSUB.
RNDRND(<number>)
A whole number from 0 up to one less than the argument, so RND(6) is 0 to 5. There is no fractional form, this BASIC having no fractions: the RND(1) of Applesoft belongs to the other BASIC in the Apple II's ROM sockets.
RUNRUN [<line>]
Discards the variables and starts the program, at the given line or at the lowest one. A prompt command: refused inside a numbered line, and accepted on an unnumbered line of its own - a listing often ends with one - though the IDE starts the program itself.
SAVEApple II onlySAVE
Writes the program to cassette as two records - its length, then its text - beeping once for each. A prompt command.
SCRApple I onlySCR
Scratch: erases the whole program. Refused inside a program line, which is the only thing standing between a listing and a typing slip. On an unnumbered line of its own - the way a listing opens - it is accepted and kept, a program the IDE builds being scratched to begin with.
SCRNApple II onlySCRN(<x>, <y>)
The colour of one lo-res block, 0 to 15. The only function here that takes two arguments, and it means a program can read its own picture back rather than keeping a map of it in an array.
SGNSGN(<number>)
The sign of a number: -1, 0 or 1.
STEPFOR <numvar> = <number> TO <number> STEP <number>
The amount a FOR loop adds each time round, and only ever part of one. Negative counts down; there is no fractional step, this BASIC having no fractions.
TABTAB <col>
Moves the print column, counting from 1, on the row the cursor is already on. A statement rather than a print formatter - the TAB( inside a PRINT is Applesoft's - so it stands on its own rather than inside a PRINT. On the Apple I it moves right only, there being no cursor addressing at all; on the Apple II it moves back as readily as forward, so what is printed next overwrites what was there.
TEXTApple II onlyTEXT
Switches back from lo-res graphics to the full 40 by 24 text screen. It does not clear it; CALL -936 does that.
THENIF <number> THEN <line> | IF <number> THEN <statement>
The consequent of an IF: a line number to jump to, or a statement to run. The two are different tokens to the interpreter, though nothing in a listing shows it.
TOFOR <numvar> = <number> TO <number>
The value a FOR loop counts to, inclusive. Also one of the words that ends a variable name where it appears inside one, which is why TOTAL is a variable and XTOTAL is not.
TRACEApple II onlyTRACE
Prints each line number as the program reaches it, with a # in front, until NOTRACE. With DSP it is the whole of this machine's debugger.
VLINApple II onlyVLIN <y>, <y> AT <x>
Draws a vertical run of lo-res blocks in the current colour, from the first row to the second inclusive, down column <x>.
VTABApple II onlyVTAB <row>
Moves the cursor to a row, 1 to 24; outside that the program stops with *** RANGE ERR. With TAB it addresses any cell on the screen, which is what lets text be redrawn in place.
Argument notation

Anything in <angle brackets> is a value you supply; everything else is typed exactly as shown. [square brackets] mark an optional part, | separates alternatives, and … means the part before it can repeat. The arguments on this page are:

<number>
a numeric expression
<string>
a string expression
<expr>
a value of either type, where the keyword takes both
<byte>
a value from 0 to 255
<var>
a variable of either type
<numvar>
a numeric variable
<strvar>
a string variable
<line>
a line number
<statement>
one BASIC statement
<comment>
free text, to the end of the line
<length>
how many characters
<x>
a horizontal graphics coordinate
<y>
a vertical graphics coordinate
<col>
a text column
<row>
a text row
<colour>
a colour, by number
<prompt>
text shown before the input; a literal, not an expression
<addr>
a memory address
<slot>
a peripheral slot, 0 to 7

Showing 73 of 73 keywords

The preamble a listing opens with ​

An Integer BASIC listing is not only numbered lines. The commands the interpreter takes at its > prompt are written above the program, and often a bare RUN below it. Paste one in as it stands: a line with no number is accepted anywhere in the program as long as it holds one of those commands, and anything else without a number is still an error.

On the Apple I ​

SCR
LOMEM=768
HIMEM=4096
10 PRINT "HELLO"
20 END
RUN

Nine commands may stand on an unnumbered line: SCR, CLR, RUN, LIST, DEL, AUTO, OFF, LOMEM= and HIMEM=. The same nine are refused inside a numbered line.

LOMEM= and HIMEM= are the two that change anything. They set the workspace the program is built into and loaded with — the area the program grows down through and its variables grow up through — so LOMEM=768 gives a program 3328 bytes instead of the stock 2048. Bounds the machine could not hold are reported where they are written: the workspace has to sit above the monitor's input buffer at $0280 and inside the 4K of RAM the machine has fitted, and its top has to be above its bottom. Where the same bound is set twice, the last one is the one that takes effect.

Lowering LOMEM claims the free RAM a machine-code block would otherwise use. $0300–$07FF is the only RAM Integer BASIC never touches on a stock machine, so a program cannot both move LOMEM down there and keep a block.

The other seven — SCR, CLR, RUN, LIST, DEL, AUTO and OFF — are kept with the program and change nothing about it. A program built here is already scratched and holds no variables, and the IDE starts it for you.

A cassette export writes the workspace into the dump alongside the program, and importing one restates whatever LOMEM= and HIMEM= it was saved with — but note that the monitor range you type at a real machine follows those bounds too, which is why the Transfer dialog spells the range out rather than always saying 800.FFF.

On the Apple II ​

NEW
HIMEM:16384
10 PRINT "HELLO"
20 END
RUN

Twelve commands may stand on an unnumbered line: AUTO, CLR, CON, DEL, HIMEM:, LOAD, LOMEM:, MAN, NEW, RUN, SAVE, and LIST, which is legal in both places. The other eleven are refused inside a numbered line.

LOMEM: and HIMEM: are the two that change anything. They set the workspace the program is built into: the program grows down from HIMEM and the variables grow up from LOMEM, and the two meeting is *** MEM FULL ERR. The cold start puts them at 2048 and the top of RAM, which is the whole 47104 bytes, so a listing sets them to make room for something else rather than to make room for itself — a machine-code block below LOMEM, say. Bounds the machine could not hold are reported where they are written, and where the same bound is set twice the last one takes effect.

The other commands are kept with the program and change nothing about it: what is built here is already erased and holds no variables, and the IDE starts it for you.

One thing the preamble is not is part of the tape. A cassette record holds the program and its length and nothing else, so HIMEM: is typed at a real machine before LOAD rather than after it — which is why the Transfer dialog spells those bounds out for a program that moved them.

Either way ​

The preamble is part of the program text, so renumbering leaves it where it is and the assistant will not drop it.

What this machine does not run ​

COLOR=, PLOT, HLIN and AT are in the Apple I's syntax table, left over from Woz's work towards the Apple II, and reach a machine with no graphics hardware. USR parses and jumps to address 0. HIMEM, LOMEM and COLOR used as expressions all evaluate to 0. None of them is offered as a keyword on that machine, and the editor names each one rather than reporting an unknown word. On the Apple II the same four graphics commands are real, and are in the table below.

Released under GNU GPL v3.0. Some ROM images are third-party copyrighted works, separate to this project, strictly for personal/educational purposes.