RW equ $08 * PB3 is R/W RS equ $04 * PB2 is RS E equ $02 * PB1 is E PORTA equ $0000 PORTB equ $0001 PORTC equ 0x04 DDRA equ $0002 DDRB equ $0003 DDRC equ 0x06 TCNT equ $0084 TSCR equ $0086 make bit7=1 to enable TCNT Num1 equ $0800 Num1A equ $0801 Num2 equ $0802 Num2A equ $0803 Num3 equ $0804 Num3A equ $0805 Ln1Cnt equ $0806 Ln2Cnt equ $0807 KeyHit equ $0808 equals equ $0809 ycount equ $0810 Math equ $0811 Temp1 equ $0812 Temp2 equ $0813 Temp3 equ $0814 org $0819 buf rmb 10 ; characters typed cnt rmb 1 ; loop counter, number of keys left to be typed org $F000 Object code goes in ROM ***************LCDInit*********************** * Initialize HD44780 LCD display * Inputs: none Outputs: none * Registers modified: A,CCR LCDInit ldaa #$FF staa DDRA Output to LCD data ldaa #$FF staa DDRB Outputs pb1=E, pb2=RS, pb3=R/W clr PORTB E=0, RS=0, R/W=0 rts ***************LCDOutChar*********************** * Output one character to HD44780 LCD display * Inputs: RegA is ASCII character Outputs: none * Registers modified: B,CCR LCDOutChar staa PORTA ldab #E+RS E=1, RS=1, R/W=0 stab PORTB ldab #RS E=0, RS=1, R/W=0 stab PORTB bsr LCDWaitShort 40us wait rts ***************LCDOutCmd*********************** * Output command to HD44780 LCD display * Inputs: RegA is LCD command Outputs: none * Registers modified: B,CCR * Entry Mode Set 0,0,0,0,0,1,I/D,S * I/D=1 for increment cursor move direction * =0 for decrement cursor move direction * S =1 for display shift * =0 for no display shift * Display On/Off Control 0,0,0,0,1,D,C,B * D =1 for display on * =0 for display off * C =1 for cursor on * =0 for cursor off * B =1 for blink of cursor position character * =0 for no blink * Cursor/Display Shift 0,0,0,1,S/C,R/L,*,* * S/C=1 for display shift * =0 for cursor movement * R/L=1 for shift to left * =0 for shift to right * Function Set 0,0,1,DL,N,F,*,* * DL=1 for 8 bit * =0 for 4 bit * N =1 for 2 lines * =0 for 1 line * F =1 for 5 by 10 dots * =0 for 5 by 7 dots LCDOutCmd staa PORTA ldab #E E=1, RS=0, R/W=0 stab PORTB ldab #0 E=0, RS=0, R/W=0 stab PORTB bsr LCDWaitLong 1.54ms wait rts ***************LCDWaitShort*********************** * 20us wait HD44780 LCD display * real display would require 37us * Inputs: none Outputs: none * Registers modified: B,CCR LCDWaitShort ldd #1 *ldd #360 8MHz addd TCNT TCNT value at the end of the delay sloop cpd TCNT EndT-TCNT<0 when EndT