Category:MSX-BASIC Instructions
This page was last modified 17:20, 29 May 2023 by Mars2000you. Based on work by Gdx and NYYRIKKI and others.

Below is a list of all standard MSX-BASIC instructions, that are not linked to a localisation (Arabic, Japanese, Korean), the presence or addition of a device such as a disk drive or a RS-232C interface, or the usage of a program that adds specific new instructions.

These instructions are classified according to their purpose. For a general overview of all instructions in alphabetical order (with exception for most reserved words), see this page : MSX-BASIC Instructions.

Generally, all instructions corresponding to a MSX generation will also work on the higher generations, but there are some exceptions, for example the instructions related to the data recorder will not work on a MSX turbo R.

Although the instructions added by MSX-BASIC 4.0 (MSX turbo R) begin with CALL, they are included in the standard MSX-BASIC instructions, even though they have a syntax typical of an extension.

For all the instructions that are not part of the standard MSX-BASIC instructions, first check this page: MSX-BASIC Extensions.

A few instructions are standard instructions while being at the same time linked to a specific MSX-BASIC extension. The most obvious case is COPY added by the Disk BASIC extension and also present on all MSX2 (and later) computers as a graphical instruction.

Contents

Arithmetic operators

Instruction Generation Function
- MSX1 Subtraction
+ MSX1 Addition
/ MSX1 Division
\ or ¥ or ₩ MSX1 Division without a digit after the decimal point in result
¥ is used on Japanese MSX instead of \
₩ is used on Korean MSX instead of \
* MSX1 Multiplication
^ MSX1 Root squared
MOD MSX1 Rest resulting of a division

Call/Return, Jump and Loop

Instruction Generation Function
FOR...NEXT MSX1 Sets up a loop in order to repeat several times a block of instructions
GOSUB MSX1 Calls a subroutine located on the specified line number
GOTO MSX1 Jumps to the specified line number and execute the instructions from there
RETURN MSX1 Returns from a subroutine that was invoked by GOSUB

Clock & Timing

Instruction Generation Function
CALL PAUSE MSX turbo R Stops execution of a BASIC program for the specified time
Short version: _PAUSE
INTERVAL MSX1 Changes the way BASIC timer interrupts are handled
GET DATE MSX2 Reads the date in the SRAM of the Real Time Clock (RTC)
GET TIME MSX2 Reads the time in the SRAM of the Real Time Clock (RTC)
ON INTERVAL GOSUB MSX1 Calls a subroutine after the specified timeout has been elapsed
SET DATE MSX2 Sets the date and saves it in the SRAM of the Real Time Clock (RTC)
SET TIME MSX2 Sets the time and saves it in the SRAM of the Real Time Clock (RTC)
TIME MSX1 Timer that is incremented by 1 on each time VDP completes screen draw

Conditions

Instruction Generation Function
< MSX1 Checks if the first argument is less than the second.
Returns -1 or 0 if true or false.
> MSX1 Checks if the first argument is greater than the second.
Returns -1 or 0 if true or false.
= MSX1 Checks if the first argument is equal to the second.
Returns -1 or 0 if true or false.
>= or => MSX1 Checks if the first argument is greater than the second or equal.
Returns -1 or 0 if true or false.
<= or =< MSX1 Checks if the first argument is less than the second or equal.
Returns -1 or 0 if true or false.
<> or >< MSX1 Checks if the first argument is diffent than the second.
Returns -1 or 0 if true or false.
NOT MSX1 Performs a bitwise NOT-operation (logical complement) on an expression
IF...GOTO...ELSE MSX1 Checks if a condition has been met to jump to number line specified after GOTO
IF...THEN...ELSE MSX1 Checks if a condition has been met to execute instruction(s) specified after THEN
ON...GOSUB MSX1 Can be used to branch execution to certain subroutine depending of condition
ON...GOTO MSX1 Can be used to branch execution to certain line depending of condition

Conversion Functions

Instruction Generation Function
ASC() MSX1 Returns the ASCII value of a character
BIN$() MSX1 Returns a string with the binary representation of a value
CDBL() MSX1 Converts a integer or simple precision value to a double precision value
CHR$() MSX1 Converts a value to the corresponding MSX character
CINT() MSX1 Converts a value to an integer number by truncating numbers after the decimal point
CSNG() MSX1 Converts a variable to a single precision number
HEX$() MSX1 Returns a string with the hexadecimal representation of a value
OCT$() MSX1 Returns a string with the octal representation of a value
STR$() MSX1 Returns a string representation of a numeric variable
VAL() MSX1 Returns the numerical value of the contents of a string

Data Storage

