LAMPIRAN 1 PROGRAM PADA MIKROKONTROLER ATMEGA 89S52
MOV TMOD,#20H ; boutrate 9600 stopbit 1, data bit 8, parity none, flow control none MOV SCON,#50H MOV TH1,#-3 SETB TR1 rs equ p2.5 rw equ p2.6 en equ p2.7 clr p1.0
mov 68h,#0 start: mov 60h,#80h call data_penampil mov a,#'S' call kirim_data mov 60h,#81h call data_penampil mov a,#'t' call kirim_data mov 60h,#82h call data_penampil mov a,#'a' call kirim_data mov 60h,#83h call data_penampil mov a,#'r' call kirim_data mov 60h,#84h call data_penampil mov a,#'t' Universitas Sumatera Utara
call kirim_data
acall tunda
mov 60h,#80h call data_penampil mov a,#'A' call kirim_data mov 60h,#81h call data_penampil mov a,#'T' call kirim_data mov 60h,#82h call data_penampil mov a,#' ' call kirim_data mov 60h,#83h call data_penampil mov a,#' ' call kirim_data mov 60h,#84h call data_penampil mov a,#' ' call kirim_data
lcall tes_At acall tunda
mov 60h,#80h call data_penampil mov a,#'K' call kirim_data mov 60h,#81h call data_penampil Universitas Sumatera Utara
mov a,#'i' call kirim_data mov 60h,#82h call data_penampil mov a,#'r' call kirim_data mov 60h,#83h call data_penampil mov a,#'i' call kirim_data mov 60h,#84h call data_penampil mov a,#'m' call kirim_data
lcall at_cmgs lcall ready
mov 60h,#80h call data_penampil mov a,#'R' call kirim_data mov 60h,#81h call data_penampil mov a,#'E' call kirim_data mov 60h,#82h call data_penampil mov a,#'A' call kirim_data mov 60h,#83h call data_penampil mov a,#'D' call kirim_data Universitas Sumatera Utara
mov 60h,#84h call data_penampil mov a,#'Y' call kirim_data acall tunda acall tunda
mov 60h,#80h call data_penampil mov a,#'T' call kirim_data mov 60h,#81h call data_penampil mov a,#'i' call kirim_data mov 60h,#82h call data_penampil mov a,#'n' call kirim_data mov 60h,#83h call data_penampil mov a,#'g' call kirim_data mov 60h,#84h call data_penampil mov a,#'g' call kirim_data mov 60h,#85h call data_penampil mov a,#'i' call kirim_data mov 60h,#86h call data_penampil mov a,#' ' Universitas Sumatera Utara
call kirim_data mov 60h,#87h call data_penampil mov a,#'=' call kirim_data mov 60h,#88h call data_penampil mov a,#' ' call kirim_data
mov 60h,#8ch call data_penampil mov a,#' ' call kirim_data mov 60h,#8dh call data_penampil mov a,#'c' call kirim_data mov 60h,#8eh call data_penampil mov a,#'m' call kirim_data
mov 60h,#0c0h call data_penampil mov a,#'S' call kirim_data mov 60h,#0c1h call data_penampil mov a,#'t' call kirim_data mov 60h,#0c2h call data_penampil mov a,#'a' Universitas Sumatera Utara
call kirim_data mov 60h,#0c3h call data_penampil mov a,#'t' call kirim_data mov 60h,#0c4h call data_penampil mov a,#'u' call kirim_data mov 60h,#0c5h call data_penampil mov a,#'s' call kirim_data mov 60h,#0c6h call data_penampil mov a,#' ' call kirim_data mov 60h,#0c7h call data_penampil mov a,#'=' call kirim_data mov 60h,#0c8h call data_penampil mov a,#' ' call kirim_data
trigger: setb p1.1 nop nop nop nop nop nop Universitas Sumatera Utara
nop nop clr p1.1 nop nop nop nop jnb p1.2,$ mov 69h,#0
hitung: acall pulsa inc 69h jb p1.2,hitung mov a,69h mov b,#100 div ab mov 70h,a mov a,b mov b,#10 div ab mov 71h,a mov 72h,b
jarak: mov r0,70h acall transfer mov 73h,r1 mov r0,71h acall transfer mov 74h,r1 mov r0,72h acall transfer mov 75h,r1 Universitas Sumatera Utara
mov 60h,#89h call data_penampil mov a,73h call kirim_data mov 60h,#8ah call data_penampil mov a,74h call kirim_data mov 60h,#8bh call data_penampil mov a,75h call kirim_data lcall tunda cpl p3.7 mov a,69h cjne a,#7,cek_low lcall bahaya cpl p1.0 mov a,68h cjne a,#1,kirim_sms ljmp trigger
cek_low: mov a,psw anl a,#80h cjne a,#80h,cek_high lcall bahaya cpl p1.0 mov a,68h cjne a,#1,kirim_sms ljmp trigger
kirim_sms: Universitas Sumatera Utara
lcall at_cmgs lcall sms_bahaya mov 68h,#1 ljmp trigger
cek_high: mov a,69h cjne a,#14,cek_low1 lcall waspada clr p1.0 mov 68h,#0 ljmp trigger
cek_low1: mov a,psw anl a,#80h cjne a,#80h,cek_high1 lcall waspada clr p1.0 mov 68h,#0 ljmp trigger
cek_high1: mov a,69h cjne a,#21,cek_low2 lcall siaga clr p1.0 mov 68h,#0 ljmp trigger
cek_low2: mov a,psw anl a,#80h cjne a,#80h,cek_high2 Universitas Sumatera Utara
lcall siaga clr p1.0 mov 68h,#0 ljmp trigger
cek_high2: lcall aman clr p1.0 mov 68h,#0 ljmp trigger
waspada: mov 60h,#0c9h call data_penampil mov a,#'W' call kirim_data mov 60h,#0cah call data_penampil mov a,#'a' call kirim_data mov 60h,#0cbh call data_penampil mov a,#'s' call kirim_data mov 60h,#0cch call data_penampil mov a,#'p' call kirim_data mov 60h,#0cdh call data_penampil mov a,#'a' call kirim_data mov 60h,#0ceh call data_penampil Universitas Sumatera Utara
mov a,#'d' call kirim_data mov 60h,#0cfh call data_penampil mov a,#'a' call kirim_data ret
aman: mov 60h,#0c9h call data_penampil mov a,#'A' call kirim_data mov 60h,#0cah call data_penampil mov a,#'m' call kirim_data mov 60h,#0cbh call data_penampil mov a,#'a' call kirim_data mov 60h,#0cch call data_penampil mov a,#'n' call kirim_data mov 60h,#0cdh call data_penampil mov a,#' ' call kirim_data mov 60h,#0ceh call data_penampil mov a,#' ' call kirim_data mov 60h,#0cfh Universitas Sumatera Utara
call data_penampil mov a,#' ' call kirim_data ret
siaga: mov 60h,#0c9h call data_penampil mov a,#'S' call kirim_data mov 60h,#0cah call data_penampil mov a,#'i' call kirim_data mov 60h,#0cbh call data_penampil mov a,#'a' call kirim_data mov 60h,#0cch call data_penampil mov a,#'g' call kirim_data mov 60h,#0cdh call data_penampil mov a,#'a' call kirim_data mov 60h,#0ceh call data_penampil mov a,#' ' call kirim_data mov 60h,#0cfh call data_penampil mov a,#' ' call kirim_data Universitas Sumatera Utara
ret
bahaya: mov 60h,#0c9h call data_penampil mov a,#'B' call kirim_data mov 60h,#0cah call data_penampil mov a,#'a' call kirim_data mov 60h,#0cbh call data_penampil mov a,#'h' call kirim_data mov 60h,#0cch call data_penampil mov a,#'a' call kirim_data mov 60h,#0cdh call data_penampil mov a,#'y' call kirim_data mov 60h,#0ceh call data_penampil mov a,#'a' call kirim_data mov 60h,#0cfh call data_penampil mov a,#' ' call kirim_data ret
Universitas Sumatera Utara
transfer: cjne r0,#0h,satu mov r1,#'0' ret satu: cjne r0,#01h,dua mov r1,#'1' ret dua: cjne r0,#02h,tiga mov r1,#'2' ret tiga: cjne r0,#03h,empat mov r1,#'3' ret empat: cjne r0,#04h,lima mov r1,#'4' ret lima: cjne r0,#05h,enam mov r1,#'5' ret enam: cjne r0,#06h,tujuh mov r1,#'6' ret tujuh: cjne r0,#07h,delapan mov r1,#'7' ret delapan: cjne r0,#08h,sembilan Universitas Sumatera Utara
mov r1,#'8' ret sembilan: cjne r0,#09h,transfer mov r1,#'9' ret
tes_At: lcall tunda cpl p3.7 lcall tunda cpl p3.7 lcall tunda cpl p3.7 lcall tunda cpl p3.7
MOV SBUF,#'A' JNB TI,$ CLR TI lcall tunda cpl p3.7
MOV SBUF,#'T' JNB TI,$ CLR TI lcall tunda cpl p3.7
MOV SBUF,#13 JNB TI,$ CLR TI
MOV 19H,#255 Universitas Sumatera Utara
mov 20h,#255
LAGI: JNB RI,counter1 CLR RI MOV a,SBUF CJNE a,#'O',counter1 lcall tunda ret
counter1: dec 19h mov a,19h cjne a,#0,lagi mov 19h,#255 counter2: dec 20h mov a,20h cjne a,#0,lagi ljmp tes_At
at_cmgs: MOV SBUF,#'A' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'T' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'+' Universitas Sumatera Utara
JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'C' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'M' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'G' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'S' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'=' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'0' JNB TI,$ CLR TI lcall tunda cpl p3.7 Universitas Sumatera Utara
MOV SBUF,#'8' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'2' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'2' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'3' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'3' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'0' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'7' JNB TI,$ CLR TI lcall tunda Universitas Sumatera Utara
cpl p3.7 MOV SBUF,#'4' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'1' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'5' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'7' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#13 JNB TI,$ CLR TI lcall tunda cpl p3.7 ret
ready: MOV SBUF,#'R' JNB TI,$ CLR TI lcall tunda cpl p3.7 Universitas Sumatera Utara
MOV SBUF,#'E' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'A' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'D' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'Y' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#26 JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#13 JNB TI,$ CLR TI lcall tunda cpl p3.7 ret
sms_bahaya: MOV SBUF,#'B' Universitas Sumatera Utara
JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'A' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'H' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'A' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'Y' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#'A' JNB TI,$ CLR TI lcall tunda cpl p3.7 MOV SBUF,#26 JNB TI,$ CLR TI lcall tunda cpl p3.7 Universitas Sumatera Utara
MOV SBUF,#13 JNB TI,$ CLR TI lcall tunda cpl p3.7 ret
data_scan: mov p0,a clr rs clr rw setb en clr en call delay ret
data_penampil: mov a,#0ch ;tulisan tampil atau tidak call data_scan mov a,#06h ;geser kanan / kiri / tetap call data_scan mov a,60h ;posisi awal karakter call data_scan ret
kirim_data: mov p0,a setb rs clr rw setb en clr en call delay mov a,#38h ;3 = nilai untuk pengiriman data 8bit,8=ukuran font call data_scan Universitas Sumatera Utara
ret
tunda: mov r7,#2 tnd: mov r6,#255 td: mov r5,#255 djnz r5,$ djnz r6,td djnz r7,tnd ret
pulsa: mov r7,#23 djnz r7,$ ret
delay: mov r7,#10 dly: mov r6,#255 djnz r6,$ djnz r7,dly ret
Universitas Sumatera Utara