-
11/2/23 Update
11/02/2023 at 16:05 • 0 commentsDavid Madole, Gaston Williams, Al Williams and others have been fixing bugs and improving Mike Riley's diskless Elf/OS system. I replaced the earlier version 1.4 file with the latest version 1.7.2, which includes all the latest changes to the various programs. I also updated the 10/8/23 Project Log to document the changes made to the programs in this version 1.7.2 ROM.
Chuck Yakym made some improvements to the standard MemberChip Card system ROM. I replaced the earlier MC20ANSA.BIN file with the new version, and edited the MemberChip Card manual to reflect the changes.
-
10/10/23 Update
10/10/2023 at 18:57 • 0 commentsFor those that already have a MemberChip Card rev.A, here are the changes to convert it to rev.B, to expand the ROM from 32k to 64k:
The change is pretty simple; just three pins! Compare it to the rev.A schematic.The EPROM is changed from a 27C256 (32k) to a 27C512 (64k). The 1802 reads the lower 32k of the EPROM normally when A15=0 and /MRD=0 (a normal memory read cycle).
But if the 1802 writes to the lower 32k, it sets A15=0, /MWR=0 and /MRD=1. /MWR=0 chip-selects the ROM, A15=0 enables it to read, and /MRD=1 sets ROM address bit A15 high; so it reads a byte from the upper 32k.
We don't want both the 1802 and ROM to put data on the bus at the same time (bus fight)! So we use the 1802's INP instruction to do the write cycle. INP sets /MWR=0, but does not put data on the bus. Instead, the 1802 loads whatever is on the data bus into its D register.
Thus we have a way to read any byte in the upper 32k of the EPROM. The upper ROM address is specified by the 1802 R(X) register (with bit A15=0). This byte can then be used or saved in RAM normally.
The 9/20/23 update shows an example program to move blocks of data from 32-64k in the EPROM into RAM.
-
10/8/23 Update
10/10/2023 at 05:23 • 3 commentsHere are some "Quickstart" instructions for the Menu, BASIC, VTL2, and Visual/02 programs in Mike Riley's alternate program ROM. They're not a full manual yet, but will get you started and give you a "taste" of vintage programs and languages.
A Quickstart Guide to the Diskless Elf/OS ROM
by Mike Riley and Lee Hart
Last update: 2 Nov 2023
Elf/OS is a disk operating system for 1802 microprocessor systems. Since disk drives on the 1802 are rare, Mike also made a "diskless" version, so users could add their own form of mass storage. The Diskless Elf/OS ROM is stored in a single 32K EPROM, which contains a "sampler" of vintage programming tools and languages, including BASIC, FORTH, LISP, and VTL-2. It also includes a Monitor, Visual debugger, mini Editor/Assembler, and XMODEM load/save programs.
Diskless Elf/OS can be used in any 1802 system with 32K ROM and 32K RAM. A 5V USB-serial adapter provides power and serial I/O using the 1802's Q output and EF3 input pins. The MemberChip Card has a header to match the Sparkfun FTDI 5v USB-TTL serial cable #9718 www.sparkfun.com/products/9718. Use it with a serial terminal, or a PC running a Terminal program such as TeraTerm http://www.tera-term.en.lo4d.com/windows. Here are the basic steps:
1. Connect the 1802ME MemberChip Card:
2. Start TeraTerm:
If it asks, select Serial (not TCP/IP), and select your COMn: port3. Select Setup... Serial port... and select:
Port = COM5 (or whatever serial port number your computer has)
Speed = 4800
Data = 8 bit
Parity = none
Stop = 1 bit
Flow control = none4. Select Setup... Terminal... and select:
Term size = 80 x 24
New-line: Receive = CR, Transmit = CR
Terminal ID = VT100
Coding: Receive = UTF-8, Transmit = UTF-85. Press the <ENTER> key, and the 1802ME will figure out the baud rate
and display its sign-on menu:------------------------------------- | MemberCHIP | | | | 1. Rc/Basic L2 | | 2. Rc/Forth | | 3. Rc/Lisp | | 4. EDTASM | | 5. VTL2 | | 6. Visual/02 | | 7. Minimon | | 8. Dump Memory | | 9. Load Memory | | | | Option ? | | v1.7.2 | -------------------------------------
Select one of the options by typing its number (1-9) and the <ENTER> key. The selected program will then start. See the instructions for how to use each program. Each program has its own way to EXIT back to the Menu.
1. Rc/BASIC L2
This is a classic 16-bit integer BASIC. Type a command line, and end it with the <ENTER> key. BASIC will execute the command, and display the result. Commands can be typed in upper or lower case, but will be converted to uppercase.
Rc/BASIC has two types of variables: Numeric and String. There are 26 Numeric variables, named A-Z. Longer names can be used for readability, but the additional letters are ignored (so A is the same variable as APPLE). Numeric variables must be integers in the range -32768 to +32767. Numbers smaller or larger than this will wrap around (so 32767+1 = -32768).
There are 26 String variables A-Z. Longer names can be used, but the last character must be a $ (so A$ is the same string variable as APPLE$). Strings are placed in quotes, like this: ROSE$="are red". Strings can be any length up to the available memory size.
There are two modes of operation; Direct and Program. In Direct mode, BASIC executes each line you type immediately. For example:
A=5 ...you type these 3 lines B=4 PRINT "A times B is "; A*B A times B is 20 ...and BASIC types this line
In Program mode, start each line with a line number. Rather than being executed, the lines are stored in memory, sorted into ascending order. If a line already exists with that number, the new line replaces it. To erase a line, type a line with just its number. It is traditional to number the lines by 10's. This makes it easy to add a line later to make changes. For example:
10 PRINT "Hello "; ...first line of your program 11 PR ...oops; I started with the wrong line number 11 ...so delete line 11 20 PRINT "world!" ...and type line 20 instead LIST ...LIST the program 10 PRINT "Hello "; 20 PRINT "world!" RUN ...now RUN it Hello world! ...and here's the output from your first program!
The LIST command will list (display) your program.
The RUN command will run your program.
The BYE command exits BASIC and returns to the menu.Here is another simple example. Try entering and running it, then experiment by making your own changes to see how it works:
20 FOR X=1 to 10 30 PRINT 11-X; "..."; 40 NEXT 50 PRINT "Blast off!" 60 END RUN Countdown 10...9...8...7...6...5...4...3...2...1...Blast off!
Programs can be saved as a file on your PC with the XMODEM function of your Terminal program. If you are using TeraTerm, here are the steps to save your BASIC program:
1. Type the SAVE command, and press <ENTER>.
2. In TeraTerm, select File... Transfer... XMODEM... Receive.
3. TeraTerm will prompt you for the file name, and location where you want to save it.
Use a file name ending in .BAS (so you can tell it's a BASIC program).4. Click Save to start the transfer.
5. The transfer process should start automatically.
You will see a progress window as it proceeds, which will close when the transfer is complete.A similar process is used to load a saved program:
1. Type the LOAD command, and press <ENTER>.
2. In TeraTerm, select File... Transfer... XMODEM... Send.
3. TeraTerm will prompt you for the file name, and location of the file.
4. Click Send to start the transfer.
5. The transfer process should start automatically.
You will see a progress window as it proceeds, which will close when the transfer is complete.Rc/BASIC Expressions
Arithmetic expressions can be used in most places where a number is expected (even in GOTO or GOSUB statements). The arithmetic operators are:
+ add
- subtract
* multiply
/ divide
AND or & bitwise AND
OR or | bitwise ORRelational operators return -1 if TRUE, or 0 if FALSE:
= equal
<> not equal
< less than
> greater than
<= less than or equal
>= greater than or equalRc/BASIC follows the standard convention for operator precedence. ( and ) are evaluated first, then * and /, then + and -, then AND OR & and |, then = > < <> <= => are evaluated last.
Rc/BASIC Statements
CLEAR clear all variables, variable names, strings, and arrays
DATA value,value,value... set up values to be read into variables (see READ)
DIM variable(size) dimension 'variable' as having 'size' elements
END end the program and returns to Direct mode
FOR variable = start TO end STEP size start a FOR..NEXT loop,
or FOR variable = start TO end which sets 'variable' to 'start',
then executes lines until NEXT.
STEP expr set step size for NEXT (must be +, defaults to 1)
NEXT variable increment 'variable' by STEP. If 'variable' is less than
or NEXT or equal to 'end', jump back to FOR; else continue.
GOTO expr jump to line number calculated by 'expr'
GOSUB expr call subroutine at line# calculated by 'expr' (see RETURN)
IF expr THEN statement if 'expr' is true (non-zero), then do 'statement'
or IF expr statement else if 'expr' is false (zero), then skip to next line
INPUT "prompt"; var, var... get input(s) from user, and assign to variable(s).
or INPUT var, var... "prompt" is optional and displays first if provided
LET var = expr set 'variable' to value of expression
or var = expr 'LET' is optional
LIST list entire program
LIST line list only 'line' number
LIST start-end list lines from 'start' to 'end'
LOAD load a BASIC program from a file on your PC (in XMODEM format)
NEW clear the program and variables
ON expr GOTO line1, line2... if expr=1, GOTO line1, if 2 GOTO line2, etc.
OUT port, value write 'value' to 1802 output port (1-7)
POKE addr, value write 'value' into memory address
PLOT x, y move cursor to x (horizontal 1-80), y (vertical 1-24)
PRINT exprlist display numbers, strings, or values of variables. Separate
items with ; for no spaces between them, or ; to put a <tab>
between them. If , or ; ends the list, no <CR> will be output.
RANDOM prompt user for a number to set the RND( ) seed
RESTORE line reset the DATA pointer to 'line' number
RETURN return to line following the last GOSUB
READ var, var... read values from DATA statement and store them in 'var' list
REM anything mark the rest of the line as a comment that will be ignored
RUN start running the program at the first line number
SAVE save a BASIC program as a file on your PC (in XMODEM format)Rc/BASIC Functions
ASC(string) return ASCII value of first character of the string
CHR$(expr) return value of expression as a 1-character ASCII string
FLG( ) return value of 1802's EF1-4 flags
FRE( ) return remaining amount of memory available
INP(port) return value of 1802 input port 1-7
LEFT$(string, expr) return 'expr' characters from left side of string
LEN(string) return length of the string
MID$(string, start, length) return 'length' characters of string,
beginning at the 'start' position
PEEK(addr) return decimal value of the byte at the memory address
RIGHT$(string, expr) return 'expr' characters from right side of string
RND(range) return a random number from 0 to 1 less than 'range'
STR$(expr) return the value of 'expr' converted into an ASCII string
USR(addr, expr) call machine language subroutine. If 'expr' is provided,
or USR(addr) it is loaded into RF. USR returns the value left in RF
by the machine language subroutine when it returns.
VAL(string) return value of 'string' expressed as a binary number
VARPTR(varname) return address where a variable name is stored5. VTL2
VTL (Very Tiny Language) was developed in 1976 for the 8080 CPU in the Altair 8800 microcomputer. Memory was expensive, so VTL only required 768 bytes! To put that in perspective, Microsoft's 4K Integer BASIC was five times bigger. Despite its size, VTL is a clever little language that is smaller, faster, more powerful, and almost as easy to use as BASIC.
VTL2 is an improved version, developed in 1977 for the 6800 microprocessor. It is also tiny, but has more commands and features. Mike Riley wrote this version for the 1802. Here are the "quickstart" instructions:
- Press 5 <ENTER> to start the VTL2 program. It displays its sign-on message:
Rc/VTL2 V1.0.0 >
- Type < then the <ENTER> key. (This is the VTL2 "LOAD" command.)
- In the Teraterm menu, select File... Transfer... XMODEM... Send
- Select the MAZE.V program to send (you can download it from the files section of this project). You should see a progress box as Teraterm sends the program to the 1802ME.
- Type #=1 and the <ENTER> key. This is the VTL command to go RUN the program starting at line #1.
This program draws a maze, with the entry at the top and exit at the bottom. It will prompt you for the starting Seed, Width, and Height. Here is a sample run:
------------------------------- | Rc/VTL2 V1.0.0 | | >< | | >#=1 | | Enter seed: 2 | | Enter width: 5 | | Enter height: 5 | | | | + +--+--+--+--+ | | | | | | | + + + +--+ + | | | | | | | | +--+--+--+ + + | | | | | | | + +--+--+--+ + | | | | | | | | +--+--+ + + + | | | | | | | +--+--+ +--+--+ | | > | -------------------------------
VTL2 is an interpreter, like BASIC. You type in your command, and it is acted on immediately. It uses unsigned decimal numbers from 0-65535, and strings of ASCII characters, delimited by quotes "like this".
There are two types of commands:
- Direct statements, which have no line number. They are executed immediately after you hit the ENTER key. All Direct statements are of the form:
- Program statements, which start with a line number. They are saved in numerical order in memory, and executed later when the program is run. All program statements look like this:
variable=expression
line# variable=expressionVTL2 Operators
+ add
- subtract
* multiply
/ divide
& bitwise AND
| bitwise OR
^ bitwise XORComparison Operators:
< less than
= equal to
> greater thanVTL2 is unusual in that it only has *ONE* statement; variable = expression ! The uppercase alphabet A-Z, plus most of the rest of the punctuation symbols are all variables. However, the punctuation symbols are "system variables" with special functions:
VTL2 System Variables
! return address
" pointer for literal print statements
# current line number
$ single character input or output
% remainder after last division
& points to last byte of program
' random number
( starts a parenthesized expression
) ends a parenthesized expression
or, starts a Remark if no matching ( before it on the line
or, ends an array description
* end of memory
> save to disk (to PC in XMODEM format)
< load from disk (from PC in XMODEM format)
? print if left of =, input if right of =
: start of array description
; suppress <CR><LF> if at end of print statement
{ start of an absolute memory address
} ends an absolute memory addressIt takes some time to wrap your head around how this "system variable" concept works. For example, the system variable '#' is the current line number, so
#=1 jumps to the first line of the program (it's the same as RUN in BASIC)
10 #=100 jumps from the current line to line 100 (the same as GOTO 100 in BASIC)You can also read system variables. Since '#' is the current line number,
100 A=# sets A = 100 (the current line number)
If a statement tries to set #=0, it is ignored and # is not changed. This is how VTL2 implements the IF statement:
10 X=25
20 #=(X=25)*50 if X=25 is true (=1), then set line# = 50 (i.e. GOTO 50)
30 ... do this if X is not 25
40 #=20 and GOTO 20
50 ... do this if X=25Every time a program statement writes to '#', the (old value of # + 1) is saved in the system variable '!'. VTL2 uses this to implement BASIC's GOSUB and RETURN commands. For example:
10 X=1
20 #=100 CALL subroutine at 100 (and set !=21)...
30 X=2 ...it returns here, since '!' points to the next line after 20
40 #=100 CALL 100 again (and set !=41)...
50 X=3 ...returns here
60 #=100 etc.
...
100 X=X*X this is the subroutine; it squares X...
110 #=! ...and returns to the next line after the CALL (like RETURN in BASIC)'?' is the variable equivalent to BASIC's PRINT and INPUT statements. If '?' is to the right of the = sign, it is the PRINT statement.
A=? this requests a user input, and sets A to it
If the '?' is to the left of the = sign, it is the INPUT statement
?="You typed ";A prompts user with message "You typed ", inputs a number, and saves it in A
Special things:
0 list program (like LIST in BASIC)
#=1 run program, by setting line number to 1 (like RUN in BASIC)
&=0 clear program, by setting last byte of program to 0 (like CLEAR in BASIC)
*=0 exit VTL2, by setting the end of memory to 0 (like BYE in BASIC)6. VISUAL/02
VISUAL/02 is an 1802 simulator. It creates a virtual 1802, with its own independent set of registers. Unlike a monitor program that must reserve some registers for itself, VISUAL/02 can examine, change, and display all the 1802 registers and memory contents, and visually display them as it executes instructions or runs programs. It includes a simple disassembler, and can set breakpoints and trap individual opcodes. VISUAL/02 is a great way to debug programs, and to learn what the 1802 opcodes actually do.
Here is a sample display:
_______1802_registers_______ _____Disassembled_code______ / \ / \ +----------+ +-------+ +-------+ +------------------------------+ | R0 7018 | | D FF | | DF 1 | | 7018 LDI FF | TRAPS | R1 3E7D | +-------+ +-------+ | 701A PLO 2 | 80 | R2 FDFF | +-------+ +-------+ | 701B LDI FD | ^ | R3 3FD1 | | X 0 | | P 0 | | 701D PHI 2 | | | R4 EB1D | +-------+ +-------+ | 701E LDI 27 | | | R5 63FF | +-------+ | 7020 PLO 6 | Trapped opcodes | R6 7027 | | T 7D | BRK: | 7021 LDI 70 | displayed here | R7 DC3E | +-------+ 701E +------------------------------+ | R8 7BEF | +-------+ 7021 +------------------------------+ | R9 F2BE | | Q 0 | ^ | 7018 F8 FF A2 F8 FD B2 F8 27 | \ | RA E9BF | +-------+ | | 7020 A6 F8 70 B6 C0 0F 3F D4 | | | RB F97C | +-------+ | | 7028 0F 2D C0 70 3D F8 FF A2 | | | RC 5FBF | | IE 1 | | | 7030 F8 FD B2 F8 3D A6 F8 70 | | memory | RD FFCF | +-------+ | | 7038 B6 E2 C0 0F 3F F8 0C D4 | | contents | RE FF5A | Breakpoints | 7040 0F 03 F8 17 AD F8 4B BD | | | RF 17DF | displayed | 7048 D4 73 10 D4 0F 66 76 31 | / +----------+ here +------------------------------+ 7000 LBR 7018 <-- the LAST instruction executed >7018 LDI FF <-- the NEXT instruction that that will be executed V02>_ <-- VISUAL's prompt when it is waiting for your command
VISUAL/02 Commands:
?P display memory from R[P]
?X display memory from R[X]
?Rn display memory from R[n]
?aaaa display memory from address aaaa
$P disassemble from R[P]
$X disassemble from R[X]
$Rn disassemble from R[n]
$aaaa disassemble from address aaaa
!P bb bb ... store bytes bb into address R[P]
!X bb bb ... store bytes bb into address R[X]
!Rn bb bb ... store bytes bb into address R[n]
!aaaa bb bb ... store bytes bb into address aaaa
@aaaa set R[P] to run at address aaaa
Rn=aaaa set R[n] to aaaa
P=n set P to n
X=n set X to n
D=nn set D to nn
DF=b set DF to b
Q=b set Q to b
IE=b set IE to b
T=bb set T to bb
I trigger interrupt action
B+aaaa set breakpoint at aaaa
B-aaaa remove breakpoint at aaaa
BC ; clear all breakpoints
T+nn set trap for instruction opcode nn
T-nn remove trap for instruction nn
TC clear all traps
<ENTER> step 1 instruction
G go (run) until next breakpoint or trap
E exit VISUAL/02
A go to EDTASM (Pico/Elf only)Note: As of 2 Nov 2023, use the TC command (Clear all Traps) before setting a Trap.
6. Minimon
This is a Mini Monitor program that lets you read and write to memory, and run programs. The sign-on prompt is ">". Commands consist of a "?" (read), "!" (write), or "@" (run) followed by a hexadecimal address. All numbers are hexadecimal. You can use the <backspace> key to correct mistakes until the final <ENTER> key to execute the command. Here's an example:
>?8000 <-- READ memory starting at 8000h. 8000: BE EA 9D 64 8E D0 F9 EF 2D 4C 75 EC B4 E4 92 F6 <-- Here are 128 bytes of memory 8010: 63 02 3A 81 66 EC B4 99 B8 96 C4 D4 CE DE 59 90 starting at 8000h. 8020: E1 68 AE E2 1B CC 7F C3 CE 8B E7 FF 5C 1D A2 3D 8030: 86 9D AC FD 61 F8 A9 2C 26 CE D8 51 3C 5C 1C 76 8040: D7 6B 5F 58 CF E6 D0 69 98 43 C7 EE 1F 95 AD 24 8050: 3F AE C9 C9 6E EF 56 D7 22 F4 02 A3 A7 4B 96 33 8060: E4 47 8E D5 43 39 30 2C FD AD E7 9F 88 2E E5 BA 8070: 71 76 1B 67 B1 D3 BE A3 3F 29 6F DA 58 DC A0 F9 >!8000 F8 FF BB 7A 2B 9B 3A 03 C0 00 00 <-- WRITE a little program into memory. >?8000 <-- Read memory again to see if it's correct. 8000: F8 FF BB 7A 2B 9B 3A 03 C0 00 00 EC B4 E4 92 F6 <-- Yep; it's correct! 8010: 63 02 3A 81 66 EC B4 99 B8 96 C4 D4 CE DE 59 90 8020: E1 68 AE E2 1B CC 7F C3 CE 8B E7 FF 5C 1D A2 3D 8030: 86 9D AC FD 61 F8 A9 2C 26 CE D8 51 3C 5C 1C 76 8040: D7 6B 5F 58 CF E6 D0 69 98 43 C7 EE 1F 95 AD 24 8050: 3F AE C9 C9 6E EF 56 D7 22 F4 02 A3 A7 4B 96 33 8060: E4 47 8E D5 43 39 30 2C FD AD E7 9F 88 2E E5 BA 8070: 71 76 1B 67 B1 D3 BE A3 3F 29 6F DA 58 DC A0 F9 >@8000 <-- Now RUN the program. (It turns the red Q LED on for a second, then waits for the <ENTER> key to return to the main menu.)
Minimon has two more commands that will prove useful. "=" is the copy command, which copies "size" bytes from the "source" address to the "destination" address. Finally, the "/" command exits Minimon and returns to the Main Menu.
>=8000 8010 10 <-- COPY 10 bytes from 8000 to 8010 >?8000 <-- Read to see if it worked. 8000: F8 FF BB 7A 2B 9B 3A 03 C0 00 00 EE F4 E7 9E FF 8010: F8 FF BB 7A 2B 9B 3A 03 C0 00 00 EE F4 E7 9E FF <-- See? It did! 8020: E1 68 AE E2 1B CC 7F C3 CE 8B E7 FF 5C 1D A2 3D 8030: 86 9D AC FD 61 F8 A9 2C 26 CE D8 51 3C 5C 1C 76 8040: D7 6B 5F 58 CF E6 D0 69 98 43 C7 EE 1F 95 AD 24 8050: 3F AE C9 C9 6E EF 56 D7 22 F4 02 A3 A7 4B 96 33 8060: E4 47 8E D5 43 39 30 2C FD AD E7 9F 88 2E E5 BA 8070: 71 76 1B 67 B1 D3 BE A3 3F 29 6F DA 58 DC A0 F9 >/ <-- EXIT Minimon
- Press 5 <ENTER> to start the VTL2 program. It displays its sign-on message:
-
10/6/23 Update
10/06/2023 at 18:44 • 0 commentsThere are a number of cross-assemblers for the 1802, but Mike Riley's ASM/02 is the newest, most capable, and runs on Windows and Linux PCs. He used it to write his Elf/OS operating system for the 1802, the source for which is posted on his Github pages (referenced elsewhere in this project). ASM/02 includes directives for producing code for various 1802 hardware platforms, including the MemberChip Card.
The cosmacelf community https://groups.io/g/cosmacelf/topics has been actively fixing bugs and adding features to ASM/02 and Elf/OS. Tony Hefner suggests downloading it from https://github.com/arhefner/Asm-02 as it's being maintained by the group. Al Williams just posted an excellent instruction manual for it at https://groups.io/g/cosmacelf/files/Al%20Williams/Assembly%20Langauge%20for%20the%20ELF_OS%20and%20ELF_BIOS%20Environment.pdf
Al's work is basically a programming manual for the 1802 using ASM/02. It explains the charming eccentricities of the 1802 (what, no CALL instruction?), and shows how the assembler gets around them (to add CALL, and many other "normal" instructions).
-
10/5/23 Update
10/05/2023 at 19:37 • 0 commentsI ordered PCBs from https://www.pcbway.com/ to test out my idea for bank-switching the MemberChip card EPROM to allow more than 32k. It's the first time I've used them. They were super-easy to work with, and even offered to sponsor the boards. :-) The PCBs look great and arrived quickly.
I was initially worried because their Gerber viewer had problems displaying my PCB. It looked like this:
Once I removed all the extraneous information outside of the Outline, this problem was resolved. The actual PCBs came out beautifully, like this:
-
10/1/23 Update
10/02/2023 at 03:55 • 0 commentsMade numerous small changes to the MC20ANSA ROM, and uploaded an updated image to the Hackaday.io page.
Changes include improved operation at high baud rates, clearer HELP messages, and the addition of a CALL option to the Monitor so you can CALL a user program, make use of the monitor's I/O routines, and RETURN to it when it exits.
The MCSMP20 monitor in the ROM actually has two separate "run" commands:
The RUN command
The monitor's RUN command is like a hardware CLEAR; it sets X=0 and P=0, so R0 becomes the program counter. If you don't provide an address (just R<cr>), then program execution begins at 0000; just like a hardware reset.
If you *do* provide an address (Raaaa<cr>), the RUN command sets R0 to that address. Thus, that's where your program will begin executing.
The other registers are set to the values saved in RAM when the monitor started, as shown by the VIEW command. If you like, you can *change* the corresponding value in RAM, and it will be restored by the RUN command.
For example, R8 is saved in RAM at FFECh and FFEDh. If you use the WRITE command to set these bytes to some value (for example, WFFEC 12 34<cr>), then RUN sets R8=1234h and then starts execution at R0.
The CALL command
The other RUN command could more properly be named CALL. Although 1802 register assignments are arbitrary, most 1802 software typically uses them as follows. If you want your programs to work with other people's programs, use these assignments:
R0 = DMA pointer (and the PC on power-up or clear)
R1 = Interrupt handler
R2 = Stack pointer
R3 = Program counter
R4 = CALL subroutine
R5 = RETURN from subroutine
R6 = used to pass parameters to or from a subroutineCALL is an initialization routine to set up all these registers for you. It is in ROM at address 1680h. The R1680<cr> command will:
- change the program counter from R0 to R3
- set P=3
- initialize the stack
- set X=2 to make it the stack pointer
- point R4 to SCRT CALL routine
- point R5 to SCRT RETURN routine
- push R6 onto the stack
- use R6 to get the current baud rate constant
- save the current baud rate constant in RE
- restore R6 from the stack
- and jump to 8000h (the start of RAM, where your user program should be)Happy hacking!
Lee Hart
-
9/20/23 Update
09/20/2023 at 18:47 • 1 commentI added a link to Josh Bensadon's short Youtube video demo of the MemberChip Card. (Thanks, Josh! I've never made a video in my life, and didn't know how I was going to add one to meet the contest rules.)
I now have a program to read files from the upper pages of a larger EPROM. This opens the door to using a file system like Mike Riley's Elf/OS. A large EPROM (up to 256k bytes) can be used to simulate a disk drive, making a file system worthwhile.
The standard ROM is 32k bytes (1 bank), and is simply addressed from 0-32k. But by rewiring the chip-select logic (a single 74HC132), the 1802 can select up to eight 32k banks in a larger ROM.
Here's the trick: EPROM /CE is selected by *either* /MRD or /MWR, and address bit A15 is connected to EPROM /OE. This means any address from 0-32k selects the EPROM. Obviously, you can't write to an EPROM.
However, 1802 I/O instructions move bytes from the data bus to/from memory. For example, the INP 1 instruction sets /MWR low, puts the register pointed to by X on the address bus, and writes whatever is on the data bus into that memory location *and* into CPU register D.
INP 1 thus sets /MWR low (to select the EPROM), sets /MRD high (to address the upper 32-64k bank), and register X provides the other 15 bits of the address to read a byte from that 32-64k bank. The byte read from the EPROM goes into the 1802's D register. It can subsequently be used, or saved anywhere in RAM. Here is a sample program:
8000 F8 01 ldi 01h ; point R6 to "source" in high ROM (for example, 0100h) 8002 B6 phi r6 ; (which will actually read 8100h in the EPROM) 8003 F8 00 ldi 00h 8005 A6 plo r6 8006 E6 sex r6 ; and set X to "source" 8007 F8 82 ldi 82h ; point R7 to "destination" in RAM = 8200h 8009 B7 phi r7 800A F8 00 ldi 00h 800C A7 plo r7 800D F8 10 ldi 10h ; set R8 as byte counter (move 10h bytes) 800F A8 plo r8 loop: 8010 68 inp 0 ; read byte from high ROM, 8011 57 str r7 ; and store it in RAM 8012 16 inc r6 ; increment source 8013 17 inc r7 ; increment destination 8014 28 dec r8 ; decrement byte counter 8015 88 glo r8 ; get counter 8016 3A bnz loop ; loop until byte counter = 0
The 1802 has three bits (N0, N1, and N2) to indicate the I/O port address. The INP instructions set these to reflect the instruction (INP 0 to INP 7). These three bits can be connected to the address bits of even larger EPROMs to address up to 256K bytes of banked memory.
-
8/27/23 Update
08/30/2023 at 03:25 • 0 commentsMore updates to the manual at sunrise-ev.com/photos/1802/1802me-manual.pdf.
I figured out a clever scheme to double the EPROM size (from 32k to 64k) with bank switching. This will allow me to put both the standard and alternate ROMs in at once. Now I'll have to see if there's enough room on the PCB to actually implement it!
Numerous small bug fixes and enhancements have been made to the Alternate ROM software. Allow tabs in the editor. Handle the illegal 1802 opcode 68h in the monitor and debugger. Add new words to FORTH, etc.
-
6/2/23 Update
06/03/2023 at 00:00 • 0 commentsAdded some new material to the manual, and updated the parts list.
I've also started to document the programs in the Alternate ROM package. It has tiny versions of several classical programming languages (BASIC, FORTH, LISP, etc.) so many users will need some "hints" on how they work.
-
5/15/23 update
05/15/2023 at 18:38 • 0 commentsCorrected a few typos on the schematic, and clarified the text. Updated the PDF manual.