Display LCD
[Kembali]
[Home]
1. Rangkaian [Kembali]
2. Flowchart [Kembali]
3. Listing Program [Kembali]
; PROGGRAM6.ASM DIGUNAKAN UNTUK INPUT KEYPAD
; DITAMPILKAN KE LCD
; Data LCD: Port A
; E : PC0
; RS : PC1h
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEG
ORG 100H
start: jmp mulai
porta equ 00h
portb equ 01h
portc equ 02h
cw equ 03h
DISPCLR EQU 00000001B
FUNCSET EQU 00111000B
ENTRMOD EQU 00000110B
DISPON EQU 00001100B
awal db ?
data db ?
data_keypad db?
ratusan db ?
puluhan db ?
satuan db ?
akhir db ?
mulai:
Mov AX, CS
Mov DS, AX
Xor AX, AX
Mov ES, AX
Mov SS, AX
Lea SI, Awal
Lea CX, Akhir
Mov DI, SI
Sub CX, SI
Cld
Rep Movsb
Mov SP,800h
Xor AX,AX
Mov DS,AX
mov al,82h ; Port A dan Port C = output dan
; Port B = input
mov dx,cw
out dx,al
call initialisasi_LCD
balik:
mov dx,portb
in al,dx
and al,128
cmp al,128
je balik
in al,dx
and al,00001111B
call konversi_keypad_to_bin
mov data_keypad,al
mov data,80h
call controlout
mov al,data_keypad
mov ah,0
add ax,30h
mov data,al
call dataout
tunggu:
mov dx,portb
in al,dx
and al,128
cmp al,0
je tunggu
jmp balik
konversi_keypad_to_bin proc near
cmp al,4
jne keypad1
mov al,1
ret
keypad1:
cmp al,8
jne keypad2
mov al,2
ret
keypad2:
cmp al,12
jne keypad3
mov al,3
ret
keypad3:
cmp al,1
jne keypad4
mov al,4
ret
keypad4:
cmp al,4
jne keypad5
mov al,4
ret
keypad5:
cmp al,5
jne keypad6
mov al,5
ret
keypad6:
cmp al,9
jne keypad7
mov al,6
ret
keypad7:
cmp al,13
jne keypad8
mov al,7
ret
keypad8:
cmp al,2
jne keypad9
mov al,8
ret
keypad9:
cmp al,6
jne keypad0
mov al,9
ret
keypad0:
cmp al,10
jne bintang
mov al,0
ret
bintang:
cmp al,14
jne pagar
mov al,14
ret
pagar:
cmp al,3
jne keluar
mov al,3
ret
keluar:
ret
konversi_keypad_to_bin endp
;-------------------------
; control instruction
;-------------------------
; E : PC0
; RS : PC1
control_out proc near
mov dx,portc
mov al,00000000b ; E = 0, RS = 0
out dx,al
call delay_lcd
mov dx,portc
mov al,00000001b ; E = 1, RS = 0
out dx,al
call delay_lcd
mov dx,porta
mov al,data
out dx,al
call delay_lcd
mov dx,portc
mov al,00000000b ; E = 0, RS = 0
out dx,al
call delay_lcd
ret
control_out endp
;-------------------------
; data instruction
;-------------------------
; E : PC0
; RS : PC1
data_out proc near
mov dx,portc
mov al,00000010b ; E = 0, RS = 1
out dx,al
call delay_lcd
mov dx,portc
mov al,00000011b ; E = 1, RS = 1
out dx,al
call delay_lcd
mov dx,porta
mov al,data
out dx,al
call delay_lcd
mov dx,portc
mov al,00000010b ; E = 0, RS = 1
out dx,al
call delay_lcd
ret
data_out endp
;--------------------
; inisialisasi LCD
;--------------------
initialisasi_LCD proc near
mov data,DISPCLR
call control_out
call delay_lcd
mov data,FUNCSET
call control_out
call delay_lcd
mov data,ENTRMOD
call control_out
call delay_lcd
mov data,DISPON
call control_out
call delay_lcd
ret
initialisasi_LCD endp
delay_lcd proc near
push cx
mov cx,07fffh
loop $
pop cx
ret
delay_lcd endp
delay proc near
push cx
mov cx,0ffffh
loop $
pop cx
ret
delay endp
ORG 40F0H
DB 0EAH
DW 0100H
DW 0FBF0H
CODE_SEG ENDS
END START