NAM WRLCD OPT P=75
OPT G
XDEF WRLCD
XREF PORTAB,PORTAC,CKBUSY,CURS,WPTR,TWPTR,SEG,WORD0,WORD1,WORD2
XREF WORD3,NCAR,TNCAR
RS EQU 0 !data input/instrucion data input
RW EQU 1 !read write
E EQU 2 !clock
DSHOME EQU %00000010 !return home code
DDRAM EQU %10000000 !base dd ram address
WRLCD IDNT 1,0 M6805 LCD CONTROLLER
* !write a string into display data ram
* !la stringa dowra` essere scritta a partire da word0.
* !seg (da 0 a 3) = definisce un blocco di memoria a partire da wordx
* !wptr (da 0 a 255) = puntatore all`interno del blocco selezionato
* !curs (da 0 a 40) = posizione del cursore sul display
* !ncar (da 0 a 255) = lunghezza della stringa in caratteri
PSCT
WRLCD LDA NCAR
STA TNCAR !numero di caratteri della stringa
JSR CKBUSY !chek if lctc is busyne
BCLR RS,PORTAC !rs=0
BCLR RW,PORTAC !rw=0
BCLR E,PORTAC !e=0
BSET E,PORTAC !e=1
LDA #DSHOME !return home
STA PORTAB
BCLR E,PORTAC !e=0
BSET RW,PORTAC !rw=1
JSR CKBUSY !chek if lctc is busyne
BCLR RS,PORTAC !rs=0
BCLR RW,PORTAC !rw=0
BCLR E,PORTAC !e=0
BSET E,PORTAC !e=1
LDA #DDRAM !cursor address
ORA CURS
STA PORTAB
BCLR E,PORTAC !e=0
BSET RW,PORTAC !rw=1
LDX WPTR !puntatore alla stringa
STX TWPTR
WRSTR LDA SEG !segmento di memoria che contiene la stringa
CMP #$00
BNE SG1
* !segmento 0; a partire da word0 max 256 caratteri
LDA WORD0,X !carica il carattere puntato
BRA WREXE !scrivilo sul display
* !segmento 1; a partire da word1 max 256 caratteri
SG1 CMP #$01
BNE SG2
LDA WORD1,X
BRA WREXE
* !segmento 2; a partire da word2 max 256 caratteri
SG2 CMP #$02
BNE SG3
LDA WORD2,X
BRA WREXE
* !segmento 3; a partire da word3 max 256 caratteri
SG3 LDA WORD3,X
WREXE TAX !salva l'accumulatore a
JSR CKBUSY !chek if lctc is busyne
TXA
BSET RS,PORTAC !rs=1
BCLR RW,PORTAC !rw=0
BCLR E,PORTAC !e=0
BSET E,PORTAC !e=1
STA PORTAB
BCLR E,PORTAC !e=0
BSET RW,PORTAC !rw=1
DEC TNCAR !aggiorna il contatore dei caratteri scritti
BEQ ESCWR !se finito esci
INC TWPTR !incrementa il puntatore al carattere da scrivere
LDX TWPTR
BRA WRSTR !continua fino a tncar=0
ESCWR RTS
END