Orwell Documentation

April 11th, 2014

Below is the documentation for ORWELL. Unfortunately WordPress messes up the formatting from the original document and I can’t be bothered redoing it all here! But all the text is here below.

 

 

ORWELL

An 8 bit personal computer running BASIC.

 

 

Overview

Orwell is a home made 6502 processor based machine. It has 16K of RAM, 32K of ROM and a 6522 VIA and a 6551 ACIA on the main CPU board as well as an additional 8 bit writable latch with debugging LEDs attached.

 

Composite video output is via Grant Searle’s ATMega based video board and is black and white only Text is in either 80×25, 40×25, 80×12, 40×12 modes. Graphics are 160 x 100 resolution.

 

Audio output is via a small amplifier and an internal speaker driven off a VIA PWM pin to allow the generation of simple tones. It is possible to connect an external amplifier if required.

 

An additional IO daughter board provides an analogue 2 axis joyport and extra IO capability (16 bits GPIO and 4 special).

 

 

Hardware

 

RAM/ROM

RAM is provided by a HM62256 32K SRAM with only the first 16K addressable. ROM is a 27C256 EPROM.

 

Keyboard

The keyboard is an old surplus Ti99/4 keyboard which is scanned using the 6522 VIA. The same VIA also drives the video board and audio output.

 

Sound

Simple sounds can produced by the VIA using the timer on PB7. Values are poked into the Timer 1 low and high latches directly. The sound is run through a small audio amplifier to an internal speaker. An external audio jack allows sending the sound to external devices.

 

Serial

The 6551 ACIA is used for serial communications running at 19200:8,N,1 with RTS/CTS hardware flow control.

 

IO board

The IO daughter board add two additional 6522 VIAs. One is set up to continuously read two ADC0804 analog to digital converters and provide push button support to allow an analog joystick to be connected.

 

Joystick

The push buttons are connected to the LSB of the ports (the LSB from the ADC is dropped). When pressed the value read from each ADC will be even. When not pressed the value from each ADC will be odd. This allows the user to perform a simple AND with 1 to check the button state.

Losing the LSB doesn’t affect the reading too much as the bottom bit is the one most affected by jitter. Losing that 1 bit of accuracy doesn’t make much practical difference for a simple joystick control.

 

Power on reset

The daughter board also provides a power on reset function (using a simple 555 timer) to provide a clean reset on start-up removing the need to manually reset the machine.

 

The second VIA is wired as a general purpose IO port providing 16 bits of general IO in two 8 bit ports (VIA port a and b). The 4 extra control signals (CA1,2 and CB1,2) are also routed to this port.

 

 

Memory map

RAM is addressed from $0000 $3FFF, IO is from $4000 to $7FFF and ROM from $8000 to $FFFF.

 

The detailed memory map is as follows:

 

$FFFF – $FFFE: ROM (IRQ)

$FFFD – $FFFC: ROM (Reset vector)

$FFFB – $FFFA: ROM (NMI)

$FFF0 – $8000: ROM (32K)

$6000: 8 bit latchable IO port (with LEDs)

$500F – $5000: 6522 VIA1 (keyboard and video)

$4803 – $4800: 6551 ACIA (serial comms)

$440F – $4400: 6522 VIA 2 (joystick port, 2 analog values and 2 buttons)

$420F – $4200: 6522 VIA3 (general IO port)

$3FFF – $0000: RAM (16K)

 

 

Software

Orwell is running a custom built version of Microsoft BASIC from 1978. I started with the Ohio Scientific code and have modified it to suit the Orwell hardware, adding commands as necessary. The keyboard and video control code is custom written. The start-up routines have been simplified (terminal width and memory size questions removed).

 

Commands added to BASIC

 

 

Font and Graphics controls

Video output is using Grant Searle’s video board as described here: http://searle.hostei.com/grant/MonitorKeyboard/index.html

 

The general purpose registered mentioned above are used for controlling text and graphics.

 

To change the font enter a value in the c val register then call FONT. The value is a number controlling the text attributes as follows:

 

Bit 2 = double height

Bit 1 = bold

Bit 0 = 80 columns

 

Video modes

40 Character normal = 0x000 = 0

80 Character normal = 0x001 = 1

40 Character bold = 0x010 = 2

