Files
SyncHome/trunk/workspace/Z80/lcd.asm
2023-03-13 08:36:51 +00:00

330 lines
6.8 KiB
NASM

;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.5.0 #9253 (Jun 20 2015) (MINGW64)
; This file was generated Tue Jul 24 12:17:59 2018
;--------------------------------------------------------
.module lcd
.optsdcc -mz80
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
.globl _LCD_Port
.globl _delay
.globl _lcd_rs
.globl _lcd_strobe
.globl _lcd_write
.globl _lcd_clear
.globl _lcd_puts
.globl _lcd_putch
.globl _lcd_goto
.globl _lcd_init
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
_Display = 0x0080
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area _DATA
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area _INITIALIZED
_LCD_Port::
.ds 1
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
.area _DABS (ABS)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
.area _HOME
.area _GSINIT
.area _GSFINAL
.area _GSINIT
;--------------------------------------------------------
; Home
;--------------------------------------------------------
.area _HOME
.area _HOME
;--------------------------------------------------------
; code
;--------------------------------------------------------
.area _CODE
;lcd.c:18: void delay(int tempo){
; ---------------------------------
; Function delay
; ---------------------------------
_delay::
;lcd.c:20: for (i=0;i<=tempo;i++) {
ld de,#0x0000
00103$:
ld hl,#2
add hl,sp
ld a,(hl)
sub a, e
inc hl
ld a,(hl)
sbc a, d
jp PO, 00116$
xor a, #0x80
00116$:
ret M
;lcd.c:23: __endasm;
nop
;lcd.c:20: for (i=0;i<=tempo;i++) {
inc de
jr 00103$
;lcd.c:28: void lcd_rs(unsigned char command){
; ---------------------------------
; Function lcd_rs
; ---------------------------------
_lcd_rs::
;lcd.c:29: if (command==DATA)
ld hl, #2+0
add hl, sp
ld a, (hl)
dec a
jr NZ,00102$
;lcd.c:30: setb(LCD_Port,RS_PIN);
ld a,(#_LCD_Port + 0)
set 6, a
ld (#_LCD_Port + 0),a
ret
00102$:
;lcd.c:32: clrb(LCD_Port,RS_PIN);
ld a,(#_LCD_Port + 0)
and a, #0xBF
ld (#_LCD_Port + 0),a
ret
;lcd.c:37: void lcd_strobe(void){
; ---------------------------------
; Function lcd_strobe
; ---------------------------------
_lcd_strobe::
;lcd.c:38: setb(LCD_Port,EN_PIN);
ld a,(#_LCD_Port + 0)
set 7, a
;lcd.c:39: Display=LCD_Port;
ld (#_LCD_Port + 0),a
out (_Display),a
;lcd.c:40: clrb(LCD_Port,EN_PIN);
ld a,(#_LCD_Port + 0)
and a, #0x7F
;lcd.c:41: Display=LCD_Port;
ld (#_LCD_Port + 0),a
out (_Display),a
ret
;lcd.c:45: void lcd_write(unsigned char c) {
; ---------------------------------
; Function lcd_write
; ---------------------------------
_lcd_write::
;lcd.c:46: LCD_Port = (LCD_Port & 0xF0) | (c >> 4);
ld a,(#_LCD_Port + 0)
and a, #0xF0
ld d,a
ld hl, #2+0
add hl, sp
ld a, (hl)
rlca
rlca
rlca
rlca
and a,#0x0F
or a, d
ld (#_LCD_Port + 0),a
;lcd.c:47: lcd_strobe();
call _lcd_strobe
;lcd.c:48: LCD_Port = (LCD_Port & 0xF0) | (c & 0x0F);
ld a,(#_LCD_Port + 0)
and a, #0xF0
ld d,a
ld hl, #2+0
add hl, sp
ld a, (hl)
and a, #0x0F
or a, d
ld (#_LCD_Port + 0),a
;lcd.c:49: lcd_strobe();
call _lcd_strobe
;lcd.c:50: delay(4);
ld hl,#0x0004
push hl
call _delay
pop af
ret
;lcd.c:54: void lcd_clear(void) {
; ---------------------------------
; Function lcd_clear
; ---------------------------------
_lcd_clear::
;lcd.c:55: lcd_rs(CMD);
xor a, a
push af
inc sp
call _lcd_rs
inc sp
;lcd.c:56: lcd_write(0x1);
ld a,#0x01
push af
inc sp
call _lcd_write
inc sp
;lcd.c:57: delay(200);
ld hl,#0x00C8
push hl
call _delay
pop af
ret
;lcd.c:61: void lcd_puts(const char * s) {
; ---------------------------------
; Function lcd_puts
; ---------------------------------
_lcd_puts::
;lcd.c:62: while(*s)
pop bc
pop hl
push hl
push bc
00101$:
ld a,(hl)
or a, a
ret Z
;lcd.c:63: lcd_putch(*s++);
inc hl
push hl
push af
inc sp
call _lcd_putch
inc sp
pop hl
jr 00101$
;lcd.c:67: void lcd_putch(char c) {
; ---------------------------------
; Function lcd_putch
; ---------------------------------
_lcd_putch::
;lcd.c:68: lcd_rs(DATA); // write characters
ld a,#0x01
push af
inc sp
call _lcd_rs
inc sp
;lcd.c:69: lcd_write(c);
ld hl, #2+0
add hl, sp
ld a, (hl)
push af
inc sp
call _lcd_write
inc sp
;lcd.c:70: delay(4);
ld hl,#0x0004
push hl
call _delay
pop af
ret
;lcd.c:74: void lcd_goto(unsigned char pos) {
; ---------------------------------
; Function lcd_goto
; ---------------------------------
_lcd_goto::
;lcd.c:75: lcd_rs(CMD);
xor a, a
push af
inc sp
call _lcd_rs
inc sp
;lcd.c:76: lcd_write(0x80+pos);
ld hl, #2+0
add hl, sp
ld a, (hl)
add a, #0x80
push af
inc sp
call _lcd_write
inc sp
ret
;lcd.c:80: void lcd_init(void) {
; ---------------------------------
; Function lcd_init
; ---------------------------------
_lcd_init::
;lcd.c:81: lcd_rs(CMD); // write control bytes
xor a, a
push af
inc sp
call _lcd_rs
inc sp
;lcd.c:82: delay(150); // power on delay
ld hl,#0x0096
push hl
call _delay
pop af
;lcd.c:83: LCD_Port = 0x3; // attention!
ld hl,#_LCD_Port + 0
ld (hl), #0x03
;lcd.c:84: lcd_strobe();
call _lcd_strobe
;lcd.c:85: delay(500);
ld hl,#0x01F4
push hl
call _delay
pop af
;lcd.c:86: lcd_strobe();
call _lcd_strobe
;lcd.c:87: delay(100);
ld hl,#0x0064
push hl
call _delay
pop af
;lcd.c:88: lcd_strobe();
call _lcd_strobe
;lcd.c:89: delay(500);
ld hl,#0x01F4
push hl
call _delay
pop af
;lcd.c:90: LCD_Port = 0x2; // set 4 bit mode
ld hl,#_LCD_Port + 0
ld (hl), #0x02
;lcd.c:91: lcd_strobe();
call _lcd_strobe
;lcd.c:92: delay(4);
ld hl,#0x0004
push hl
call _delay
;lcd.c:93: lcd_write(0x28); // 4 bit mode, 1/16 duty, 5x8 font
ld h,#0x28
ex (sp),hl
inc sp
call _lcd_write
inc sp
;lcd.c:94: lcd_write(0x08); // display off
ld a,#0x08
push af
inc sp
call _lcd_write
inc sp
;lcd.c:95: lcd_write(0x0F); // display on, blink curson on
ld a,#0x0F
push af
inc sp
call _lcd_write
inc sp
;lcd.c:96: lcd_write(0x06); // entry mode
ld a,#0x06
push af
inc sp
call _lcd_write
inc sp
ret
.area _CODE
.area _INITIALIZER
__xinit__LCD_Port:
.db #0x00 ; 0
.area _CABS (ABS)