home *** CD-ROM | disk | FTP | other *** search
- \\ LCDT.SEQ 8096 code for LCD driver etc. by Mike Mayo
-
- This is a sample program showing how to use TCOM96, which is an 8096
- Forth target compiler adapted from Tom Zimmer's TCOM for 8086.
-
- This program has been developed and tested using the Intel 80c196KB chip.
- The hardware environment includes 64K bytes of static RAM, two 8K byte
- EEPROM's, a 16L8 PAL for address decode, and a Maxim MAX232 chip for
- connecting the 80c196's serial port to a COM port of a PC.
-
- $Header: F:/tcom/sampl96/logs/lcdt.sev 1.6 12 Dec 1990 13:45:52 MikeM $
- $Log: F:/tcom/sampl96/logs/lcdt.sev $
- \
- \ Rev 1.6 12 Dec 1990 13:45:52 MikeM
- \
- \ Rev 1.3 18 Sep 1990 12:08:12 MikeM
- \ Released to Tom Zimmer
-
- {
-
- $2000 cseg intvec2000
- $2014 cseg eprom-PPW
- $2018 cseg bus-config
- $2020 cseg null-table-jmp
- $2030 cseg intvec2030
- $2080 cseg initial-cseg
-
- $0C0 CONSTANT PSP0
- $100 CONSTANT RP0
-
- $F800 constant DREG \ display register
- $200 constant DBUF \ display data buffer
- \ ( 120 bytes per row )
- \ ( 7680 bytes in all )
-
- registers \ by default this starts at $24
-
- 2variable DPOINT \ pointers and counters
- variable DCOUNT \ for display block move
- variable ROW_COUNTER
-
- variable SP_FLAGS \ serial port status image
-
- variable tlcdx \ display output stuff
- variable tlcdy
- variable tcolor
-
- variable tach_sample \ sample timer2 in here
- variable tach_counter \ count LCD interrupts for sampling timer2
- variable old_tach \ previous tach value
-
-
- 11 constant SFT_T3 \ HSO command to Start timer 3
- $E0 constant LOAD_TVAL \ For 50Hz frame rate
- 37 constant TACH_COUNT \ Frame count for tach samples
-
- 64 constant ROWS
- 60 constant ROW_WORDS
-
-
- long_branch
- long_library
-
- initial-cseg \ reset entry point
-
- : start-here \ two possible entry points
- start-from-ee \ $2080 for RESET
- startup \ $2083 for downloaded code
- ;
-
- fload spcode.seq
- fload dispcode.seq
- fload spcmds.seq
-
- code TRAP_INT \ debugger's TRAP instruction gets us here
- PUSHF
- PUSH PSP
- PUSH TTOS
- PUSH TTOS2
- PUSH W0
- PUSH W2
- LD W0 SP
- CALL SEND_WORDL
-
- BEGIN CALL SP_POLL_L AGAIN \ now wait for host to do something
- end-code
-
- \ Items on stack....
- \ Address following the TRAP instruction
- \ Machine Flags
- \ PSP
- \ TTOS
- \ TTOS2
- \ W0
- \ W2
- \ Return address into TRAP_INT from SP_POLL
-
- CODE UNTRAP \ debugger's return from a TRAP
- \ discard the return address into TRAP_INT after CALL SP_POLL
- ADD SP # 2
- \ restore registers saved after the TRAP
- POP W2
- POP W0
- POP TTOS2
- POP TTOS
- POP PSP
- POPF
- RET \ debugger will have modified this return address
- end-code
-
-
- code copy-to-EE ( s d n -- f ) \ copy n bytes from s to d in EEPROM
- \ Make sure that n is less than 32
- \ and that it will not cross 32-byte
- \ boundaries in the EEPROM
-
- LDB TTOS2 TTOS \ byte count
- LOAD_TTOS \ address to write to
- LD W2 TTOS
- LOAD_TTOS \ source address
- 1 $:
- LDB W0 []+ TTOS \ get a byte of data to write
- STB W0 []+ W2 \ write the byte
- DJNZ TTOS2 1 $
-
- DEC W2 \ point to last byte written
- LD TTOS 0
- 2 $:
- CMPB W0 [] W2 \ check to see if it is done
- JE 3 $
- DEC TTOS
- JNE 2 $ \ $10000 loop timeout
- 3 $:
- RET \ return loop couter on stack
- \ It is =0 if timed out
- end-code
-
- : copy-boot-to-EE ( source dest -- ) \ copy RAM to boot EEPROM
- $2000
- 0 do over c@ over c!
- begin over c@ over c@
- - 0= until
- 1 + swap 1 + swap
- loop
- drop drop
- 0 sp_send
- $2000 $8000
- $2000
- 0 do over c@ over c@
- - 0= if else leave then
- 1 + swap 1 + swap
- loop
- drop
- dup $100 / sp_send
- sp_send
- ;
- : copy-boot-to-EE1 ( -- ) \ copy RAM to boot EEPROM1
- $2000 $8000
- copy-boot-to-EE
- ;
- : copy-boot-to-EE2 ( -- ) \ copy RAM to boot EEPROM2
- $2000 $A000
- copy-boot-to-EE
- ;
-
- code set-hso ( n -- ) \ set bits n in the HSO
- LDB W0 IOS0
- LDB WSR # 15
- ORB W0 # TTOS
- LDB IOS0 W0
- LDB WSR 0
- LOAD_TTOS
- ret
- end-code
-
- code clear-hso ( n -- ) \ reset bits n in the HSO
- NOTB TTOS
- LDB W0 IOS0
- LDB WSR # 15
- ANDB W0 # TTOS
- LDB IOS0 W0
- LDB WSR 0
- LOAD_TTOS
- ret
- end-code
-
- code TIME_INT \ timer interrupt service for refreshing a LCD panel.
- PUSHF
- LDB DPOINT 2+ IOS1
- LDB HSO_COMMAND # SFT_T3 $10 + \ restart the timer
- ADD HSO_TIME <-- TIMER1 # LOAD_TVAL
- \ Set up the count for the timer
-
- ORB IOPORT1 # 1 \ set LOAD
- ANDB IOPORT1 # $0FE \ clear LOAD
- ANDB IOPORT1 # $0FD \ clear FRAME
-
- LD DPOINT 2+ # DREG
- BMOV DPOINT DCOUNT \ send one row of display data
-
- DEC0= ROW_COUNTER IF
- XORB IOPORT1 # 4 \ flip DF
- ORB IOPORT1 # 2 \ set FRAME
- LDB ROW_COUNTER # ROWS \ Loop count for all rows
- LD DPOINT # DBUF \ Point to start of display buffer
- DEC0= TACH_COUNTER IF
- \ sample timer2 every so often.
- \ It will be counting pulses from a tachometer.
- LD TACH_SAMPLE TIMER2 \ Get tach count
- CLR TIMER2 \ Reset counter
- LDB TACH_COUNTER # TACH_COUNT \ Loop count for
- \ displaying tach*20
- THEN
- THEN
-
- POPF
- END-CODE code NULL_INT
- RET end-code
-
-
- CODE START-FROM-EE \ entry point when booting from EEPROM
- DI
- LD W2 # $2000 \ source
- LD TTOS # $A000 \ destination \ copy to RAM
- LD TTOS2 # $1000 \ count
- 1 $:
- LD W0 []+ W2 \ move words from EE to RAM
- ST W0 []+ TTOS
- DEC TTOS2
- JNE 1 $
-
- LDB W0 IOS0
- LDB WSR # 15
- OR W0 # 8
- LDB IOS0 W0 \ switch to running in RAM
- LDB WSR 0
- end-code
-
- CODE STARTup \ entry point when downloaded
- DI
- LD SP # RP0 \ Initialize the return stack.
- LD PSP # PSP0 \ Initialise the parameter stack.
-
- LDB IOPORT1 # 2 \ set FRAME
- LDB ROW_COUNTER # ROWS \ Loop count for all rows
- LD DPOINT # DBUF \ Point to start of display buffer
- LD DCOUNT # ROW_WORDS \ words per display row
-
- LDB IOC2 # $80 \ clear the CAM
- LDB INT_PEND 0 \ clear pending interrupts
- LDB INT_PEND1 0
- LDB HSO_COMMAND # SFT_T3 $10 +
- ADD HSO_TIME <-- TIMER1 # LOAD_TVAL \ Set up the count for the timer
- LDB INT_MASK # $20
-
- LDB IOC0 # 0
- EI
- end-code \ This must be immediately followed by MAIN
- : MAIN \ MAIN must be immediately preceded by STARTup
- SP_INIT
- 'S' sp_send
- BEGIN
- SP_POLL
- ROW_WORDS DCOUNT !
- dotach
- AGAIN
- ;
-
-
- : showtach
- 10 10 at \ 4 .r
- dup 1000 / dup '0' + l-emit 1000 * -
- dup 100 / dup '0' + l-emit 100 * -
- dup 10 / dup '0' + l-emit 10 * -
- '0' + l-emit
- ;
-
- : dotach \ display the tachometer measurement
- tach_sample @ 1+ 0=
- not if tach_sample c@ 20 *
- dup old_tach - abs \ put in some hysteresis to
- \ stabilise the display
- 3 - 0< if showtach else drop then
- -1 tach_sample !
- then
- ;
-
- : TEST
- 256 0 DO I SP_SEND LOOP ;
-
-
- intvec2000 \ interrupt vectors
- code TBL@2000
- NULL_INT , \ Timer overflow interrupt.
- NULL_INT , \ A/D Conversion complete interrupt.
- NULL_INT , \ HSI Data available.
- NULL_INT , \ HSO interrupt
- NULL_INT , \ HSI.0 pin
- TIME_INT , \ Software timers.
- NULL_INT , \ Serial port.
- NULL_INT , \ Extint.
- TRAP_INT , \ Trap instruction
- NULL_INT , \ Unimplemented opcode
- END-CODE
-
- intvec2030 \ interrupt vectors
- code TBL@2030
- NULL_INT , \ Transmit interrupt.
- NULL_INT , \ Receive interrupt.
- NULL_INT , \ 4th entry into HSO FIFO
- NULL_INT , \ TIMER2 capture
- NULL_INT , \ TIMER2 overflow
- NULL_INT , \ Extint pin
- NULL_INT , \ HSI FIFO full
- $2080 , \ NMI
- END-CODE
-
- eprom-PPW
- code eBUS_CONFG
- $096 C, \ Programming Pulse Width for 87c196
- END-CODE
-
- bus-config
- code BUS_CONFG
- $0DF C, \ Bus configuration word
- END-CODE
-
- null-table-jmp
- code TBL@2020
- SJMP $2080 \ Just in case a jump table has blanks in it
- END-CODE \ we can reinitialise from here.
-
-
- end-cseg
-
-
-