2019-12-25 19:39:07 +11:00
|
|
|
PORTB = $6000
|
|
|
|
PORTA = $6001
|
|
|
|
DDRB = $6002
|
|
|
|
DDRA = $6003
|
|
|
|
|
|
|
|
E = %10000000
|
|
|
|
RW = %01000000
|
|
|
|
RS = %00100000
|
|
|
|
|
|
|
|
.org $8000
|
|
|
|
|
2020-05-16 16:36:55 +10:00
|
|
|
|
|
|
|
|
2019-12-25 19:39:07 +11:00
|
|
|
reset:
|
|
|
|
lda #%11111111 ; Set all pins on port B to output
|
|
|
|
sta DDRB
|
|
|
|
|
|
|
|
lda #%11100000 ; Set top 3 pins on port A to output
|
|
|
|
sta DDRA
|
|
|
|
|
|
|
|
lda #%00111000 ; Set 8-bit mode; 2-line display; 5x8 font
|
2020-05-16 16:36:55 +10:00
|
|
|
jsr send_inst
|
|
|
|
|
2019-12-25 19:39:07 +11:00
|
|
|
lda #%00001110 ; Display on; cursor on; blink off
|
2020-05-16 16:36:55 +10:00
|
|
|
jsr send_inst
|
2019-12-25 19:39:07 +11:00
|
|
|
|
2020-05-16 16:36:55 +10:00
|
|
|
lda #%00000001 ; Reset display
|
|
|
|
jsr send_inst
|
2019-12-25 19:39:07 +11:00
|
|
|
|
2020-05-16 16:36:55 +10:00
|
|
|
lda #%00000110 ; Increment and shift cursor; don't shift display
|
|
|
|
jsr send_inst
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
print:
|
|
|
|
lda message,x
|
|
|
|
beq loop
|
|
|
|
jsr send_data
|
|
|
|
inx
|
|
|
|
jmp print
|
|
|
|
|
|
|
|
loop:
|
|
|
|
jmp loop
|
2019-12-25 19:39:07 +11:00
|
|
|
|
2020-05-16 16:36:55 +10:00
|
|
|
message: .asciiz "Hello again, Kiddies!"
|
2019-12-25 19:39:07 +11:00
|
|
|
|
2020-05-16 16:36:55 +10:00
|
|
|
lcd_wait:
|
|
|
|
pha
|
|
|
|
lda #%00000000 ; PORT B to INPUT
|
|
|
|
sta DDRB
|
|
|
|
lcd_busy:
|
|
|
|
lda #RW
|
2019-12-25 19:39:07 +11:00
|
|
|
sta PORTA
|
2020-05-16 16:36:55 +10:00
|
|
|
lda #(RW | E)
|
2019-12-25 19:39:07 +11:00
|
|
|
sta PORTA
|
2020-05-16 16:36:55 +10:00
|
|
|
lda PORTB
|
|
|
|
and #%10000000
|
|
|
|
bne lcd_busy
|
|
|
|
|
|
|
|
lda #RW
|
2019-12-25 19:39:07 +11:00
|
|
|
sta PORTA
|
2020-05-16 16:36:55 +10:00
|
|
|
lda #%11111111 ; PORT B to output
|
|
|
|
sta DDRB
|
|
|
|
pla
|
|
|
|
rts
|
2019-12-25 19:39:07 +11:00
|
|
|
|
2020-05-16 16:36:55 +10:00
|
|
|
send_inst:
|
|
|
|
jsr lcd_wait
|
2019-12-25 19:39:07 +11:00
|
|
|
sta PORTB
|
2020-05-16 16:36:55 +10:00
|
|
|
lda #0 ; Clear RS/RW/E bits
|
2019-12-25 19:39:07 +11:00
|
|
|
sta PORTA
|
2020-05-16 16:36:55 +10:00
|
|
|
lda #E ; Set E bit to send instruction
|
2019-12-25 19:39:07 +11:00
|
|
|
sta PORTA
|
2020-05-16 16:36:55 +10:00
|
|
|
lda #0 ; Clear RS/RW/E bits
|
2019-12-25 19:39:07 +11:00
|
|
|
sta PORTA
|
2020-05-16 16:36:55 +10:00
|
|
|
rts
|
2019-12-25 19:39:07 +11:00
|
|
|
|
2020-05-16 16:36:55 +10:00
|
|
|
send_data:
|
|
|
|
jsr lcd_wait
|
2019-12-25 19:39:07 +11:00
|
|
|
sta PORTB
|
|
|
|
lda #RS ; Set RS; Clear RW/E bits
|
|
|
|
sta PORTA
|
|
|
|
lda #(RS | E) ; Set E bit to send instruction
|
|
|
|
sta PORTA
|
|
|
|
lda #RS ; Clear E bits
|
|
|
|
sta PORTA
|
2020-05-16 16:36:55 +10:00
|
|
|
rts
|
2019-12-25 19:39:07 +11:00
|
|
|
|
|
|
|
|
|
|
|
.org $fffc
|
|
|
|
.word reset
|
|
|
|
.word $0000
|