Altair8800 Simulator

MBasic commands and statements

Command Description

Command Description
AUTO Generate auto line number after each
AUTO [<line number>[,<increment>]]
CALL Call assembly language subroutine CALL <variable name>[(<arg list>)]
CHAIN Call a program and pass variables
CHAIN [MERGE] <filename>[,[<line #>] [,ALL] [,DELETE<range>]]
CLEAR Clear variables to zero/null, set memory end and amount of stack space.
CLEAR [,[<exp1>][,<exp2>]]
CLOAD[?|*] Load program from cassette
? – verify against prgm in memory
* - load array into variable
CLOSE Close disk file
CLOSE
COMMON Pass variables to CHAINed program
COMMON <list of variables>
CONT Continue program after Control-C, STOP or END CSAVE Save program to cassette
CSAVE <filename> (only first char is used)
DATA Store constants accessed by READ statement
DATA <list of constants>
DEF FN Define a user specified function
DEF FN<name>[(<params>)]=<function def>
DEF<type> Declare variable types beginning with a range of letters as a specific type
DEF<type> <range of letters>
Where type is INT, SNG, DBL, or STR<
DEF USR Specify starting address of assembly subroutine DEF USR[<digit>]=<integer expression>
DELETE Delete program lines
DELETE [<line number>][-<line number>]
DIM Specify maximum size of array variable
DIM <list of variables>
EDIT Edit a specified line
EDIT <line number>
END Terminate program execution. ERASE Eliminate arrays from a program.
ERASE <list of array variables>
ERR/ERL Variable containing error code and line number
IF ERR = <error code> THEN ….
ERROR Simulate error code or trap for error
ON ERROR GOTO … Trap error ERROR 15 Generate error code 15
FIELD Allocate space for variables in a file buffer
FIELD [#]<file number>, <field width> AS <string variable>
>FOR..NEXT Loop
FOR <var> = X to Y [STEP z] NEXT [<var>][,<var>…]
GET Read a record from a random disk file
GET [#]<file number>[,<record number>]
GOSUB Branch to subroutine
GOSUB <line number>
… RETURN
GOTO Unconditional Branch
GOTO <line number>
IF/THEN/ELSE Conditional branch
IF <exp> THEN <statement(s)> | <line #> [ELSE <statement(s)> | <line #>
INPUT Input from terminal device
INPUT[;][<”prompt”>;]<list of vars>
INPUT# Read data from sequential file
INPUT#<file#>, <vars>
KILL Delete file from disk.
KILL <filename>
LET Assign value to variable
[LET] <var>=<exp>
LINE INPUT Input up to 254 chars without delimiters
LINE INPUT[;][<”prompt”>;]<string var>
LINE INPUT# Read entire line from sequential file
LINE INPUT#<file#>, <string var>
LIST List all or part of program in memory
LIST [<line#>[-<line#>]]
LLIST List current program to line printer
LLIST [<line#>[-<line#>]]
LOAD Load file from disk, .BAS extension assumed
LOAD <filename>[,R]
R option runs program after load
LPRINT Print data on the line printer device
LPRINT [<list of expr>]
LPRINT USING <string exp>;<list of expr>
LSET/RSET Move data from memory and a file buffer in Preparation for a PUT statement
LSET left-justifies, RSET right-justifies LSET <str var>=<str expr>
RSET <str var>=<str expr>
MERGE Merge a specified disk file with pgm in mem MERGE <filename>
MID$ Replace part of one string with another
MID$(<str exp1>,n[,m])=<str exp2>
NAME Change name of a disk file
NAME <old fname> AS <new fname>
NEW Delete current program, clear vars
NULL Set number of nulls to be printed after NewLine
ON ERROR Enable error trapping
ON ERROR GOTO <line #>
ON..GOSUB Branch on expression value
ON..GOTO ON <expr> GOTO/GOSUB <list of line #s>
OPEN Open a disk file for I/O
OPEN <mode>,#<file#>,<filename>[,<reclen>]
OPTION BASE Specify min value of an array index OPTION BASE n (n= 0 or 1)
OUT I,J Send byte J to machine port I
OUT <port>, <byte>
POKE Write a byte to a memory location
POKE <memory locn>,<byte>
PRINT[#} Print on the terminal
PRINT USING PRINT <list of expr>
PUT Write record from random buffer to disk
[#]<file#>,[,<record #>]
RANDOMIZE Reseed random number generator
RANDOMIZE [<expr>]
READ Read values from DATA statement READ <vars>
REM or ‘ Remark
RENUM Renumber program lines.
RENUM [[<new #>][,[<old #>][,<increment>]
RESTORE Reset Data statements to a specified point
RESTORE [<line#>]
RESUME Continue execution after error
RESUME [0 | NEXT | <line#>]
RUN RUN <filename> [,R] – R doesn’t clear vars RUN [<line#>] start execution at line #
SAVE Save program to disk SAVE <filename>[,A | ,P]
A: ASCII FORMAT, P: Encoded format
STOP Terminate program execution E
SWAP Exchange value of two variables SWAP <var1>,<var2>
SYSTEM Return to CP/M
TRON/TROFF Trace execution for debugging
WAIT Suspend execution until pattern on input port WAIT <port#>, I[,J]
J if specified, is XORd with I
WHILE/WEND Loop while condition is true WHILE <expr>… WEND
WIDTH Set line width for line printer WIDTH [LPRINT] <integer expr
WRITE[#] Output to terminal or file with commas WRITE [<list of expr>]

MBASIC FUNCTIONS

Function Description
ABS(X) Absolute Value
ASC(X$) ASCII Numerical value of a character ATN(X) Arctangent of X in radians
CDBL(X) Convert X to double-precision CHR$(I) Convert ASCII value I to character CINT(X) Convert X to integer
COS(X) Cosine of X in radians
CSNG(X) Convert X to single-precision
CVI,CVS,CVD Convert string to Integer, Single, Double EOF(file#) Returns true if end of seq file reached
EXP(X) Returns e^X
FIX(X) Returns integer portion of X (does not round)
FRE(X) Returns number of free bytes
FRE(““) Forces garbage collection
HEX$(X) Returns string with hex value of X
INP(I) Returns byte read from port I
INPUT$(X) INPUT(X[,[#]Y]) Returns string of X chars from terminal or file
INSTR INSTR([I,],X$,Y$) – returns pos where Y$ is found in X$, starting from position I
INT(X) Returns largest integer <=X
LEFT$(X$,I) Returns string with leftmost I chars of X$ LEN(X$) Returns number of chars in X$
LOC(<file>) Returns next record to be used by GET/PUT
LOG(X) Returns natural log of X
LPOS(X) Returns current position of line printer head
MID$(X$,I,J) Returns string of J chars from X from pos I
MKI$,MKS$, Convert numeric to string. MKI: 2-bytes, MKS, MKD$ 4-bytes, MKD: 8-bytes
PEEK(I) Returns byte read from memory loc I
POS(I) Returns current cursor position
RIGHT$(X$,I) Returns I rightmost chars of X$
RND[(X)] Returns random number between 0 and 1
  SGN(X) If X>0 returns 1, =0 returns 0, <0, returns -1
SIN(X) Returns sine of X in radians
SPACE$(X) Returns a string of X spaces
SPC(I) Prints I spaces on terminal
SQR(X) Returns square root of X
STR$(X) Returns string representation of X
STRING$(I,J) Returns string of len I of chars with ASCII J
TAB(I) Spaces to position I on terminal
TAN(X) Returns tangent of X in radians
USR Calls user assembler subroutine
VAL(X$) returns numeric value of X$
VARPTR(vn) Returns memory address of variable name OR Starting address of disk I/O buffer

Control Characters

Key Function
^A Edit mode on current line
^C Interrupt program execution
^O Halts output, execution continues
^R Retypes current line
^S Suspend execution
^Q Resume execution
^U Delete current line
ESC Exit edit mode
← 8080 Instruction set↑ Altair8800 Simulator