📄 lcd.asm
字号:
;*###################################################;
;company:cansum writed by:he qigrang
; date:2004-7-2
;
;####################################################;
.area display_var(data)
;===============================;以下的都是临时寄存器,可释放的。
;-------------------------------;十进制数
h_temp0:: .ds 1 ;要显示的低位
h_temp1:: .ds 1 ;要显示的中位
h_temp2:: .ds 1 ;要显示的高位
;------------------------------difine RAM(DISPLAY)
h_dis_ram0:: .ds 1
h_dis_ram1:: .ds 1
h_dis_ram2:: .ds 1
h_dis_ram3:: .ds 1
h_dis_ram4:: .ds 1
;------------------------------
adrptr:: .ds 2
temp0:: .ds 1
temp1:: .ds 1
temp2:: .ds 1
;===============================;
.area display_code(code)
lcd_display::
call h_clr_dis_ram ;清除显存
call h_x_to_a ;16进制变为10进制
call h_check_table ;查表得到显示数据
call h_dis_all ;把数据送到显存
ret
;***************************************;
h_clr_dis_ram:
lda #0
sta h_dis_ram0
sta h_dis_ram1
sta h_dis_ram2
sta h_dis_ram3
sta h_dis_ram4
ret
;****************************************;
;有个转换公式的(可以把程序写得好短),但我忘了,
;又查不到资料,我就是差的。现用了最笨的方法,。
;-----------------------------------------
h_x_to_a:
lda cnt_point
sta temp0
lda cnt_point+1
sta temp1
lda #0
sta h_temp0
sta h_temp1
sta h_temp2
h_x_to_a_1:
lda temp0
cmpe #10 ;低位是小于十吗?
brnc h_x_to_a_2
;lda temp0
suba #10
sta temp0
lda h_temp1
inca
sta h_temp1
cmpe #10
brnc h_x_to_a_1
;lda h_temp1
suba #10
sta h_temp1
lda h_temp2
inca
sta h_temp2
br h_x_to_a_1
h_x_to_a_2:
lda temp1
cmpe #0
brz h_x_to_a_3
lda h_temp1
inca
sta h_temp1
lda #246
adda temp0
sta temp0
lda temp1
deca ;高位减一
sta temp1
br h_x_to_a_1
h_x_to_a_3:
lda temp0
sta h_temp0
ret
;*******************************************;
;*******************************************;
h_check_table:
lda h_temp2 ;求高位的表值数
cmpe #0 ;如高位是零,不用显示
brz h_dis_middle
sta temp0
call h_get_table
lda temp0
sta h_dis_ram0
lda temp1
sta h_dis_ram1
h_dis_middle:
lda h_temp1
cmpe #0
brz h_check_high
br h_dis_middle1
h_check_high:
lda h_temp2
cmpe #0
brz h_dis_low
h_dis_middle1:
lda h_temp1 ;求中间位的表值
sta temp0
call h_get_table
lda temp0
adda #0 ;clear cy
rolc ;左移四位
rolc
rolc
rolc
anda #11110000b
ora h_dis_ram1
sta h_dis_ram1
lda temp0
adda #0 ;clear cy
rorc ;右移四位
rorc
rorc
rorc
anda #00001111b
sta h_dis_ram2
lda temp1
adda #0 ;clear cy
rolc ;左移四位
rolc
rolc
rolc
anda #11110000b
ora h_dis_ram2
sta h_dis_ram2
h_dis_low:
lda h_temp0 ;求低位的表值
sta temp0
call h_get_table
lda temp0
sta h_dis_ram3
lda temp1
sta h_dis_ram4
ret
;=====================================;
;intput:temp0
;output:temp0,temp1
;-------------------------------------
h_get_table:
lda #>(h_table) ;送表头值
sta adrptr+1
lda #<(h_table)
sta adrptr
h_getnum:
lda temp0 ;
cmpe #0
brz h_ready
lda temp0
deca
sta temp0
lda adrptr
adda #2
sta adrptr
lda #0
addc adrptr+1
sta adrptr+1
br h_getnum
h_ready:
lda adrptr+1
sta tph
lda adrptr
sta tpl
h_ready_ok:
lda r_op1
anda #10000000b
brz h_ready_ok
ldv
sta temp0
lda adrptr
inca
sta adrptr
lda #0
addc adrptr+1
sta adrptr+1
sta tph
lda adrptr
sta tpl
ldv
sta temp1
ret
h_table:
db 01010110b,00000011b ;0
db 00000000b,00000011b ;1
db 01110100b,00000001b ;2
db 01110000b,00000011b ;3
db 00100010b,00000011b ;4
db 01110010b,00000010b ;5
db 01110110b,00000010b ;6
db 00010000b,00000011b ;7
db 01110110b,00000011b ;8
db 01110010b,00000011b ;9
;=========================================;
;*****************************************;
;*****************************************;
h_dis_all: ;送到真正的显存
lda h_dis_ram0
sta 0f0h
lda h_dis_ram1
sta 0f1h
lda h_dis_ram2
sta 0f2h
lda h_dis_ram3
sta 0f3h
lda h_dis_ram4
sta 0f4h
ret
;****************************************;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -