{ Lee Hart's ELF (RCA COSMAC 1802) Membership Card PARALLEL PROGRAMER Parallax Propeller Plus Peter Jakacki's TACHYON Software: TACHYON.spin Forth ver 4.7 + EXTEND.fth + EASYFILE.fth Note: Several modules were deleted from EXTEND to increase available memory size. I replaced the 32K RAM chip in the ELF with a pin compatible 32K EEPROM. This enabled programs to be retained after power was turned off. } : (COSMAC) ; --- COINSTANTS & VARIABLES --- #P8 #8 MASKS OUTPUTS \ connects to ELF input port #P16 #8 MASKS INPUTS \ connects to ELF output port #P4 #4 MASKS OUTPUTS \ connects to ELF control port #P4 == /in #P5 == pclr #P6 == rw #P7 == wait #10 == dly \ delay time in ms long a# \ current memory address long sect# \ currernt sector number #512 BYTES code --- ELF CONTROL WORDS --- --- Execute /in and increment memory address pub E ( -- ) /in LOW dly ms /in HIGH a# ++ ; --- Halt current running program pub H ( -- ) wait LOW ; --- Set LOAD mode pub LOAD ( -- ) H pclr LOW ; --- Clear registers and set starting address to 0 pub SE ( -- ) pclr LOW wait HIGH dly ms H a# ~ ; --- Set READ mode (default) pub RD ( -- ) rw HIGH LOAD ; --- Set WRITE mode pub WR ( -- ) rw LOW LOAD ; --- RUN current loaded program pub RP ( -- ) pclr HIGH wait HIGH ; --- UTILITIES --- --- Reboot Tachynon - resets initial state pub R ( -- ) REBOOT ; --- Set 1802 memory address (0-32767) pub >ADDR ( n -- ) a# ! ; --- Clear 1802 input port pri CLRPORT ( -- ) 0 $FF 8 SHL OUT ; --- CODE BLOCK OPERATIONS --- --- Clear code block pub CCODE ( -- ) #512 FOR $00 code I + C! NEXT ; --- Assemble 1802 code, increment memory, and set no. bytes at address 0 pub ^ ( byte -- ) code 1+ a# @ + C! a# ++ code ++ ; --- Display code block pub DCODE ( -- ) code #512 DUMP ; --- Edit code block pub ECODE ( address -- ) code + C! ; --- SECTOR BLOCK OPERATIONS --- --- Clear SDBUF pub CSECT ( -- ) #512 FOR $00 SDBUF I + C! NEXT ; --- Display SDBUF contents pub DSECT ( -- ) SDBUF #512 DUMP ; --- Load SD Card Sector index no. of open file to SDBUF pub LSECT ( index -- ) FSECT@ + SECTOR ; --- Write code block to SD Card sector block (SDBUF) pub WCTOS ( -- ) CSECT #512 FOR code I + C@ SDBUF I + C! NEXT ; --- Write sector block (SDBUF) to code block pub WSTOC ( -- ) CCODE #512 FOR SDBUF I + C@ code I + C! NEXT ; --- Save sector to currently open file --- WRSECT --- COSMAC READ/WRITE OPERATIONS --- --- Read 1802 memory, leaving byte on stack and increment memory pub RBYTE ( -- byte ) E #16 #8 PINS@ ; --- Display 16 bytes of code beginning at current address pub DLINE ( -- bo, b1, b2..., b15 ) CR a# @ . ." : " #16 FOR RBYTE .BYTE SPACE NEXT ; --- Display n lines of code pub NDUMP ( n -- l, l2 .... ln ) FOR DLINE NEXT ; --- Write 1 byte to 1802, eg, $F8 WBYTE pub WBYTE ( byte -- ) CLRPORT 1 SWAP 8 SHL OUT E ; --- Write code to 1802 memory pub WCODE ( -- ) WR SE code C@ FOR code I 1+ + C@ WBYTE NEXT RD ; --- Write SDBUF sector to 1802 memory pub WSECT ( -- ) WR SDBUF @ FOR SDBUF I 1+ + C@ WBYTE NEXT RD ; --- Write n bytes from SDBUF to 1802 memory pri WSBUF ( n -- ) FO SDBUF I + C@ WBYTE NEXT ; --- Write binary code program in currently opened file to 1802 pub WBIN ( -- ) WR FSECT@ 1- sect# ! FSIZE@ #512 U/MOD FOR sect# @ 1+ DUP sect# ! SECTOR #512 WSBUF NEXT WSBUF RD ; --- 1802 ASSEMBLY LANGUAGE --- : (1802) ; --- Register Operations $10 == INC0 $11 == INC1 $12 == INC2 $13 == INC3 $14 == INC4 $15 == INC5 $16 == INC6 $17 == INC7 $18 == INC8 $19 == INC9 $1A == INC10 $1B == INC11 $1C == INC12 $1D == INC13 $1E == INC14 $1F == INC15 $20 == DEC0 $21 == DEC1 $22 == DEC2 $23 == DEC3 $24 == DEC4 $25 == DEC5 $26 == DEC6 $27 == DEC7 $28 == DEC8 $29 == DEC9 $2A == DEC10 $2B == DEC11 $2C == DEC12 $2D == DEC13 $2E == DEC14 $2F == DEC15 $60 == ITX $80 == GLO0 $81 == GLO1 $82 == GLO2 $83 == GLO3 $84 == GLO4 $85 == GLO5 $86 == GLO6 $87 == GLO7 $88 == GLO8 $89 == GLO9 $8A == GLO10 $8B == GLO11 $8C == GLO12 $8D == GLO13 $8E == GLO14 $8F == GLO15 $90 == GHI0 $91 == GHI1 $92 == GHI2 $93 == GHI3 $94 == GHI4 $95 == GHI5 $96 == GHI6 $97 == GHI7 $98 == GHI8 $99 == GHI9 $9A == GHI10 $9B == GHI11 $9C == GHI12 $9D == GHI13 $9E == GHI14 $9F == GHI15 $A0 == PLO0 $A1 == PLO1 $A2 == PLO2 $A3 = PLO3 $A4 == PLO4 $A5 == PLO5 $A6 == PLO6 $A7 == PLO7 $A8 = PLO8 $A9 == PLO9 $AA == PLO10 $AB == PLO11 $AC == PLO12 $AD = PLO13 $AE == PLO14 $AF == PLO15 $B0 == PHI0 $B1 == PHI1 $B2 == PHI2 $B3 = PHI3 $B4 == PHI4 $B5 == PHI5 $B6 == PHI6 $B7 == PHI7 $B8 = PHI8 $B9 == PHI9 $BA == PHI10 $BB == PHI11 $BC == PHI12 $BD = PHI13 $BE == PHI14 $BF == PHI15 --- Memory Load/Store Instructions $01 == LDN1 $40 == LDA0 $F0 == LDX $72 == LDXA $F8 == LDI $50 == STR0 $73 == STXD \ Short Branch Instructions $30 == BR $31 == BQ $32 == BZ $33 == BDF $33 == BDZ $33 == BGE $34 == B1 $35 == B2 $36 == B3 $37 == B4 $38 == SKP $39 == BNQ $3A == BNZ $3B == BNF $3B == BM $3B == BLL $3C == BN1 $3D == BN2 $3E == BN3 $3F == BN4 \ Long Branch & Skip Instructions $C0 == LBR $C1 == LBQ $C3 == LBDF $C4 == NOP $C6 == LSNZ $C7 == LSNF $C8 == NLBR $C9 == LBNQ $CA == LBNZ $CB == LBNF $CC == LSIE $CD == LSQ $CE == LSZ $CF == LSDF \ Logic, Arithmetic, and Shift Instructions $F1 == OR $F2 == AND $F3 == XOR $F4 == ADD $74 == ADC $F5 == SD $75 == SDB $F7 == SM $77 == SM0B $F9 == ORI $FA == ANI $FB == XRI $FC == ADI $7C == ADCI $FD == SDI $7D == SDBI $FF == SMI $7F == SMBI $F6 == SHR $FE == SHL $76 == SHRC $76 == RSHR $7E == SHLC $7E == RSHL \ Control Instructions $00 == IDL $70 == RET $71 == DIS $79 == MARK $78 == SAVE $7A == REQ $7B == SEQ $D0 == SEP0 $D1 == SEP1 $D2 == SEP2 $D3 == SEP3 $D4 == SEP4 $D5 == SEP5 $E0 == SEX0 $E1 == SEX1 $E2 == SEX2 $E3 == SEX3 $E4 == SEX4 $E5 == SEX5 \ Input\Output Instructions $61 == OUT1 $62 == OUT2 $63 == OUT3 $64 == OUT4 $65 == OUT5 $66 == OUT6 $67 == OUT7 $69 == INP1 $6A == INP2 $6B == INP3 $6C == INP4 $6D == INP5 $6E == INP6 $6F == INP7 { Programming Example Define words as follows: pub blink1 $F8 ^ $08 ^ $B2 ^ $22 ^ $92 ^ $3A ^ $03 ^ $CD ^ $7B ^ $38 ^ $7A ^ $30 ^ $00 ^ ; or using assembly language pub blink2 DI ^ #8 ^ PHI2 ^ DEC2 ^ GHI2 ^ BNZ ^ #3 ^ LSQ ^ SEQ ^ SKP ^ REQ ^ BR ^ #0 ^ ; Executing blink1 or blink2 will load the blink code in the code block. For large programs, multiple words can be defined which are executed sequentialy. Additional TACHYON Words which may prove useful. FORGET -- Removes word and all words that follow from dictionary, ie, FORGET (COSMAC) removes the entire 1802 vocabulary. BACKUP? -- Backup current dictionary if changes have been made. WORDS -- Lists current dictionary. .S -- Displays current status of stack. Note: See TACHYON documentation for information on using TACHYON to define additional words for this application. Easyfile Words MOUNT -- Open SD Card for access to files. DIR -- Lists current stored files. SDBUF -- 512 byte buffer used to access SD card contents. FOPEN -- Opens named file for read/write operations. FSECT@ -- Leaves sector address of opened file on stack. FSIZE@ -- Leaves number of bytes in file on stack. SECTOR ( sector # -- ) -- Stores specified sector content in SDBUF. WRSECT -- Writes SDBUF content to open file on SD card. RW -- Makes current opened file read/write. FCLOSE -- Close current open file. size "file name" FCREATE$ -- Create a new file - use format 8.3. DELETE -- Deletes named file on SD card. -FERASE -- Erase current open file content. References: 1802 Membership Card : http://www.sunrise-ev.com/memnbershipcard.htm http://www.retrotechnology.cm/memship/memship.html http://www.ittybuttycomputers.com/IttyButty/ShortCor.html }