OSI 6502 BASICv1.0 UsersManual
OSI 6502 BASICv1.0 UsersManual
I I _____...............___
\
\,
,\ ~•'""• .Ca - •· S •0
OSI 6502 8K BASIC VERSION l .0
l
The single user license is for one version of BASIC., i.e., if the
user has BK BASIC for cassette, he will still have to pay full price
for BK Disk BASIC.
2
SPECIAL CHARACTERS
Character Use
@ Erases line being typed
(shift 0) Erases last character being typed
Carriage return Must be used after each line typed
Control C Interrupts program execution or listing
returns to command mode.
: (colon) Allows multiple statements per line
Contol 0 Typing a control O once surpresses output
until another control O is typed.
? ? can be used instead of print.
out a variable can be used when FOR-NEXT statements are not nested.
ENO statements are not necessary. Question marks can be used
instead of PRlNI 11LET is optional. No spaces are required in
11 • 11 11
EXAMPLES:
LEGAL ILLEGAL
A IA
Al #8
AZ TOO
BEQ RGOTO
APPLE NEW l
TUESDAY FREQUENCY
Note: that variables AZl and AZ2 would be treated the same since
BASIC looks only at the first two characters .
• 3
COMMANDS
• NAME
LIST
EXAMPLE
LIST
LIST 100
COMMENTS
Lists program
Lists program from line 100. Control
C stops program listing at end of
current line.
NULL NULL 3 Inserts 3 nulls at the start of each
line to eliminate change return
bounce problems. Null should be O lfi\
when entering paper tapes from Teletyp~
readers. When punching tapes Nu1~=3.
Higher settings are required on faster
mechanical terminals.
RUN RUN Starts program execution at first line.
All variables are reset. Use an
immediate GOTO to start execution at
a desired 1ine.
RUN 200 GOTO 200 with variables reset.
NEW NEW Deletes current program.
CONT CONT Continues program after Control C or
4t STOP if the program has not been modified.
For instance a STOB followed by manually
printing out variables and then a CONT:
is a useful procedure in program debugg-
ing.
LOAD LOAD Used in cassette and Disk BASIC only.
OPERATORS
SYMBOL EXAMPLE COMMENTS
= A=lO LET is optional
LET 8=10
C=-B Negation
1' (Shift/n) X-t4 X to the 4th power
CtD with C negative and D not an integer
gives an FC error.
* C=A*B Multiplication
I D=L/M Division
+ Z=L+M Addition
4
J=255.l-X Subtraction
• <>
>
<
10 IF A<>B THEN 5
B>A
B<A
Not equal
B greater than A
B less than A
< =, =< B<,,A B less than or equal to A
=>,::>= B=>A B greater than or equal to A
AND IF B>A AND A>C
THEN 7 If both expressions are true then--.
OR IF B>A OR A>C
THEN 7 If either expression is true then--.
NOT IF NOT B'>A THEN 7 If B<=A then--.
AND, OR, and NOT can also be used in Bit manipulation mode for per-
formin9 Boolean operations of 16 bit 2s complement numbers (-32768 to
+32767)
EXAMPLES
EXPRESSION RESULT
63 AND 16 16
-1 AND 8 8
4 OR 2 6
l O OR l 0 10
NOT 0 -1
NOT l -2
OPERATOR EVALUATION RULES: Math statements evaluated from left to
right with* and/ evaluated before+ and -
Parentheses explicitly determine order of
evaluation.
Precedence for evaluation
l ) By pa renthese
2) 1'
3) Negation
4) * I
5) + -
6) =,<>, <,>, <=, >=
7) NOT
8) AND
9) OR
•
5
-
STATEMENTS
In the fa 11 owing examples
V or Wis "a numeric variable, X is a numeric expression,
X$ is a string expression, I or J is a truncated integer.
NAME EXAMPLE COMMENTS
DATA 10 DATA 1,3, 7 Data for READ statements must
be in order to be ~ad. Strings
may be read in DATA statements.
DEF 10 DEF FNA (V)=V*B User defined function of one
argument.
DIM 110DIMA(l2) Allocates space for Matrices
and sets all matrix variables
to zero. Non dimensioned
variables default to 10.
END 999 END Terminates program (optional)
FOR, NEXT l O FOR x= . l to l O STEP ol STtP is needed only if Xis
2v----- not incremented by l. NEXT X
30 NEXT X is needed only if FOR NEXT
loops are nested if not NEXT
alone can be used variables
and functions can be used in
FOR statements.
GOTO 50 GOTO l 00 Jumps to line 100
GOSUB, RETURN 100 GOSUB 500 Goes to subroutine, RETURN
500 . . . . goes back to next line number
600 RETURN after the GO SUB
IF .•. THEN
10 If X=5 THEN 5 If the statement is true
10 If x=5 THEN PRINT X
10 If X=5 THEN PRINT X:Y=Z Then the following will be
executed including multiple
statements of that line.
IF ... GOTO
10 I Ir X=5 GOT05 Same as if THEN with line
number )
ON ... GOTO
100 ON I GOTO 10, 20, 30 Computed GOTO
If I=l then 10
If 1=2 then 20
If 1=3 then 30
6
PRINT 10 PRINT X Prints value of expression
20 PRINT Test
11 11 Standard BASIC syntax with
, ; formats
11
7
POS ( I) Gives current location of terminal print
head .
• SPC (I)
STRINGS
Prints I spaces, can only be used in print
statements.
Strings can be from Oto 255 characters long. All string variables
end in$ ex. A$,B9t HELLO$.
Strings can be dimensioned equated, printed,. r.ead from Data statements,
etc.
STRING FUNCTIONS
ASC (X$) Returns ASCll value of first character in
string.
CHR$ ( I) returns a I character string equivalent
the ASCII value above.
LEFT$ (X$,I) Gives left most I characters of string X$
RIGH1$ (X$, I) Gives right most I character of string X$
. MID $ (X$,I ,J) Gives string subset of string X$ starting
at 1th character for J characters. If J is omitted,
goes to end of string.
LEN (X$) Gives length of string in bytes.
STR$ (X) Gives a string which is the character
representation of the numeric expression
of X. Example X=3.l
X$=STR$(X)
X$= 3.1
11 11
a
8
1/0
The following features of OSI BK BASIC are usefull primarily for
I/0 control. The user should be extremely careful with these state-
ments and functions since they manipulate the memory of the computer
directly. An improper operation with any of these commands can
cause a system crash, wiping out BASIC and the users program, thus
requiring a complete reload of the computer .
.
STATEMENT/FUNCTI'ON COMMENT
PEEK (I) Returns the decimal value of the
specified memory or 1/0 location.
(Decimal)
Example:
X=PEEK (64256)
Loads variable X with the 430 Board's
A/D converter output. (FBOOhex)
POKE I ,J Loads memory location I (decimal) with
J (Decimal) I must be between O and
65536 and J must be between O and 255
Example: 10 Poke 64256, 255 loads FBOO
with FF (Hex) thus loads the 430 Board's
D/A port Osuch that its output is +2
volts.
WAIT I,J,K Reads status of memory location I
(Decimal) exclusive OR's with K then
AND's the result with J until a non
zero result is obtained. If K is omit-
ted, it is zero.
Wait is used for fast service of input
status flags.
Example: Wait X,l will wait until Bit
zero of memory location X goes low then
BASIC will continue.
The high speed servicing of flags via the WAIT command allows the
programmer to service medium speed devices such as line printers .or
industrial equipment directly in BASIC.
USR: The USR function allows linkage to machine language routines
such as ultra-fast device handlers, etc. The USR function calls
only one machine language routine and can pass one integer value to the
machine language routine so that 65,000 actual user routines are possible.
The beginning of the user subroutine must be poked into 23Ehex (low)
and 23Fhe~ {high). The USR routine can use up to 8 levels of sub-
routines ll6 stack locations) without page swapping.
The USR function can obtain the argument of the function by cal ling
the routine pointed to by 6 (low) and 7 (high). This routine will
9
place the value of the argument in AE(hex) (high part) and AF(hex)
• (low part). To pass a value back to BASIC, the high part is placed
in A and the low part is placed in Y and the subroutine pointed to
by 8 and 9 should be called. If this function is not called USR
(X) will equal X. An RTS returns from USR to BASIC. All registers
can be modified by the user routine without affecting BASIC, however,
no page zero locations can be modified! The POKE instruction can
also be used to change the USR function call.
INTERRUPTS
For Interrupting routines of any significant length, page zero and
page one should be swapped out to higher memory, or memory partition-
ing (A16 and A17 on late model OSI memory-boards) should be used.
BASICs have MAT functions which will have to be rewritten with FOR-
NEXT loops.
10
OSI 6502 8K BASIC ERROR MESSAGES
ERROR CODE MEANING
BS Bad Subscript: Matrix outside DIM
statement range, etc.
DD Double Dimension: Variable dimensioned twice.
Remember subscripted variables default to
dimension 10.
FC Function Call error: Parameter passed to
function out of range.
ID Illegal Direct: Input or DEFIN statements can
not be used in direct mode.
NF NEXT without FOR:
OD Out of Data: More reads than DATA
OM Out of Memory: Program too big or too many GOSUBs,
FOR NEXT loops or variables. ·
ov Overflow: Result of calculation too large for .
BASIC
• SN
RG
us
Syntax error: Typo, etc.
RETURN without GOSUB.
Undefined Statement: Attempt to junp to non-
existant line number.
/0 Division by Zero.
CN Continue errors: Attempt to inappropriately
continue from BREAK or STOP.
LS Long String: String longer than 255 characters.
OS Out of String Space: Sarne as OM
ST String Temporaries: String expresssion too complex.
TM Type Mismatch: String variable mismatched to
numeric variable.
Uf Undefined Function.
11
OPERATING INSTRUCTIONS: AUDIO CASSETTE VERSION
BASIC will now return its prompter 11 0K 11 and can be used as any stand-
ard on-line BASIC.
The display width can be adjusted by poking a new constant into the
CRT output routine. Example: "POKE 8745, 22 reduces the 1 ine
11
turn the tape on and return. Typing any key will now transfer
command back to the keyboard, so when the load is complete type
return. BASIC wi 11 report an SN error when it reads the 11 0K 11 at
the end of the tape, so just ignore it.
12
OPERATING INSTRUCTIONS: PAPER TAPE VERSION
Ol 2E l F3F" then G 11 11 •
10. BASIC will ask memory size. If you do not require any
memory reserved for machine language routines simply type
return and BASIC will use all available memory. On
teletypes type return when BASIC asks "TERMINAL WIDTH".
BASIC will now return its prompter 11 0K 11 and can be used as any stand-
ard on-line BASIC.
Punching out a Program!
When you are ready to punch a program, set null for 3 using the
immediate mode by typing "Null 3 then return. Then generate some
11
leader off line. With the punch off and the terminal on line type
LIST then turn the punch on, then type return. BASIC will list
11 11 ,
0 Then place the BASIC program tape in the reader and turn it on.
11 •
13
You can optionally type control O just before turning on the
reader to surpress output. BASIC will report an 11 SN error 11 when
it reads the OK at the end of the tape. Simply ignore this.
If a reset occurs from BASIC you may be able to re-enter it by
11 L Ol2E0000 11 then 11 R11 then 11 G11 • If the stack has been disturbed
by another program or extensive use of the monitor, this will not
be possible and BASIC may be damaged by attempting to warm start
it. It is always safe to cold start BASIC from the monitor at
1F3F by 11 L 012E 1F3F 11 , then 11 R11 , then 11 G11 • However, any program in
BASIC will be lost.
,.
14