Instruction Generation Updates Related extensions / Remarks
BLOAD MSX1 Disk BASIC
BSAVE MSX1 Disk BASIC
CLOAD MSX1
CLOAD? MSX1
CLOSE MSX1 Disk BASIC, QuickDisk BASIC, MemoryDisk BASIC, RS-232C BASIC
CSAVE MSX1
EOF() MSX1 Data input function
LOAD MSX1 Disk BASIC, MemoryDisk BASIC, RS-232C BASIC
MAXFILES MSX1
MERGE MSX1 Disk BASIC, MemoryDisk BASIC, RS-232C BASIC
MOTOR MSX1
OPEN MSX1 Disk BASIC, QuickDisk BASIC, MemoryDisk BASIC, RS-232C BASIC
RUN MSX1 Disk BASIC, MemoryDisk BASIC
SAVE MSX1 Disk BASIC, MemoryDisk BASIC, RS-232C BASIC
VARPTR() MSX1 Data input function

Note: The Data Recorder support has been removed from the MSX turbo R.

Debugging

Instruction Generation Updates Related extensions / Remarks
CONT MSX1
FRE() MSX1
TROFF MSX1
TRON MSX1

Display

Instruction Generation Updates Related extensions / Remarks
BASE MSX1 MSX2, MSX2+ Instruction for VDP experts
CIRCLE MSX1
CLS MSX1 Delta BASIC
COLOR MSX1 MSX2, MSX2+ Kanji BASIC, Hangul BASIC
COLOR= MSX2
COPY MSX2 It is the standard MSX2 instruction
It must not be confused with the COPY instruction added by the Disk BASIC
COPY SCREEN MSX2 Optional, can be used only on machines with an internal or external digitizer
CSRLIN MSX1
DRAW MSX1
LINE MSX1 MSX2
LOCATE MSX1 Delta BASIC
LPOS() MSX1 Data input function
OPEN MSX1
PAINT MSX1
POINT MSX1 Data input function
POS() MSX1 Data input function
PRESET MSX1 MSX2
PRINT or ? MSX1
PSET MSX1 MSX2
PUT KANJI MSX2 Related to Kanji BASIC
SCREEN MSX1 MSX2, MSX2+ Hangul BASIC, Kanji BASIC
SET ADJUST MSX2 Related to Real Time Clock (RTC)
SET PAGE MSX2
SET SCROLL MSX2+
SET VIDEO MSX2 Optional, can be used only on machines with an internal or external digitizer
SPC() MSX1
TAB() MSX1
VDP() MSX1 MSX2, MSX2+ Instruction for VDP experts
VPEEK() MSX1 MSX2 Data input function
VPOKE MSX1 MSX2
WIDTH MSX1 MSX2 Hangul BASIC, Kanji BASIC

Error Treatment

Instruction Generation Updates Related extensions / Remarks
ERL MSX1
ERR MSX1 Disk BASIC, Delta BASIC
ERROR MSX1 Disk BASIC, Delta BASIC
ON ERROR GOTO MSX1

Input/Output Bus

Instruction Generation Updates Related extensions / Remarks
INP() MSX1 Data input function
OUT MSX1 Data output function
WAIT MSX1 Data input function

Keyboard and/or Controllers

Instruction Generation Updates Related extensions / Remarks
CALL ADJUST MSX2 Short version: _ADJUST
Only on MSX2 computers manufactured by Daewoo
Maybe also available with the Sanyo MPC-X Graphic Expander Unit
and the Sanyo MPC-27 computer
Enables the V9938 light-pen interface
INKEY$ MSX1 Data input function
INPUT MSX1
INPUT$() MSX1 Data input function
KEY MSX1
KEY() MSX1
LINE INPUT MSX1
OPEN MSX1
ON KEY GOSUB MSX1
ON STOP GOSUB MSX1
ON STRIG GOSUB MSX1
PAD() MSX1 MSX2 Data input function, Light Pen support removed on MSX turbo R
PDL() MSX1 Data input function, Paddle controllers support removed on MSX turbo R,
these devices are unused on MSXPLAYer.
STICK() MSX1 Data input function
STRIG() MSX1 Data input function

Logical operators

Instruction Generation Updates Related extensions / Remarks
AND MSX1
EQV MSX1
IMP MSX1
NOT MSX1
OR MSX1
XOR MSX1

Mathematical Functions

Instruction Generation Updates Related extensions / Remarks
ABS() MSX1
CDBL() MSX1
CINT() MSX1
CSNG() MSX1
EXP() MSX1
FN MSX1
FIX() MSX1
INT() MSX1
LOG() MSX1
RND() MSX1
SGN() MSX1
SQR() MSX1

New Basic Instructions/Machine Language Functions

Instruction Generation Updates Related extensions / Remarks
CALL or _ MSX1 Instruction for machine language experts
DEF USR MSX1
USR() MSX1 Data input function

Printer