80 Character bold = 0x011 = 3

40 Character normal double-height = 0x100 = 4

80 Character normal double-height = 0x101 = 5

40 Character bold double-height = 0x110 = 6

80 Character bold double-height = 0x111 = 7

 

The default startup value is 40 column bold double height (as this is best on small LCD screens).

 

Standard ASCII is implemented for the main character set. Extended ASCII codes are implemented the same as for DOS. Control codes are standard ASCII where applicable – other codes added to allow control of the screen. The full implementation is shown below:

 

Video display control codes

Hex (Decimal) and meaning

01 (01) – Cursor home (Standard ASCII)

02 (02) – Define cursor character (2nd byte is the curs character, or 00 to turn off) <–New for 3.0

03 (03) – Cursor blinking

04 (04) – Cursor solid

05 (05) – Set graphics pixel (next two bytes = x,y) <–New for 3.0

06 (06) – Reset graphics pixel (next two bytes = x,y) <–New for 3.0

08 (08) – Backspace (Standard ASCII)

09 (09) – Tab (Standard ASCII)

0A (11) – Linefeed (Standard ASCII)

0C (12) – Clear screen (Standard ASCII)

0D (13) – Carriage return (Standard ASCII)

0E (14) – Set column 0 to 79 (2nd byte is the column number) or 0 to 39 for a 40 char line

0F (16) – Set row 0 to 24 (2nd byte is the row number)

10 (16) – Delete start of line

11 (17) – Delete to end of line

12 (18) – Delete to start of screen

13 (19) – Delete to end of screen

14 (20) – Scroll up

15 (21) – Scroll down

16 (22) – Scroll left

17 (23) – Scroll right

18 (24) – Set font attribute for the current line (see elsewhere on this page for details) <–New for 3.0

1A (26) – Treat next byte as a character (to allow PC DOS char codes 1 to 31 to be displayed on screen)

1B (27) – ESC – reserved for ANSI sequences

1C (28) – Cursor right

1D (29) – Cursor Left

1E (30) – Cursor up

1F (31) – Cursor down

20 (32) to 7E (126) – Standard ASCII codes

7F (127) – Delete

80 (128) to FF (255) – PC (DOS) extended characters

So, to print “Hello” at column 18, row 10 on the monitor in BASIC would be as follows:

PRINT CHR$(14) ; CHR$(17) ; CHR$(15) ; CHR$(9) ; “HELLO”

 

Character set

