Skip to content

MSX BASIC reference ​

Every command, function and operator in MSX BASIC 1.0, the BASIC that came in the ROM of every MSX1 — here, the Sony HB-10P.

MSX was a published standard rather than one company's machine, so this BASIC is the same on every MSX1 whoever built it. It is Microsoft BASIC underneath; what is not Microsoft is the machine bolted to it.

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

Notes and caveats ​

  • Line numbers 0–65529, strictly ascending, with several statements to a line separated by :. ? is shorthand for PRINT and ' for REM, and LET is optional. GO TO written as two words is not accepted, unlike the Microsoft BASICs this one descends from.
  • Variable names may be long, but only the first two characters are significant, so COUNT and COST are one variable. All four type suffixes are real — $ string, % integer, ! single, # double — and a name carrying none is double precision, fourteen digits, unless DEFINT and its siblings say otherwise. Integer arithmetic is markedly faster, which is why DEFINT A-Z is the usual first line of a game.
  • Spaces are ignored outside strings, REM and DATA, so FORI=1TO10 is a loop. The other side of that rule is that a keyword is recognised inside a name: SCORE contains OR and TOTAL contains TO, and both are rejected.
  • Numbers may be written in decimal, hex (&HFF), octal (&O377) or binary (&B1010). The operators include ^ (power, folding left to right so 2^3^2 is 64), \ (integer division), MOD, XOR, EQV and IMP. AND, OR and NOT combine their operands bit by bit, and a true comparison is -1.
  • <=, >= and <> have no tokens of their own — each is stored as its two characters' tokens side by side — which is why =<, => and >< are the same three tests written the other way round, and why all six are listed below.
  • The string space is 200 bytes on a clean boot, whatever the free-memory figure says. A program holding more than a handful of strings needs a CLEAR 1500 (or larger) first, or it stops with Out of string space.
  • There is no WHILE/WEND. And CALL is for cartridge extensions, not for machine code: a code block is reached with DEF USR and USR.

Command Function Operator

