org 0h
nop
call masukserial
mov dptr,#MyCharacter
loop: clr A
Movc A,@A+dptr
cjne A,#0,Next
sjmp loop1
Next: call out
inc dptr
sjmp loop
loop1: call input
cjne A,#'1',next1
mov P0,#30h
mov p1,#31h
next1: cjne A,#'2',next2
mov P0,#31h
mov p1,#30h
next2: cjne A,#'3',nextx
mov P0,#39h
mov p1,#34h
nextx: sjmp loop1
;
masukserial:
mov scon,#52h ; Konfigurasi komunikasi serial
mode 1
mov tmod,#20h ; Baud rate 2400 BPS
MOV TH0,#81H
MOV TL0,#4AH
MOV TH1,#0f3h
MOV TL1,#32H
setb tr1
SETB PT1
SETB ET1
SETB EA
ret
;
input:
detecti: jnb ri,detecti
; Deteksi bit RI apakah data sudah diterima
atau belum
clr ri
mov a,sbuf
ret
;
out:
detecto: jnb ti,detecto;
clr ti ;
mov sbuf,a ;
ret
;
MyCharacter:
DB
' Tekan Tombol 1, 2 atau 3',13,10,0
End