The character set is using the DOS character set (http://en.wikipedia.org/wiki/Code_page_437). Any printable character can be set as the cursor by putting it’s decimal value into c_val and calling SETCUR.

 

 

8K BASIC manual

 

Special characters

 

@ Erases the line being typed.

FCTN <- Erase the last character.

CTRL-C Stop program execution. Get out of LOAD and BINARY modes.

: Allow multiple statements per line.

? Can be used instead of PRINT.

 

BASIC properties

 

FOR-NEXT statements that aren’t nested don’t need the variable after NEXT.

 

A colon (:) can be used to concatenate statements onto one line.

 

A semi-colon (;) after a PRINT will append the next text to the same line.

 

LET is optional.

 

Instructions can be run from within a BASIC program or directly from the command line.

 

Spaces are generally optional!

 

BASIC variables

 

Variables can be 2 characters long and must be unique. Longer variables can be used but only the first two letters matter.

 

The first character must be a letter. The second may be a letter or number.

 

Long variable names can’t contain BASIC keywords.

 

BASIC commands

 

LIST

 

Lists a program or parts of a program by linenumber.

 

LIST ; Lists the entire program.

LIST 110 ; List line 110.

LIST 110-140 ; List lines between 100 and 140 inclusive.

 

 

NULL

 

Inserts null characters at the beginning of a line. Apparently used for punched tape machines to prevent carriage return bounce!

 

NULL 3 ; Insert 3 NULLS before a line.

 

RUN

 

Runs the BASIC program in memory. Can be used with a line number to start execution at that line. All variables are reset when RUN is used.

 

RUN ; Start execution at the first line found in memory.

RUN 100 ; Start execution at line 100.

 

NEW

 

Deletes the current BASIC program. This only removes BASIC programs. Data loaded through the BINARY command is unaffected.

 

 

CONT

 

Continues execution of a program stopped with CTRL-C or the STOP command if the program has not been modified.

 

LOAD

 

Load mode enables input via the serial port rather than the keyboard. Data is received at 19200,8,N,1 with RTS/CTS flow control enabled.

 

To exit loading a CTRL-C can be sent from the keyboard or from the file being loaded itself. A CTRL-C character (0x3) appended to the BASIC file being loaded will automatically exit load mode after uploading the code.

 

Entering and exiting load mode will generate an audible beep.

 

BINARY

 

Binary mode is to allow data to be written directly into memory at a given location. This is useful for loading large amounts of data or ASM code.

 

The address to load into is poked into locations $65 (101) and $66 (102), LSB first. During binary loading the IO LEDs will indicate the LSB count of the data loaded.

 

Exiting binary mode must be done with a CTRL-C entered from the keyboard.

 

Entering and exiting binary mode will generate an audible beep.

 

To binary load data to location $0800 (2048) in RAM:

POKE 101, 0 ; LSB address.

POKE 102, 8 ; MSB address.

BINARY

 

When data is loaded press CTRL-C to exit.

 

To see how many bytes were transferred look at locations $316 (790) and $317 (791), LSB first.

 

10 B = PEEK(791)*256 ; Get MSB of count.

20 T = B + PEEK(790) ; Get LSB of count.

30 PRINT T;

40 PRINT “ BYTES LOADED”

 

SAVE

In save mode data is output to both the screen and the serial port. Data is sent at 19200,8,N,1 with RTS/CTS flow control enabled.

 

Save mode can be used with a terminal program to record entered programs and outputs.

 

To exit save mode the command NORMAL must be entered. Entering and exiting save mode will generate an audible beep.

 

NORMAL

 

The normal command will exit from save mode and stop the output from being sent to the serial port.

 

CLS

 

Clears the screen and returns the cursor to the top lefthand corner.

 

MOVE

 

Moves the cursor to the point given in x_val, y_val.

 

POKE 784, 5 ; X value.

POKE 785, 7 ; Y value.

MOVE

 

SETCUR

 

Sets the cursor based on the value specified in c_val. Values are based on the DOS code page 437 character set (see above).

 

POKE 783, 2 ; 2 = Smiley face.

SETCUR

 

GET

 

The get command will return the value of a key pressed at that exact instant into a variable. To check if a key was returned the length of the variable is checked. A length of zero indicates no key is being pressed.

 

10 GET A$

20 IF LEN(A$) <> 0 THEN GOTO 100

30 GOTO 10

100 PRINT A$;

110 PRINT “ WAS PRESSED”

120 GOTO 10

 

FONT

 

Change the current video font into one of the 8 modes given above. The value is passed into c_val.

 

POKE 783, 1 ;80 column, other values given above

FONT

 

PLOT

 

Plots a single point on screen at the location given in x_val, y_val and the colour in c_val (0=black, 1=white).

 

10 CLS ; Clear the screen.

20 POKE 783, 1 ; Colour white.

30 POKE 784, 10   ; X point.

40 POKE 785, 10   ; Y point.

PLOT

 

LINE

 

Draws a line between X1Y1 and X2Y2. Values are given in x_val, y_val, a_val and b_val. Colour in in c_val (0=black, 1=white).

 

 

10 CLS

20 POKE 783, 1 ; Colour white.

30 POKE 784, 10 ; X1 point.

40 POKE 785, 10 ; Y1 point.

50 POKE 786, 50 ; X2 point.

60 POKE 787, 50 ; Y2 point.

70 LINE

 

RECT

 

Draws a rectangle between X1Y1 and X2Y2. Values are given in x_val, y_val, a_val and b_val. Colour in in c_val (0=black, 1=white).

 

10 CLS

20 POKE 783, 1 ; Colour white.

30 POKE 784, 10 ; X1 point.

40 POKE 785, 10 ; Y1 point.

50 POKE 786, 50 ; X2 point.

60 POKE 787, 50 ; Y2 point.

70 RECT

 

CIRCLE

 

Draws a circle centred on x_val, y_val. Radius is given in a_val. Colour in in c_val (0=black, 1=white).

 

10 CLS

POKE 783, 1 ; Colour white.

POKE 784, 45 ; X centre point.

POKE 785, 45 ; Y centre point.

POKE 786, 25 ; Radius.

CIRCLE

 

BASIC symbols

 

Symbols, like BASIC commands, can be used in direct mode. For example typing:

PRINT 2^3

 

Will output 8.

 

= ; Assignment symbol, e.g. A=10, LET B=20 (LET command optional).

; Negation, subtraction, e.g. C=-B, 6-2 = 4.

^ ; Power, e.g. 2^3 = 8.

* ; Multiplication, e.g. 2*3 = 6.

/ ; Division, e.g. 6/3 = 2

+ ; Addition, e.g. 2+3 = 5

<> ; Not equal to, e.g. IF A<>B THEN GOTO 5 (A not equal to B).

> ; Greater than, e.g. IF A > B THEN GOTO 5 ( A greater than B).

< ; Less than, e.g. IF A < B THEN GOTO 5 (A less than B).

<=, =< ; Less than or equal to.

>=, => ; Greater than or equal to.

AND ; Logical AND, e.g. IF B<A AND A>C THEN GOTO 5 (Both true).

OR ; Logical OR, e.g. IF B<A OR A>C THEN GOTO 5 (Either true).

NOT ; Logical NOT, e.g. IF NOT A>B THEN GOTO 5 (A<=B).

 

AND, OR and NOT can also be used as bitwise manipulations on 16 bit, 2s complement numbers (-32768 to 32767) directly, e.g.

 

PRINT 63 AND 16 ; 16

PRINT -1 AND 8 ; 8

PRINT 4 OR 2 ; 6

PRINT 10 OR 10 ; 10

PRINT NOT 0 ; -1

PRINT NOT 1 ; -2

 

Evaluation order and precedence

 

States are evaluated left to right on the following order of precedence. Parenthesis can be used for explicit grouping.

 

  1. Parenthisis
  2. ^
  3. Negation
  4. *, /
  5. +, –
  6. =, <>, <, >, <=, >=
  7. NOT
  8. AND
  9. OR

 

BASIC Statements

 

In the following examples V or W is a numeric variable, X is a numeric expression, x$ is a string value and I or J is a truncated integer.

 

DATA

 

Data to be read, in order, by a READ statement. Data can include strings.

 

10 DATA 1, 3, 7

 

DEF

 

User defined function with one argument.

 

10 DEF FNA (V)=V*B

 

DIM

 

Allocated space for matrices and sets all values to 0. The array contains 1 element more than the amount passed in as arrays are indexed from 0 to the number! Undimensioned variables will default to a size of 10.

 

100 DIM A(5) ; A is an array of 6 values.

 

Reference elements in arrays with brackets.

 

100 PRINT A(0)

 

END

 

Terminates a BASIC program. This is optional.

 

FOR, TO, NEXT, STEP

 

Basic loop. STEP can optionally be used if the increment isn’t in values of 1. The variable can be omitted from the NEXT statement if the loop isn’t nested. Variables and function may be used in FOR statement.

 

10 FOR X=1 TO 10 STEP

20 PRINT X;

30 NEXT X ; X here is option in un nested loop.

 

10 FOR Y=.1 TO 10 STEP .1

20 PRINT Y;

30 NEXT Y ; Y here is option in un nested loop.

 

GOTO

 

Jump to another line number.

 

100 GOTO 50 ; Jump to line 50.

 

GOSUB, RETURN

 

Go to a subroutine. On RETURN the program resumes from the line after the GOSUB.

 

100 GOSUB 500

500

510 RETURN

 

IF, THEN

 

If the condition is true perform the next statement. If there are multiple statements on one the line they are all executed.

 

IF X=5 THEN 100 ; Goes to line 100.

IF X=5 THEN PRINT X ; Prints X.

IF X=5 THEN PRINT X: PRINT Y ; Prints X and Y.

 

IF, GOTO

 

Behaves the same as an IF, THEN but will GOTO the given line number.

 

IF X=5 GOTO 100 ; Goes to line 100 if X = 5.

 

ON, GOTO

 

Computed GOTO. Compares a variable then will GOTO multiple locations based on the value of that variable.

 

100 ON I GOTO 100, 200, 300 ; If I=1 GOTO 100, I=2 GOTO 200, I=3 GOTO 300.

 

PRINT

 

Output a value to the screen.

 

10 PRINT X ; Prints the value of variable X.

20 PRINT “X” ; Prints the character X.

 

READ

 

Reads data consecutively from data statements in the program.

 

400 READ V,W ; V is set to the 1st data value, W to the second.

 

REM

 

Remarks. Comments in the BASIC code.

 

10 REM IGNORE THIS LINE!

 

RESTORE

 

Restores initial values of all DATA values.

 

STOP

 

Stops program execution. Execution can be started again with CONT if the code hasn’t been modified.

 

Functions

 

ABS(X)

 

Absolute value.

 

10 PRINT ABS(-10) ; Prints 10.

 

INT(X)

 

Largest integer less than X.

 

10 PRINT INT(9.999) ; Prints 9.

 

RND(X)

 

Generate a random number between 0 and 1. RND(0) generates the same number always. RND(X) will generate the same sequence of random numbers for a given X.

 

10 PRINT RND(6) ; Prints .493982

20 (8-5)*RND(1)+5 ; Prints a random number between 5 and 8.

 

SGN(X)

 

Returns 1 if the value is greater than 0. 0 if the value is 0 and -1 if the value is negative.

 

10 PRINT SGN(-12) ; Prints -1

20 PRINT SGN(0) ; Prints 0.

30 PRINT SGN(12) ; Prints 1.

 

SIN(X), COS(X), TAN(X), ATN(X)

 

Trigonometric functions where X is in radians.

 

SQR(X)

 

Returns the square root of X.

 

10 PRINT SQR(9) ; Prints 3.

 

USR(X)

 

User defined function. The USR function vector is at $A. This contains a hard coded JMP instruction. The address that the USR function will call must be poked into location $0B (11) and $0C (12), in the order LSB, MSB.

 

The assembly user function then starts at the address given. To return from the USR function a RTS command is issued.

 

For a USR function at $0800 (2048) in memory doing the following:

 

LDA #$AA ; Load $AA into the accumulator (10101010 in binary).

STA IO ; Display the value on the debug LEDs (IO = $6000).

RTS ; Return.

 

We need the following code:

 

10 POKE 2048, 73 ; LDA instruction, $49 = 73.

20 POKE 2049, 170 ; Value to store, $AA = 170.

30 POKE 2050, 141 ; STA instruction, $8D = 141.

40 POKE 2051, 0 ; LSB of address to store at, $00 = 0.

50 POKE 2052, 96 ; MSB of address to store at, $60 = 96.

60 POKE 2053, 96 ; RTS instruction, $60 = 96.

 

To access this code when then set up the address and call the USR function at $0800 (2048).

 

100 POKE 11, 0 ; LSB of USR function location, $00 = 0.

110 POKE 12, 8 ; MSB of USR function location, $08 = 8.

 

120 X=USR(0)

 

This will call the assembly routine to display 10101010 on the debug LEDs then return.

 

TBD (addresses to be found):

The argument passed in is put into the FAC.

To return a 2 byte integer is to be returned the CONVERT FAC TO INT code is called.

To return a floating point value the 2 byte integer value is put into A and Y the the FLOAT SIGNED INTO A,Y code is called.

 

EXP(X)

 

e to the power of X where e = 2.71828

 

FRE(X)

 

Returns the amount of free bytes for BASIC left in the RAM space.

 

LOG(X)

 

Returns the natural log of X.

 

10 LOG(X)/LOG(10) ; Will return base 10 log of X.

 

TAB(I)

 

Positions the print head to X.

 

POS(I)

 

Returns the position of the print head.

 

SPC(I)

 

Print I spaces in PRINT statements.

 

Strings

 

Strings may be from 0 to 255 characters long.

All string variables end in $, e.g. A$, NAME$.

Strings can be dimensioned, equated, printed and read from data statements.

 

BASIC String functions

 

ASC(A$)

 

Returns the ASCII value of the first character in the string.

 

10 PRINT ASC(“HELLO”) ; Prints 72.

 

CHR$(I)

 

Returns the 1 character string for the given ASCII value.

 

10 PRINT CHRS(72) ; Prints H.

 

LEFT$(A$,I), RIGHT(A$,I)

 

Returns the left/right most I characters of string A$.

 

10 PRINT LEFT$(“HELLO WORLD”, 5) ; Prints HELLO.

 

MID$(A$,I,J)

 

Returns the characters in the string from position I for J characters. If J is omitted characters to the end of the string are returned.

 

10 PRINT MID$(“HELLO WORLD”, 2, 4) ;Prints ELLO.

 

LEN(A$)

 

Returns the length of the string in bytes.

 

10 PRINT LEN(“HELLO WORLD”) ; Prints 11.

 

STR$(X)

 

Returns a character representation of the given value.

 

10 X = 3.141

20 x$ = STR$(X)

30 PRINT X$ ; Prints 3.141.

 

VAL(X$)

 

Returns a numeric variable of the given string.

 

10 X$ = ”3.141”

20 X =  VAL(X$)

30 PRINT X ; Prints 3.141.

 

BASIC Special functions

 

PEEK(I)

 

Returns a decimal value of the data stored at the decimal location given.

 

10 X = PEEK (17408) ; Reads the value of the X axis of the joystick.

20 PRINT X ; Prints the value.

 

POKE I,J

 

Loads decimal memory location I with the decimal value J.

 

10 POKE 24576, 170 ; Sends value 170 (10101010 binary) to the IO LEDs.

 

WAIT I,J,K

 

Reads the decimal value of decimal memory location I then exclusive ORs the value with K then ANDs the result with J until the result is not zero.

If K is omitted it will wait until the result is zero.

 

Used to handle hardware inputs.

 

10 X = PEEK (17408) ; Reads the value of the X axis of the joystick.

20 PRINT X ; Prints the value.

30 WAIT 17408, 1 ; Wait until

 

Code examples

The following are some code snippets. These can be entered in direct mode or in BASIC code. The text after the ; is comments to make this easier to understand. This text isn’t part of the command! Values for PEEK and POKE are in the range 0-255 since this is an 8 bit computer.

 

To output to the LEDs:

POKE 24576, ?

 

To make sounds:

POKE 20484, ?

POKE 20485, ?

 

To stop the sound:

POKE 20484, 0

POKE 20485, 0

 

To check for a key press:

GET A$

IF LEN(A$) <> 0 THEN … ; If length is zero no key is being pressed.

 

To read the joyport (returns 0..255 odd or even values depending on button state):

X = PEEK (17408) ; X axis (port a on the VIA)

B = X AND 1 ; Check lowest bit

IF B = 0 THEN … ; 0 = button pressed, 1 = button not pressed

 

To read the joyport (returning a 0..127 continuous range):

X = PEEK (17408) ; X Axis.

X1 = INT(X/2) ; Convert to a 1..127 value with no gaps

 

To read the general IO ports as inputs:

PEEK (16896) ; Read port b

PEEK (16897) ; Read port a

 

To change the general IO port to input or output (1 indicates output):

POKE 16898, 255 ; Port b ddr, all outputs

POKE 16898, 0 ; Port b ddr, all inputs

POKE 16899, 255 ; Port a ddr, all outputs

POKE 16899, 0 ; Port a ddr, all inputs

 

To change the general IO port a to be 0..4 input, 5..7 outputs:

POKE 16899, 240 ; Port a ddr in binary 1111000

 

To set bits 5..7 above to on:

POKE 16897, 240 ; Port a in binary 1111000

 

To set bits 5..7 above to off:

POKE 16897, 0 ; Port a in binary 0000000

 

To load raw binary data into memory at location $0800 (2048):

POKE 101, 0 ; LSB

POKE 102, 8 ; MSB

BINARY

 

After load completes hit CTRL-C on keyboard then read how many bytes were copied:

B = PEEK(791)*256 ; Get MSB of count.

TOT = B + PEEK(790) ; Get LSB of count.

 

Appendix A: Peek and poke values

 

USR jmp 10 ($0A)

USR lsb 11 ($0B)

USR msb 12 ($0c)

 

BINARY Address lsb 101 ($65)

BINARY Address msb 102 ($66)

 

c_val 783 ($30F)

x_val 784 ($310)

y_val 785 ($311)

a_val 786 ($312)

b_val 787 ($313)

 

BINARY Count lsb 790 ($316)

BINARY Count msb 791 ($317)

 

 

IO port B     16896 ($4200)

IO port A     16897 ($4201)

IO ddr B 16898 ($4202)

IO ddr A 16899 ($4203)

IO timer 1 low 16900 ($4204)

IO timer 1 high 16901 ($4205)

IO acr     16907 ($420B)

IO pcr     16908 ($420C)

IO ifr     16909 ($420D)

IO ier     16910 ($420E)

 

Joy X axis 17408 ($4400)

Joy Y axis 17409 ($4401)

 

Beeper high tone 20484 ($5004)

Beeper low tone 20485 ($5005)

 

IO LEDs 24576 ($6000)

 

Appendix B: BASIC symbols

 

= ; Assignment symbol, e.g. A=10, LET B=20 (LET command optional).

; Negation, subtraction, e.g. C=-B, 6-2 = 4.

^ ; Power, e.g. 2^3 = 8.

* ; Multiplication, e.g. 2*3 = 6.

/ ; Division, e.g. 6/3 = 2

+ ; Addition, e.g. 2+3 = 5

<> ; Not equal to, e.g. IF A<>B THEN GOTO 5 (A not equal to B).

> ; Greater than, e.g. IF A > B THEN GOTO 5 ( A greater than B).

< ; Less than, e.g. IF A < B THEN GOTO 5 (A less than B).

<=, =< ; Less than or equal to.

>=, => ; Greater than or equal to.

AND ; Logical AND, e.g. IF B<A AND A>C THEN GOTO 5 (Both true).

OR ; Logical OR, e.g. IF B<A OR A>C THEN GOTO 5 (Either true).

NOT ; Logical NOT, e.g. IF NOT A>B THEN GOTO 5 (A<=B).

 

AND, OR and NOT can also be used as bitwise manipulations on 16 bit, 2s complement numbers (-32768 to 32767) directly, e.g.

 

Appendix C: BASIC keywords summary

 

DATA

DEF

DIM

END

FOR, TO, NEXT, STEP

GOTO

GOSUB, RETURN

IF, THEN

IF, GOTO

ON, GOTO

PRINT

READ

REM

RESTORE

STOP

 

LIST ; List program lines.

NULL ; Insert nulls before lines.

RUN ; Run a BASIC program.

NEW ; Clear all program memory.

CONT ; Continue.

LOAD ; Load via serial port.

BINARY ; Binary load into memory.

SAVE ; Output via serial port.

NORMAL ; Stop save mode.

CLS ; Clear the screen and home cursor.

MOVE ; Move the cursor.

SETCUR ; Set the cursor.

GET ; Get the currently pressed key.

FONT ; Set the font.

PLOT ; Plot a point.

LINE ; Draw a line.

RECT ; Draw a rectangle.

CIRCLE ; Draw a circle.

 

ABS(X) ; Absolute value.

INT(X) ; Integer value.

RND(X) ; Random number between 0 and 1.

SGN(X) ; Sign of a number.

SIN(X) ; Trigonometric functions.

COS(X)

TAN(X)

ATN(X)

SQR(X) ; Square root.

EXP(X) ; Exponential.

FRE(X) ; Free memory remaining.

LOG(X) ; Natural log.

TAB(I) ; Position print head.

POS(I) ; Return position of print head.

SPC(I) ; Print spaces.

 

ASC(A$) ; ASCII value of character.

CHR$(I) ; Character value of ASCII.

LEFT$(A$,I) ; Left substring.

RIGHT(A$,I) ; Right substring.

MID$(A$,I,J) ; Mid substring.

STR$(X) ; String version of number.

VAL(X$) ; Numeric version of string.

 

PEEK(I) ; Peek into memory.

POKE I,J ; Poke into memory.

WAIT I,J,K ; Wait for event.

USR(X) ; User function.

 

 

Appendix D: BASIC error messages

 

Error messages are returned as a 2 character message:

 

NF ; Next without for.

SN ; Syntax error.

RG ; Return without gosub.

OD ; Out of data.

FC ; Illegal quantity.

OV ; Overflow.

OM ; Out of memory.

US ; Undefined statement.

BS ; Bad subscript.

DD ; Re-dimensioned array.

/0 ; Division by zero.

ID ; Illegal direct.

TM ; Type mismatch.

LS ; String too long.

ST ; Formula too complex.

CN ; Can’t continue.

UF ; Undefined function.

 

 

Comments are closed.