Syntax & description
-<number> - <number> | -<number>
Subtracts, and negates.
*<number> * <number>
Multiplies.
/<number> / <number>
Divides, always producing a fractional value. The backslash is the integer division.
\<number> \ <number>
Integer division: both operands are converted to integers and the result is truncated towards zero, so -7 \ 2 is -3.
^<number> ^ <number>
Raises to a power. It folds left to right, so 2^3^2 is 64 rather than 512.
+<number> + <number> | <string> + <string>
Adds numbers and joins strings. A joined string longer than 255 characters is a String too long.
<<number> < <number> | <string> < <string>
Less than.
<=<number> <= <number> | <string> <= <string>
Less than or equal. MSX BASIC has no token of its own for it: the pair is stored as the < and = tokens side by side, which is why the reversed spelling is the same test.
<><number> <> <number> | <string> <> <string>
Not equal.
=<number> = <number> | <string> = <string>
Equal, and also the assignment in LET. Which of the two it is comes from where it stands, not from how it is written.
=<<number> =< <number> | <string> =< <string>
Less than or equal, written the other way round; the same two tokens as <=, in the other order.
=><number> => <number> | <string> => <string>
Greater than or equal, written the other way round; the same test as >=.
><number> > <number> | <string> > <string>
Greater than. Strings compare a character code at a time from the left, and a shorter string that matches as far as it goes is the smaller.
><<number> >< <number> | <string> >< <string>
Not equal, written the other way round; the same test as <>.
>=<number> >= <number> | <string> >= <string>
Greater than or equal.
ABSABS(<number>)
The value without its sign.
AND<number> AND <number>
Combines two sixteen-bit integers a bit at a time, so 5 AND 3 is 1. A true comparison is -1, every bit set, which is why it also reads as a logical AND.
ASCASC(<string>)
The code of a string’s first character. An empty string is an Illegal function call.
ATNATN(<number>)
The arctangent, in radians, between -π/2 and π/2. There is no two-argument form, so the quadrant has to be worked out from the signs.
ATTR$ATTR$
The attributes of the last file a disc search found. Illegal function call on a machine with no drive.
AUTOAUTO [<line>[, <number>]]
Numbers the lines as they are typed, from the line given and in the steps given; 10 and 10 when neither is. An asterisk beside the number warns that a line already exists there.
BASEBASE(<number>) | BASE(<number>) = <addr>
Reads or moves one of the video chip’s tables in video RAM. The twenty numbers are five tables - name, colour, pattern, sprite attributes, sprite patterns - for each of the four screen modes in turn, so BASE(5) is SCREEN 1’s name table and BASE(10) SCREEN 2’s.
BEEPBEEP
The single click the machine makes on an error, played through the sound chip. Printing character 7 does exactly the same.
BIN$BIN$(<number>)
A number written as binary digits, with no leading marker. The matching literal form is &B.
BLOADBLOAD <filename>[, R][, <addr>]
Loads a machine-code file saved by BSAVE back to the addresses it came from, or that far past them when an offset is given; R runs it afterwards. Code blocks attached to a document are placed for you, so a program here rarely needs it.
BSAVEBSAVE <filename>, <addr>, <addr>[, <addr>]
Saves a range of memory as a binary file, its header carrying the start, the end and an optional entry address. A tape image holding one is reported on import rather than pasted into the editor as nonsense.
CALLCALL <extension>[(<arg>[, <arg>]…)]
Passes a statement to a cartridge or disc extension by name. It is not how machine code is run - that is DEF USR and USR - and with nothing fitted to answer, every name is a Syntax error.
CDBLCDBL(<number>)
Converts to double precision - fourteen digits in eight bytes, and what MSX BASIC calculates in when nothing says otherwise.
CHR$CHR$(<number>)
The character with that code. Codes below 32 are console commands rather than shapes - CHR$(12) clears the screen - and CHR$(1) is the prefix that prints one of their glyphs instead.
CINTCINT(<number>)
Converts to a sixteen-bit integer, truncating towards zero rather than rounding, and reporting Overflow outside -32768 to 32767. FIX truncates the same way without the range check.
CIRCLECIRCLE (<x>, <y>), <radius>[, <colour>[, <number>, <number>[, <number>]]]
Draws a circle or an arc centred on the point. The two optional angles are radians measured anticlockwise from three o’clock, and the argument after them is the aspect ratio, which flattens the circle into an ellipse.
CLEARCLEAR [<number>[, <addr>]]
Discards every variable. The first argument resizes the string space, which is only 200 bytes on a clean boot; the second lowers the top of memory, which is how a program reserves room for a machine-code routine.
CLOADCLOAD [<filename>]
Loads a tokenized program from cassette, the first one found when no name is given. The machine works the speed out as it reads, so a tape does not have to say which it was written at.
CLOSECLOSE [#<file>[, #<file>]…]
Closes an open file, or every open file when none is named. A file written to tape is not finished until it is closed.
CLSCLS
Clears the screen and homes the cursor. In SCREEN 2 and SCREEN 3 it clears the picture as well as the text.
CMDCMD <extension>
Hands a command to an extension ROM. Nothing here claims one, so it answers Illegal function call.
COLORCOLOR [<colour>][, <colour>][, <colour>]
Sets the foreground, background and border colours from the fixed sixteen (0 transparent, 1 black, 15 white). In SCREEN 1 there is one pair for the whole screen, so a COLOR statement recolours every character already on it.
CONTCONT
Resumes a program stopped by STOP, END or CTRL-STOP, at the statement after. Editing any line makes that impossible and the answer is Can’t CONTINUE.
COPYCOPY <filename> TO <filename>
Copies a file from one device to another. Illegal function call without a disc interface.
COSCOS(<number>)
The cosine of an angle in radians.
CSAVECSAVE <filename>[, <number>]
Saves the tokenized program to cassette under a name of up to six characters. The second argument is the speed - 1 for 1200 baud, 2 for 2400 - and 1200 is the default.
CSNGCSNG(<number>)
Converts to single precision - six digits in four bytes, which is what a literal short enough to fit is stored as.
CSRLINCSRLIN
The row the text cursor is on, counted from 0. POS gives the column.
CVDCVD(<string>)
Eight bytes out of a record buffer read back as a double-precision value.
CVICVI(<string>)
Two bytes out of a record buffer read back as an integer. MKI$ is the other direction.
CVSCVS(<string>)
Four bytes out of a record buffer read back as a single-precision value.
DATADATA <constant>[, <constant>]…
Inline constants for READ to consume in program order. The rest of the statement is stored exactly as typed, so a value holding a comma or a colon has to be quoted.
DEFDEF FN<name>[(<param>[, <param>]…)] = <expr> | DEF USR[<number>] = <addr>
Defines a single-expression function called through FN, or sets one of the ten USR entry points. DEF USR is how a BASIC program reaches machine code on this machine; CALL is not.
DEFDBLDEFDBL <letter>[-<letter>][, <letter>[-<letter>]]…
Makes every variable whose name begins with one of those letters double precision, keeping fourteen digits in eight bytes. This is what MSX BASIC uses when nothing says otherwise.
DEFINTDEFINT <letter>[-<letter>][, <letter>[-<letter>]]…
Makes every variable whose name begins with one of those letters a sixteen-bit integer. DEFINT A-Z at the top of a game is the usual first line: integer arithmetic is markedly faster than the double precision MSX BASIC otherwise uses.
DEFSNGDEFSNG <letter>[-<letter>][, <letter>[-<letter>]]…
Makes every variable whose name begins with one of those letters single precision, keeping six digits in four bytes.
DEFSTRDEFSTR <letter>[-<letter>][, <letter>[-<letter>]]…
Makes every variable whose name begins with one of those letters a string, unless the name carries a suffix of its own.
DELETEDELETE <line>[-<line>]
Removes a line, or a range of lines, from the program.
DIMDIM <var>(<number>[, <number>]…)
Declares an array and its bounds. Subscripts start at 0, so DIM A(10) has eleven elements; an array used without DIM is created with bound 10, and DIMming it afterwards is a Redimensioned array error.
DRAWDRAW <string>
Draws from a macro string: U, D, L, R and E, F, G, H move and draw a distance in one of eight directions, M moves to a point, C sets the colour, S the scale and A a rotation in quarter turns, while B prefixed to a move draws nothing and N returns to where the move started.
DSKFDSKF(<disc>)
Free clusters on a disc. Illegal function call on a machine with no drive.
DSKI$DSKI$(<disc>, <sector>)
Reads a disc sector into a string. Illegal function call here.
DSKO$DSKO$ <disc>, <sector>
Writes a buffer out to a disc sector. This machine has no drive, so it answers Illegal function call.
ELSEIF <number> THEN <statement>|<line> ELSE <statement>|<line>
The alternative branch of an IF. It is stored behind a colon the listing hides, which is why it can open what looks like a fresh statement and still belong to the IF before it.
ENDEND
Stops the program and returns to Ok without printing a message. It is not final: MSX BASIC leaves the same resume point STOP does, so CONT carries on at the statement after it.
EOFEOF(<file>)
True (-1) once a sequential file has nothing more to read, so a read loop knows to stop.
EQV<number> EQV <number>
Bitwise equivalence: a bit is set where the two operands agree, so 5 EQV 3 is -7. The complement of XOR, and rare outside this family.
ERASEERASE <var>[, <var>]…
Discards an array and the memory it held, so it may be DIMmed again with different bounds.
ERLERL
The number of the line the last error happened on, for an ON ERROR handler to report or branch on.
ERRERR
The code of the last error - the same number ERROR raises and the message table is indexed by.
ERRORERROR <number>
Raises the error with that code as though the interpreter had. Codes the machine does not use are free for a program’s own, and report Unprintable error when nothing traps them.
EXPEXP(<number>)
e raised to that power - the inverse of LOG.
FIELDFIELD #<file>, <length> AS <strvar>[, <length> AS <strvar>]…
Maps a random-access record buffer onto string variables. Random files need a disc, which this machine has none of, so it answers Illegal function call.
FILESFILES [<filename>]
Lists the files on a disc, matching a pattern when one is given. This machine has no drive, so it answers Illegal function call.
FIXFIX(<number>)
Truncates towards zero, so FIX(-1.5) is -1 where INT gives -2. Unlike CINT it keeps values beyond the integer range.
FNFN<name>[(<arg>[, <arg>]…)]
Calls a function DEF FN defined. The name follows FN with no space, and the DEF must have run before the call.
FORFOR <numvar> = <number> TO <number> [STEP <number>]
Opens a counting loop that runs to the matching NEXT. STEP sets the increment, which may be negative or fractional; the limit is tested at NEXT, so the body always runs at least once.
FPOSFPOS(<file>)
The byte position within an open file. It belongs to the disc ROM, so it answers Illegal function call here.
FREFRE(<expr>)
Free memory, and which pool depends on the argument’s type: FRE(0) is the bytes left in the program area and FRE("") the bytes left in the string space. The two are separate, and the string space is only 200 bytes until CLEAR grows it.
GETGET #<file>[, <record>]
Reads a record of a random-access file into the buffer FIELD mapped. Disc only, so on this machine it reports Illegal function call.
GOSUBGOSUB <line>
Calls the subroutine at a line number; RETURN comes back to the statement after.
GOTOGOTO <line>
Jumps to a line number. Unlike the Microsoft BASICs it descends from, MSX BASIC will not read GO TO as two words - the space is a syntax error.
HEX$HEX$(<number>)
A number written as hexadecimal digits, with no leading marker. The matching literal form is &H.
IFIF <number> THEN <statement>|<line> [ELSE <statement>|<line>]
Runs the consequent when the value is non-zero, and the ELSE part when it is zero. GOTO may stand in for THEN before a line number, and IFs may be nested along one line because each ELSE binds to the nearest IF.
IMP<number> IMP <number>
Bitwise implication: a bit is clear only where the left operand has it and the right does not, so 5 IMP 3 is -5.
INKEY$INKEY$
One character from the keyboard buffer without waiting, or the empty string when there is none. It never blocks, which is what makes it the read a game loop uses.
INPINP(<port>)
Reads a byte from a processor input port.
INPUTINPUT [<prompt>;] <var>[, <var>]… | INPUT #<file>, <var>[, <var>]…
Prints the prompt (or a question mark when there is none) and waits for a whole line to be typed. With a file number it reads the next comma-separated fields from an open file instead.
INSTRINSTR([<start>,] <string>, <string>)
The position of the second string inside the first, counting from 1, or 0 when it is not there. The optional first argument says where to start looking.
INTINT(<number>)
Rounds down to a whole number, so INT(-1.5) is -2. FIX truncates towards zero instead.
IPLIPL <string>
Sets the command the machine runs at the next reset. It belongs to the disc ROM, so it answers Illegal function call here.
KEYKEY <number>, <string> | KEY LIST | KEY ON | KEY OFF
Sets what one of the ten function keys types, lists them all, or shows and hides the strip along the bottom row. KEY OFF is usually the first thing a full-screen program does, since it gives that row back.
KILLKILL <filename>
Deletes a file from disc. Illegal function call on a machine with no drive.
LEFT$LEFT$(<string>, <length>)
The first n characters of a string.
LENLEN(<string>)
How many characters a string holds, 0 to 255.
LET[LET] <var> = <expr>
Assigns a value. The keyword is optional and almost always left out; it costs a byte of program text and nothing else.
LFILESLFILES [<filename>]
The FILES listing sent to the printer. Disc only, so it answers Illegal function call here.
LINELINE [(<x>, <y>)]-(<x>, <y>)[, <colour>[, B|BF]] | LINE INPUT [<prompt>;] <strvar>
Draws a straight line between two points, starting from the last point plotted when the first is left out; B draws the box with those two corners and BF fills it. The unrelated LINE INPUT reads a whole typed line, commas and all, into a string.
LISTLIST [<line>][-<line>]
Lists the program to the screen, all of it or the range given. The listing is regenerated from the tokens, so it comes back in the machine spelling rather than as it was typed.
LLISTLLIST [<line>][-<line>]
Lists the program to the printer. As with LPRINT there is no printer here, so it waits rather than reporting anything.
LOADLOAD <filename>[, R]
Loads a program from a device, tokenized or as an ASCII listing - the machine tells which from the first byte. R runs it as soon as it arrives, leaving any open files open.
LOCLOC(<file>)
The record last read or written. Disc only, so it answers Illegal function call here.
LOCATELOCATE [<col>][, <row>][, <number>]
Moves the text cursor. Both are counted from 0 and the column comes first, which is the other way round from most of this family. A third argument of 1 shows the cursor and 0 hides it.
LOFLOF(<file>)
The length of an open file in bytes. Disc only, so it answers Illegal function call here.
LOGLOG(<number>)
The natural logarithm, to base e. There is no base-10 logarithm; divide by LOG(10).
LPOSLPOS(<number>)
The column the printer head is at, as far as BASIC knows. The argument is a dummy.
LPRINTLPRINT [<expr>][;|,]…
Prints to the printer rather than the screen, taking the items PRINT does. No printer is fitted here and this is not an error: the machine waits for one that never answers, so a program reaching LPRINT stops until CTRL-STOP.
LSETLSET <strvar> = <string>
Places a string into a FIELD buffer variable, left-justified and padded or cut to the field width. Disc only here.
MAXMAXFILES = <number>
Reserves that many file buffers, 0 to 15, and clears every variable as it does so. Each buffer costs a few hundred bytes, so MAXFILES=0 is how a program that opens nothing takes the room back. The statement is stored as the MAX token followed by the FILES one, which is why it is listed here under MAX.
MERGEMERGE <filename>
Reads an ASCII listing into the program already in memory, each incoming line replacing one it collides with. A tokenized file cannot be merged; save it with the A option to get a listing.
MID$MID$(<string>, <start>[, <length>])
The substring starting at that position, counting from 1, of the given length or to the end. It also works on the left of an assignment, overwriting that part of a string in place without changing its length.
MKD$MKD$(<number>)
A double-precision value as eight bytes for a record buffer.
MKI$MKI$(<number>)
An integer as the two bytes a record buffer holds it in. CVI reads them back.
MKS$MKS$(<number>)
A single-precision value as four bytes for a record buffer.
MOD<number> MOD <number>
The remainder of an integer division. Both operands are converted to integers first and the sign follows the left one, so -7 MOD 2 is -1.
MOTORMOTOR | MOTOR ON | MOTOR OFF
Turns the cassette motor on or off, or reverses whichever it was when neither word is given. No recorder is modelled here, so it is accepted and does nothing.
NAMENAME <filename> AS <filename>
Renames a file on disc. Illegal function call on a machine with no drive.
NEWNEW
Erases the program and every variable with it.
NEXTNEXT [<numvar>[, <numvar>]…]
Closes the innermost FOR loop and jumps back to it. Naming the variable closes that loop specifically, and several may be closed in one statement.
NOTNOT <number>
Flips every bit of a sixteen-bit signed integer, so NOT 0 is -1. A true comparison is -1 here, every bit set, which is what makes this a working logical negation too.
OCT$OCT$(<number>)
A number written as octal digits, with no leading marker. The matching literal form is &O.
OFFKEY(<number>) OFF
Disarms an event trap. It follows KEY(n), INTERVAL, SPRITE, STOP and STRIG(n), where ON arms the trap and STOP holds it pending until ON comes back. It is also the second word of KEY OFF and MOTOR OFF.
ONON <number> GOTO <line>[, <line>]… | ON <number> GOSUB <line>[, <line>]…
Branches to the n-th line in the list (1 selects the first) and falls through when the value is 0 or past the end. ON ERROR GOTO sets an error handler, and ON KEY, ON SPRITE, ON STOP, ON STRIG and ON INTERVAL arm the event traps that call a subroutine when something happens.
OPENOPEN <filename> [FOR INPUT | FOR OUTPUT | FOR APPEND] AS #<file>
Opens a device or file on a number. The device prefix is what matters here: CAS: is the cassette, CRT: and LPT: the screen and the printer, and GRP: is how text is drawn on a graphics screen.
OR<number> OR <number>
Bitwise OR, so 5 OR 3 is 7.
OUTOUT <port>, <byte>
Writes a byte to a processor output port. The video chip is at ports &H98 and &H99 and the sound chip at &HA0 to &HA2, which is what VPOKE and SOUND are built on.
PADPAD(<number>)
A touch pad on one of the general-purpose ports, 0 to 7. Nothing is fitted here, so it reads 0.
PAINTPAINT (<x>, <y>)[, <colour>]
Fills the area around a point, stopping at pixels already that colour. It only fills what is enclosed, so a boundary with a one-pixel gap in it leaks into the rest of the screen.
PDLPDL(<number>)
A paddle position on one of the general-purpose ports, 1 to 12. No paddle is fitted here, so it reads 255.
PEEKPEEK(<addr>)
Reads a byte of processor memory. The screen is not in it: VPEEK reads video RAM.
PLAYPLAY <string>[, <string>[, <string>]]
Plays music macro strings, one per sound channel: A to G with # and - are notes, O sets the octave, L the note length, T the tempo, V the volume, S and M the envelope, and R rests. It returns at once and the music plays on underneath, so a game can start a sound and carry straight on.
POINTPOINT(<x>, <y>)
The colour of a pixel in SCREEN 2 or SCREEN 3, or -1 when the point is off the screen.
POKEPOKE <addr>, <byte>
Writes a byte to processor memory, addressed in decimal or as &H hexadecimal. It cannot reach the picture: the screen lives in the video chip’s own 16K, which only VPOKE writes.
POSPOS(<number>)
The column the text cursor is on, counted from 0. The argument is a dummy the interpreter ignores.
PRESETPRESET (<x>, <y>)[, <colour>]
Plots a point in the background colour, which is how a pixel is erased. Given a colour of its own it behaves exactly as PSET does.
PRINT?PRINT [<expr>][;|,]… | PRINT #<file>, <expr>
Prints to the screen; a question mark is shorthand for it. A semicolon runs the next item straight on, a comma moves to the next 14-column zone, and a trailing separator holds the newline back. In SCREEN 2 and SCREEN 3 it draws nothing at all and raises no error - text on a graphics screen goes through the GRP: device.
PSETPSET (<x>, <y>)[, <colour>]
Plots a point - 256×192 in SCREEN 2, 64×48 in SCREEN 3, with the origin at the top left. It also fixes the position the GRP: device prints text at.
PUTPUT SPRITE <plane>[, (<x>, <y>)][, <colour>][, <pattern>] | PUT #<file>[, <record>]
PUT SPRITE places one of the 32 sprite planes at a point in a colour, showing the shape SPRITE$ defined for it; an argument left out keeps what the plane already had. The unrelated file form writes a random-access record and needs a disc.
READREAD <var>[, <var>]…
Takes the next constant from the DATA statements, in program order. RESTORE winds the pointer back.
REM'REM <comment>
A comment to the end of the line. An apostrophe is shorthand for it, stored as a REM behind a colon the listing hides, so it may follow another statement on the same line.
RENUMRENUM [<line>[, <line>[, <number>]]]
Renumbers the program and rewrites every GOTO, GOSUB, THEN and RESTORE to match: the new first number, the old line to start renumbering at, and the step.
RESTORERESTORE [<line>]
Winds the DATA pointer back to the first constant in the program, or to the first in the line named.
RESUMERESUME [<line>|0|NEXT]
Returns from an ON ERROR handler: bare or 0 retries the statement that failed, NEXT carries on at the one after it, and a line number goes there. Outside a handler it is a RESUME without error.
RETURNRETURN [<line>]
Returns from a subroutine to the statement after the GOSUB. A line number goes there instead and forgets the call, which is how an event trap hands control to a chosen place.
RIGHT$RIGHT$(<string>, <length>)
The last n characters of a string.
RNDRND(<number>)
A random number from 0 up to but not including 1. A positive argument carries the sequence on, 0 repeats the number just given, and a negative one reseeds from that value - so RND(-TIME) is the usual way of starting somewhere unpredictable.
RSETRSET <strvar> = <string>
Places a string into a FIELD buffer variable, right-justified. Disc only here.
RUNRUN [<line>] | RUN <filename>[, R]
Clears the variables and starts the program, at the line named when one is given. Given a filename it loads that program first, so RUN"CAS:GAME" is load-and-go from tape.
SAVESAVE <filename>[, A]
Saves the program to a device. A writes an ASCII listing instead of the tokenized program, which is what MERGE reads and what another machine’s BASIC has some chance of accepting.
SCREENSCREEN [<mode>][, <number>]
Selects the display: 0 is 40×24 text, 1 is 32×24 text with colour, 2 is 256×192 graphics and 3 is 64×48 blocks. The second argument is the sprite size - 0 and 1 give 8×8, 2 and 3 give 16×16, and the odd numbers magnify - and three further arguments set the key click, the cassette speed and the printer type.
SETSET PASSWORD <string>
A disc option - the password a later SAVE writes. Illegal function call here, there being no drive.
SGNSGN(<number>)
-1, 0 or 1 according to the sign of the value.
SINSIN(<number>)
The sine of an angle in radians.
SOUNDSOUND <hwreg>, <byte>
Writes a byte straight to a sound chip register: 0 to 5 are the three tone periods, 6 the noise period, 7 the mixer, 8 to 10 the channel volumes and 11 to 13 the envelope. The noise channel can be reached no other way.
SPACE$SPACE$(<length>)
A string of that many spaces.
SPC(PRINT SPC(<number>)
Inside PRINT, emits that many spaces. Unlike TAB( it counts from wherever the print position already is.
SPRITESPRITE$(<pattern>) = <string> | SPRITE ON | SPRITE OFF
SPRITE$ defines a shape from eight bytes for an 8×8 sprite or thirty-two for a 16×16 one, which PUT SPRITE then places. The ON and OFF forms arm and disarm the collision trap ON SPRITE GOSUB sets, and SPRITE STOP holds it pending.
SQRSQR(<number>)
The square root. A negative argument is an Illegal function call.
STEPFOR <numvar> = <number> TO <number> STEP <number>
The amount a FOR loop adds each time round, which may be negative or fractional. Without it the step is 1.
STICKSTICK(<number>)
A direction: 0 for centred, then 1 to 8 clockwise from up, so 1 is up, 3 right, 5 down and 7 left. STICK(0) reads the cursor keys, STICK(1) and STICK(2) the two joystick ports.
STOPSTOP
Halts the program and reports Break in nn. CONT resumes at the following statement with every variable intact.
STR$STR$(<number>)
A number as the text PRINT would show, leading space for the sign and all. VAL is the other direction.
STRIGSTRIG(<number>)
A trigger: -1 while it is held and 0 otherwise. STRIG(0) is the space bar, 1 and 3 the first triggers of the two joystick ports, 2 and 4 their second triggers.
STRING$STRING$(<length>, <expr>)
A string of that many copies of a character, named either by its code or as the first character of a string.
SWAPSWAP <var>, <var>
Exchanges the values of two variables. They must be the same type; mixing them is a Type mismatch.
TAB(PRINT TAB(<col>)
Inside PRINT, moves the print position to that column, counted from 0. It only moves forwards.
TANTAN(<number>)
The tangent of an angle in radians.
THENIF <number> THEN <statement>|<line>
Introduces what an IF does when its test succeeds. A bare line number after it is a jump, so THEN 100 and GOTO 100 are the same thing.
TIMETIME | TIME = <number>
The interrupt counter, stepping once a frame - fifty times a second on this PAL machine - and wrapping at 65536. Assigning to it resets it, which is how a program times something without a clock.
TOFOR <numvar> = <number> TO <number> [STEP <number>]
The upper limit of a FOR loop, and the separator in COPY. Because keywords are recognised inside names, a variable may not contain it: TOTAL reads as TO followed by TAL.
TROFFTROFF
Stops the line-number trace TRON started.
TRONTRON
Prints each line number in square brackets as the program reaches it.
USINGPRINT USING <string>; <expr>[; <expr>]…
Formats output against a template: # is a digit position, . fixes the decimal point, a comma groups thousands, ** pads with asterisks, $$ floats a currency sign and ^^^^ selects exponent notation. For strings, ! takes the first character and a pair of backslashes makes a field as wide as the gap between them. The template repeats when there are more values than fields.
USRUSR[<number>](<arg>)
Calls the machine-code routine DEF USR set, passing one argument and returning whatever the routine leaves behind. The ten entry points are numbered 0 to 9, and a bare USR is USR0.
VALVAL(<string>)
The number a string begins with, or 0 when it does not begin with one. It reads &H, &O and &B literals as well as decimals.
VARPTRVARPTR(<var>)
The address of a variable’s value: two bytes for an integer, a three-byte descriptor for a string, four or eight for a float. VARPTR(#n) gives the address of an open file’s control block instead.
VDPVDP(<hwreg>) | VDP(<hwreg>) = <byte>
Reads or writes one of the video chip’s eight control registers. VDP(8) is the exception: it reads the status register, which carries the frame flag and the sprite collision and fifth-sprite bits.
VPEEKVPEEK(<addr>)
Reads a byte of video RAM - the video chip’s separate 16K, where the screen, the character shapes and the sprites all live.
VPOKEVPOKE <addr>, <byte>
Writes a byte to video RAM - the video chip’s own 16K, a second address space POKE cannot reach. Writing the name table directly is how an MSX program puts characters on screen faster than LOCATE and PRINT can.
WAITWAIT <port>, <mask>[, <mask>]
Reads an input port until the value, exclusive-ORed with the second mask and ANDed with the first, is non-zero. The program stops there until it is, so a mask that can never match is a hang.
WIDTHWIDTH <number>
Sets how many columns the text screen uses: up to 40 in SCREEN 0 and 32 in SCREEN 1. Neither starts at its maximum - this machine boots at 37 and 29 - so a program laying text out by column sets the width for itself.
XOR<number> XOR <number>
Bitwise exclusive OR: a bit is set where exactly one operand has it, so 5 XOR 3 is 6.
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
<constant>
a literal number or string, not an expression
<var>
a variable of either type
<numvar>
a numeric variable
<strvar>
a string variable
<letter>
a single letter
<line>
a line number
<statement>
one BASIC statement
<comment>
free text, to the end of the line
<name>
a name the program defines for a function or procedure
<param>
a parameter, where the definition introduces it
<arg>
a value, where the call passes it
<start>
the position something starts at, counting from 1
<length>
how many characters
<x>
a horizontal graphics coordinate
<y>
a vertical graphics coordinate
<col>
a text column
<row>
a text row
<mode>
a screen mode
<colour>
a colour, by number
<prompt>
text shown before the input; a literal, not an expression
<file>
an open file, by the number it was opened on
<filename>
the name of a file on tape or disc
<addr>
a memory address
<port>
an input/output port, by number
<mask>
a bit mask, one bit per item
<hwreg>
a hardware register, by number
<plane>
a sprite plane, 0 to 31
<pattern>
a sprite shape, by number
<radius>
the radius of a circle, in pixels
<record>
a record number in a random-access file
<disc>
a disc drive, by number
<sector>
a sector on a disc, by number
<extension>
the name of a cartridge or disc extension

Showing 177 of 177 keywords

What this machine does not run ​

The disc vocabulary is in the ROM of a machine that never had a drive. FILES, LFILES, KILL, NAME, COPY, SET, IPL, CMD, DSKI$, DSKO$, DSKF, ATTR$, FPOS, LOC and LOF all tokenize and all answer Illegal function call; FIELD, GET, PUT #, LSET and RSET want a disc for the same reason. They are in the table because the machine has them, not because they work.

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