Instruction Generation Updates Related extensions / Remarks
LLIST MSX1
LPRINT MSX1
OPEN MSX1

Programming

Instruction Generation Updates Related extensions / Remarks
 : MSX1 Separator between two instructions
AUTO MSX1
DELETE MSX1
ELSE MSX1
END MSX1
LIST MSX1
NEW MSX1
REM or ' MSX1
RENUM MSX1
RESUME MSX1
STOP MSX1

Prompt

Instruction Generation Updates Related extensions / Remarks
SET BEEP MSX2 Related to Real Time Clock (RTC)
SET PASSWORD MSX2 Related to Real Time Clock (RTC)
SET PROMPT MSX2 Related to Real Time Clock (RTC)
SET SCREEN MSX2 Related to Real Time Clock (RTC)
SET TITLE MSX2 Related to Real Time Clock (RTC)

RAM Access

Instruction Generation Updates Related extensions / Remarks
PEEK() MSX1 Data input function
POKE MSX1
VARPTR() MSX1 Data input function

Sound and Music

Instruction Generation Updates Related extensions / Remarks
BEEP MSX1 MSX2
CALL PCMPLAY MSX turbo R Short version: _PCMPLAY
CALL PCMREC MSX turbo R Short version: _PCMREC
PLAY MSX1 MSX-AUDIO BASIC, MSX-MUSIC BASIC
PLAY() MSX1
SOUND MSX1 Instruction for PSG experts

Sprites

Instruction Generation Updates Related extensions / Remarks
COLOR SPRITE() MSX2
COLOR SPRITE$() MSX2
ON SPRITE GOSUB MSX1
PUT SPRITE MSX1 MSX2
SPRITE MSX1
SPRITE$() MSX1

String Handling

Instruction Generation Function
INSTR() MSX1 Returns position of first occurrence of a substring in a string, this from a specified position
LEN() MSX1 Returns the length of a string, including all non-printable characters
LEFT$() MSX1 Returns a string corresponding to a number of the leftmost characters from an original string
MID$() MSX1 Returns a string corresponding to a number of characters from an original string,
this from a specified position - Can also replace a substring by another string
RIGHT$() MSX1 Returns a string corresponding to a number of the rightmost characters from an original string
SPACE$() MSX1 Generates a string with a specified number of spaces
STRING$() MSX1 Returns a string with a variable length, all containing either the same character,
which is defined as an ASCII code or the first character of a string

Trigonometric Functions

Instruction Generation Function
ATN() MSX1 Returns the arctangent of a variable
COS() MSX1 Returns the cosine of a variable in radians
SIN() MSX1 Returns the cosine of a variable in radians
TAN() MSX1 Returns the tangent of a variable

Variables Setting

Instruction Generation Function
= MSX1 Defines a variable - see LET
CLEAR MSX1 Clears the contents of all variables and arrays, closes all open files
DATA MSX1 Stores data in a program (e.g. graphics), to be read with READ
DEFDBL MSX1 Defines a variable or a range of variables as double precision
DEF FN MSX1 Defines a function which returns user-specified output based on optional variables
DEFINT MSX1 Defines a vriable or a range of variables as integer
DEFSNG MSX1 Defines a variable or a range of variables as single precision
DEFSTR MSX1 Defines a variable or a range of variables as string.
DIM MSX1 Reserves memory for the specified variables and initializes the array(s)
ERASE MSX1 Frees memory by erasing one or more arrays
LET MSX1 Assigns a value to a specified variable
Optional instruction, can be omitted
READ MSX1 Returns next value(s) that has been stored in the program source by using DATA
RESTORE MSX1 Sets the line number where READ instruction can read next value
SWAP MSX1 Exchanges the contents of two variables

Reserved Words

Most of these reserved words are used in Disk BASIC.

Instruction Generation Function
ATTR$() MSX1 Without diversion, returns "Illegal function call"
CMD MSX1 Without diversion, returns "Illegal function call"
COPY MSX1 Returns "Illegal function call" on diskless MSX1
Do not confuse with the graphical COPY instruction added on MSX2
CVD() MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
CVI() MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
CVS() MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
DSKF() MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
DSKO$ MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
FIELD MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
FILES MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
FPOS() MSX1 Without diversion, returns "Internal error"
GET MSX1 Instruction works, but is useless on diskless MSX1
IPL MSX1 Without diversion, returns "Illegal function call"
KILL MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
LOC() MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
LOF() MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
LSET MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise.
MKD$() MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
MKI$() MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
MKS$() MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
NAME MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
PUT MSX1 Instruction works, but is useless on diskless MSX1
(except when combined with SPRITE)
RSET MSX1 Used in Disk BASIC, returns "Illegal function call" otherwise
SET MSX1 Returns "Illegal function call" on MSX1