Last edited · 21 revisions  

 


 

Basic/02 Compiler

Basic/02 is a Basic cross-compiler that emits 1802 code.  So far compilations of the compiler have been produced that run on the Linux and Windows operating systems.

Several members have produced compilations of the Basic 1802 cross-compiler that run on Windows.  Please use the following links to download the actual exe files from two of those members who have provided their work in the files section.

https://groups.io/g/cosmacelf/files/Hank%20Riley

https://groups.io/g/cosmacelf/files/Glenn%20Jolly

https://github.com/fourstix/Basic-02/releases

 

See https://github.com/rileym65  for current information on the Linux version.

 

Example compile command line:

sbc -l -L -c -fp -b -ram=0000-7FFF -rom=8000-FFFF -elfos TestAsm.bas

 

ASM

CHDIR "dirname"

CLOSE #filenum

CLS

DATA number,number,...

DEALLOC addr

DELETE "filename"

DMA expr

DPOKE addr,value

END

FOR var=expr TO expr [STEP expr]

FREAD #filenum address,length

FWRITE #filenum address,length

GET #filenum var,...

GOSUB line

GOTO line

IDLE

IF expr THEN statement

INPUT ["prompt",]var[,var][,var][,...]

INTR line

IOFF

ION

[LET] var=expr

LOCATE y,x

MKDIR "dirname"

NEXT [var]

ON expr GOSUB line,line,...

ON expr GOTO line,line,...

OPEN "filename" FOR INPUT|OUTPUT|APPEND AS #filenum

OUT port,value

POKE addr,value

POS #filenum position

PRINT expr[,;]expr[,;]...

PUT #filenum var,...

Q expr

READ var,var,...

REM text

RENAME "filename" TO "filename"

RESTORE [line]

RETURN [line]

RMDIR "dirname"

 

Expressions:

+

-

*

/

%

&

|

^

=

<>

<

>

<=

>=

$hexnum

ABS(expr)

ALLOC(expr)

ACOS(expr)

ASIN(expr)

ATAN(expr)

CINT(expr)

COS(expr

CSNG(expr)

DPEEK(addr)

EOF(filenum)

EXP(addr)

FLG(expr)

FRE(addr)

INP(port)

LN(expr)

PEEK(addr)

POS(filenum)

RND(range)

SGN(expr)

SIN(expr)

SQRT(expr)

TAN(expr)

 

System variables:

DATA_        - Address of DATA pointer

FREE_        - Address of free RAM

LFSR_        - MSW of 32-bit LFSR RND seed

LFSR__       - LSW of 32-bit LFSR RND seed

 

 

*ISTART

*IRETURN

 

  

File I/O Variables:

IOFLAG

IORESULT

The file I/O commands will set global variables IOFLAG and IOSTAUS based upon the results of the I/O calls.   IOFLAG will have the value of DF resulting from the Elf/OS kernel call and when non-zero, indicates an error has occurred.  When IOFLAG is nonzero, then IORESULT will contain the error code returned by the Elf/OS kernel (Value from D).  For FREAD and FWRITE, if IOFLAG=0 (no error occurred) then IORESULT will contain the number of bytes read/written, for all other calls IORESULT is undefined if IOFLAG=0.

 

Variables:

Variable names can be more than 1 character, but must start with a letter

and then must consist of either upper or lowercase letter or numbers or the

underscaore (_) character.  Case is irrelevant.

 

Varaibles are stored either at the specified address, else the first byte

in RAM after the program (if program is compiled for RAM) else the first byte

of RAM.

 

Notes:

Multiple statements on a line are supported, statements must be separated

by the colon (:) character.

 

Line numbers must be greater than 0 and less than 65536 and must appear

in order.

 

All other numbers are 16-bit signed integers (unless -32 or -fp is used).

 

if term=none then PRINT and INPUT will not produce any code, nor will they

produce errors during compile.

 

if term=bios then terminal i/o expects the Elf/OS BIOS to be present at

its normal address.

 

if term=self then terminal i/o functions will be added to the output file

producing a fully self-contained program that has no external dependencies

 

In general whitespace is ignored and can be used as desired for legibility.

 

A single line number must be contained on a single input line.  Each input

line is currently limited to 2048 character.

 

Compiler Directives:

.1805           - Enable 1804/5/6 assembler mode

.32             - Enable 32-bit mode

.binary         - Output file as binary

.fp             - Enable floating-point mode

.elfos          - Produce Elf/OS executable

.list           - Show source list

.nolist         - Turn off source list

.noruntime      - Do not show runtime modules

.nosymbols      - Do not show assembler symbols

.novars         - Do not show variables

.options        - Show options in effect

.runtime        - Show runtime modules

.symbols        - Show assembler symbols

.vars           - Show variables

 

Command Line Switches:

-32             - compile in 32-bit mode

-fp             - enable floating point

-a              - produce assembly file

-A              - display assembly

-b              - output as binary

-c              - show compiler output

-i              - output as Intel hex

-l              - show source list

-L              - create .lst file

-o              - show options in effect

-r              - output as RCS hex

-R              - show runtime modules

-s              - show assembler symbols

-v              - show variables

-lf             - set line endings to line-feed

-cr             - set line endings to carriage-return

-lfcr           - set line endings to line-feed/carriage-return

-crlf           - set line endings to carriage-return/line-feed

-nq             - normal Q for internal serial port

-rq             - reverse Q for internal serial port

-ef?            - Set EF line for internal serial port (?=1-4)

-ref?           - Set reverse EF line for internal serial port (?=1-4)

-ram=start-end  - set ram address range

-rom=start-end  - set rom address range

-start=hex      - Set start address

-exit=hex       - Set address to jump to on exit

-vars=hex       - Start of variable table

-stack=hex      - set address for top of stack

-estack=hex     - set address for top of expression stack

-heap=hex       - set address for top of heap

-keybuf=hex     - size of key buffer

-term=bios      - use BIOS terminal i/o (default)

-self                  - use internal serial i/o

-none                 - no terminal

-elfos          - produce an Elf/OS executable

-stg            - produce STG compatible image (sets -exit=8003)

-melf           - -ram=0000-7fff -rom=8000-ffff -nq -ef2

-pev            - -ram=0000-7fff -rom=8000-ffff -nq -ef2

-pev2           - -ram=0000-7fff -rom=8000-ffff -rq -ref2

-elf2k          - -ram=0000-7fff -rom=8000-ffff -nq -ef3

-mclo           - -ram=0000-7fff -rom=8000-ffff -nq -ef3

-mchi           - -ram=8000-ffff -rom=0000-7fff -nq -ef3

-mchip          - -ram=8000-ffff -rom=0000-7fff -rq -ref3