You are on page 1of 26

LISTING CODE ASSEMBLY MOTOROLA 68HC11

SYSTEM SECURITY

Oleh:
Ahmad Reza Musthafa

Supported by :

Sistem Keamanan Rumah Assembly Motorola 68HC11

Source code: ORG $c4 JSCI RMB 3 JSPI RMB 3 JPAIE RMB 3 JPAO RMB 3 JTOF RMB 3 JTOC5 RMB 3 JTOC4 RMB 3 JTOC3 RMB 3 JTOC2 RMB 3 JTOC1 RMB 3 JTIC3 RMB 3 JTIC2 RMB 3 JTIC1 RMB 3 JRTI RMB 3 JIRQ RMB 3 JXIRQ RMB 3 JSWI RMB 3 JILLOP RMB 3 JCOP RMB 3 JCLM RMB 3 TB5MS: equ * DB0: equ DB1: equ DB2: equ DB3: equ DB4: equ DB5: equ DB6: equ DB7: equ OL4 OM4 OL3 OM3 equ equ equ equ DB2 DB3 DB4 DB5 $1a $20 equ equ equ equ

10000 1 2 4 8 $10 $20 $40 $80

toc3: equ tctl1: equ toc2: tmsk1: tflg1: tmsk2: NOTDB5: NOTDB6: porta equ portd: ddrd: portb: portc: ddrc: sccr2: REGBLK: F3500HZ: * spk_tone: sound_dur: xsound_save:

$18 $22 $23 $24 equ equ 8 9 4 ;$4 $3 $7 $2d equ 351 $00 2 1 2

$DF $BF

0 equ equ equ equ equ equ

$1000 ; 3.5KHz at 8MHz

equ org rmb rmb rmb

Ahmad Reza Musthafa| 2

Sistem Keamanan Rumah Assembly Motorola 68HC11 sound_repeat: xsound_beg: sound_start: rest_note: STACK: ONE_MS FIVE_MS TEN_MS rmb rmb rmb rmb equ 1 2 1 1 $8FFF equ equ equ 167 835 1670 ; for 8 MHz 1000us/6us=167

PORTF DDRF d40us: REG_SEL: ENABLE: NOT_REG_SEL: NOT_ENABLE: temp1: pfimg: reset_seq: disp_ram: * LCDimg: LCD_RSimg: LCD_ENimg: LCD: LCD_RS: LCD_EN: select: d5ms_flag: disp_data: disptn:

equ equ equ equ equ equ org rmb rmb rmb rmb

$2201 $2203 15 ; 15x6us= 90 us, 60us ok DB0 ; 0=reg, 1=data equ DB1 $FE $FD 0 1 1 1 3 equ pfimg pfimg pfimg PORTF equ PORTF equ PORTF 1 1 4 4

equ equ equ

rmb rmb rmb rmb

org jmp lcd_ini: ldaa staa clra staa staa ldx ldaa staa jsr ldx clr jsr rts inidsp1: fcb fcb fcb inidsp2: fcb fcb fcb

$D000 start

#$FF DDRF pfimg PORTF #inidsp1 #1 reset_seq outins1 #inidsp2 reset_seq outins2

2 $33 $32 4 $28 $06 Ahmad Reza Musthafa| 3

Sistem Keamanan Rumah Assembly Motorola 68HC11 fcb fcb outins1: pshb jsr ldab inx onext1: ldaa jsr inx jsr decb bne pulb rts * outins2: pshb jsr ldab inx onext2: ldaa jsr inx decb bne jsr pulb rts * delay_10ms: nop $0c $01

sel_inst 0,x 0,x wrt_pulse d5ms onext1

sel_inst 0,x 0,x wrt_pulse

onext2 d5ms

d10ms: pshx ldx #TEN_MS bsr del1 pulx rts d5ms: pshx ldx #FIVE_MS bsr del1 pulx rts del1: dex inx dex bne del1 rts delay: nop d10: pshx ldx #25000 bsr del1 pulx rts d5: pshx ldx #1000 bsr del1 pulx rts del0: dex Ahmad Reza Musthafa| 4

Sistem Keamanan Rumah Assembly Motorola 68HC11 inx dex bne rts

del0

* * sel_data: psha ldaa oraa bra sel_inst: psha ldaa anda sel_i: staa staa pula rts * lcd_line1: jsr ldaa bra lcd_line2: jsr ldaa line3: jsr * jsr jsr rts

LCD_RSimg #REG_SEL sel_i

LCD_RSimg #NOT_REG_SEL LCD_RSimg LCD_RS

sel_inst #$80 line3 sel_inst #$C0 wrt_pulse sel_data msg_out

msg_out: ldaa jsr inx decb bne rts

0,x wrt_pulse

msg_out

wrt_pulse: pshx psha anda staa ldaa anda oraa staa staa * bsr ldaa beq jsr * wrtpls: pula

#$f0 temp1 LCDimg #$0f temp1 LCDimg LCD enable_pulse reset_seq wrtpls d5ms

; get LCD port image.

; output data

Ahmad Reza Musthafa| 5

Sistem Keamanan Rumah Assembly Motorola 68HC11 asla asla asla asla staa * ldaa anda oraa staa staa * bsr pulx rts * enable_pulse: ldaa oraa staa staa LCD_ENimg #ENABLE LCD_ENimg LCD_EN enable_pulse LCDimg #$0f temp1 LCDimg LCD

temp1

ldaa LCD_ENimg anda #NOT_ENABLE staa LCD_ENimg staa LCD_EN pshx ldx #d40us jsr del1 pulx rts start: ldaa staa lds jsr jsr ldx clr ldaa jsr back: ldaa rora #$ff portd,x #STACK delay_10ms delay_10ms #REGBLK sccr2,x #$ff lcd_ini portd+$1000 ; turn off 7-segment display

bcs loading ldx #MSG2 ldab #16 jsr lcd_line1 jsr delay_10ms jsr delay_10ms jmp back loading: ldx #pes ldab #16 jsr lcd_line1 ldx #MSG1 ldab #16 jsr lcd_line2 jsr delay Ahmad Reza Musthafa| 6

Sistem Keamanan Rumah Assembly Motorola 68HC11 jsr delay

ldx #MSG1a ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #MSG1b ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #MSG1c ldab #16 jsr lcd_line2 jsr delay jsr delay ldx ldab #16 jsr jsr jsr #MSG1 lcd_line2 delay delay

ldx #MSG1a ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #MSG1b ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #MSG1c ldab #16 jsr lcd_line2 jsr delay jsr delay ldx ldab #16 jsr jsr jsr ldx #MSG1 lcd_line2 delay delay

#MSG1a ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #MSG1b ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #MSG1c Ahmad Reza Musthafa| 7

Sistem Keamanan Rumah Assembly Motorola 68HC11 ldab #16 lcd_line2 delay delay lcd_ini

jsr jsr jsr jsr ldx

#wel0 ldab #16 jsr lcd_line1 jsr delay ldx #wel1 ldab #16 jsr lcd_line1 jsr delay ldx #wel2 ldab #16 jsr lcd_line1 jsr delay jsr delay ;jsr delay ldx #wel3 ldab #16 jsr lcd_line1 jsr delay ldx #wel4 ldab #16 jsr lcd_line1 jsr delay ldx #wel5 ldab #16 jsr lcd_line1 jsr delay jsr delay ;jsr delay ldx #wel6 ldab #16 jsr lcd_line1 jsr delay ldx #wel7 ldab #16 jsr lcd_line1 jsr delay jsr delay ;jsr delay ldx #wel8 ldab #16 jsr lcd_line1 jsr delay ldx #wel9 ldab #16 jsr lcd_line1 jsr delay jsr delay ;jsr delay Ahmad Reza Musthafa| 8

Sistem Keamanan Rumah Assembly Motorola 68HC11

ldx

#wel10 ldab #16 jsr lcd_line1 jsr delay ldx #wel11 ldab #16 jsr lcd_line1 jsr delay jsr delay ;jsr delay ldx #wel12 ldab #16 jsr lcd_line1 jsr delay ldx #wel13 ldab #16 jsr lcd_line1 jsr delay jsr delay ;jsr delay ldx #wel14 ldab #16 jsr lcd_line1 jsr delay ldx #wel15 ldab #16 jsr lcd_line1 jsr delay jsr delay ;jsr delay ldx #wel16 ldab #16 jsr lcd_line1 jsr delay ldx #wel17 ldab #16 jsr lcd_line1 jsr delay jsr delay ;jsr delay ldx #wel18 ldab #16 jsr lcd_line1 jsr delay #wel19 ldab #16 jsr lcd_line1 jsr delay jsr delay ; jsr delay ldx #wel20 ldab #16 Ahmad Reza Musthafa| 9 ldx

Sistem Keamanan Rumah Assembly Motorola 68HC11 jsr jsr jsr jsr lcd_line1 delay delay delay

ldx jsr jsr jsr jsr

#wel21 ldab #16 lcd_line1 delay delay delay

ldx jsr jsr jsr jsr

#wel22 ldab #16 lcd_line1 delay delay delay

ldx

#wel ldab #16 jsr lcd_line1 jsr delay jsr delay jsr delay

#sis0 ldab #16 jsr lcd_line2 jsr delay ldx #sis1 ldab #16 jsr lcd_line2 jsr delay ldx #sis2 ldab #16 jsr lcd_line2 jsr delay ldx #sis3 ldab #16 jsr lcd_line2 jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr lcd_ini ldx #REGBLK Ahmad Reza Musthafa| 10

ldx

Sistem Keamanan Rumah Assembly Motorola 68HC11 jmp kembali kembali: ldx #pros ldab #16 jsr lcd_line1 ldx #bit ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #pros1 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros2 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros3 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros ldab #16 jsr lcd_line1 ldx #bit ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #pros1 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros2 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros3 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros ldab #16 jsr lcd_line1 ldx #bit ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #pros1 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros2 ldab #16 Ahmad Reza Musthafa| 11

Sistem Keamanan Rumah Assembly Motorola 68HC11 jsr lcd_line1 jsr delay jsr delay ldx #pros3 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros ldab #16 jsr lcd_line1 ldx #bit ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #pros1 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros2 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #pros3 ldab #16 jsr lcd_line1 jsr delay jsr delay jsr lcd_ini ldx #comp ldab #16 jsr lcd_line1 ldx #bit1 ldab #16 jsr lcd_line2 jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay ldx #pass ldab #16 jsr lcd_line1 ldx #pass2 ldab #16 jsr lcd_line2 jsr menu: ldx start2

#suc ldab #16 Ahmad Reza Musthafa| 12

Sistem Keamanan Rumah Assembly Motorola 68HC11 jsr lcd_line1 ldx #pass1 ldab #16 jsr lcd_line2 smenu: jsr spk_off jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr delay jsr lcd_ini ldx #menu1 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #menu2 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #menu3 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #menu4 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #menu5 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #menu6 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #menu7 ldab #16 jsr lcd_line1 jsr delay jsr delay ldx #menu2a ldab #16 jsr lcd_line2 jsr delay ldx #menu2b Ahmad Reza Musthafa| 13

Sistem Keamanan Rumah Assembly Motorola 68HC11 ldab #16 lcd_line2 delay jsr delay jsr delay jsr delay ldx #menu2c ldab #16 lcd_line2 delay

jsr jsr

jsr jsr

ldx #menu2d ldab #16 jsr lcd_line2 jsr delay ldx #menu2e ldab #16 lcd_line2 delay jsr delay ldx #menu2f ldab #16 lcd_line1 delay

jsr jsr

jsr jsr

ldx #menu2g ldab #16 jsr lcd_line1 jsr delay ldx #menu2h ldab #16 jsr lcd_line1 jsr delay jsr delay jmp start3

pes: FCC " System Secure " pass: FCC " Password " pass1: FCC "System Activated" pass2: FCC " NOT ACTIVATED " suc: FCC " SUCCESS " MSG1: FCC " Loading " MSG1a: FCC " Loading. " MSG1b: FCC " Loading.. " MSG1c: FCC " Loading... " pros: FCC " Scanning " pros1: FCC " Scanning. " pros2: FCC " Scanning.. " pros3: FCC " Scanning... "

bit: FCC " port: " bit1: FCC " port: ******** " comp: FCC wel0: wel1: wel2: wel3: FCC FCC FCC FCC " Saved S" " " E" Ahmad Reza Musthafa| 14 "

" " S "S "S

Sistem Keamanan Rumah Assembly Motorola 68HC11 wel4: FCC wel5: FCC wel6: FCC wel7: FCC wel8: FCC wel9: FCC wel10: FCC wel11: FCC wel12: FCC wel13: FCC wel14: FCC wel15: FCC wel16: FCC wel17: FCC wel18: FCC wel19: FCC wel20: FCC wel21: FCC wel22: FCC wel: FCC sis0: sis1: sis2: sis3: FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC FCC "S E " " SE L" " SE L " " SEL A" " SEL A " " SELA M" " SELA M " " SELAM A" " SELAM A " " SELAMA T" " SELAMA T " " SELAMAT " " SELAMAT D" " SELAMAT D " " SELAMAT D A" " SELAMAT DA T" " SELAMAT DAT A" " SELAMAT DATA N" " SELAMAT DATAN G" " SELAMAT DATANG " "s " " Pass " "ter Pass " " Enter Pass " " Ada Penyusup!! " " WARNING " " Situasi Aman " " INFORMASI " "ME NU" " ME NU " " ME NU " " ME NU " " ME NU " " ME NU " " MENU " "me "Game "Game "Game "Game " " I" IR" IRrx"

msg2: msg3: msg4: msg5:

menu1: menu2: menu3: menu4: menu5: menu6: menu7: menu2a: menu2b: menu2c: menu2d: menu2e:

menuirx1: FCC menuirx2: FCC

"==== IRrx ====" "Tes Scan"

menu2f: FCC "= MENU =" menu2g: FCC "== MENU ==" menu2h: FCC "==== MENU ===="

gameawal: FCC " Tebak Kata " gameawal2: FCC "cancel next"

game1: FCC " __K__ " jwb1: FCC "1.tekno 2.teknik" game2: FCC " K_____ " jwb2: FCC "1.kumis 2.kucing" Ahmad Reza Musthafa| 15

Sistem Keamanan Rumah Assembly Motorola 68HC11 game3: FCC " C___ " jwb3: FCC "1.cola 2.cupu" game4: FCC " __M_ " jwb4: FCC "1.bemo 2.game" menangs: FCC " SELAMAT " menangs2: FCC " Anda Menang " kalahs: FCC " MAAF " kalahs2: FCC " Anda Kalah "

segm: fcb $3f,$06,$5b,$4f,$66,$6d,$7d,$07 fcb $7f,$6f,$77,$7c,$39,$5e,$79,$71 fcb $3d,$76,$74,$1e,$38,$54,$63,$5c G, H, h, J L n o o fcb $73,$50,$78,$3e,$1c,$6e,$08,$40 P, r, t, U, u Y - fcb $00,$01,$48,$41,$09,$49 blk, -, =, =, =, = ;0-7 ;8-$0f ;10-17 ;18-1f ;20-23

* *

* * seven_segment: pshx pshb ldx #segm psha anda #$3f tab abx ldaa 0,x ; get segment pulb andb #$80 ; add DP aba pulb pulx rts * start2: lds #STACK ldx #REGBLK * ldaa #11111111b ldaa #$ff ; turn off 7-segment display staa portd,x * ldaa #11111100b ; 0 =input, 1 = output ldaa #$fc staa ddrd,x * ldx #REGBLK ldaa #DB6 staa tmsk1,x cli * begin: ldab #$40 stab disp_data ldab #$40 stab disp_data+1 ldab #$40 stab disp_data+2 ldab #$40 stab disp_data+3 ldx #disp_data jsr move jsr sel_digit ;==========================================================coba switch brset portc,x DB2 begin Ahmad Reza Musthafa| 16

Sistem Keamanan Rumah Assembly Motorola 68HC11 brset portc,x DB4 begin brset portc,x DB6 begin ;===================kondisi clr brclr portc,x DB3 begin brclr portc,x DB5 begin brclr portc,x DB7 begin brclr portc,x DB0 begin brclr portc,x DB1 begin jmp begins ;========================================================== brset porta,x DB0 begin ;jsr delay_10ms brset porta,x DB0 begin jmp passbenar begins: ldab #$bf stab disp_data ldab #$bf stab disp_data+1 ldab #$bf stab disp_data+2 ldab #$bf stab disp_data+3 ldx #disp_data jsr move jsr sel_digit ;==========================================================coba switch brset portc,x DB2 begin ;jsr delay_10ms brset portc,x DB4 begin ;jsr delay_10ms brset portc,x DB6 begin ;jsr delay_10ms brclr portc,x DB3 begin brclr portc,x DB5 begin brclr portc,x DB7 begin brclr portc,x DB0 begin brclr portc,x DB1 begin ;========================================================== brset porta,x DB0 begins ;jsr delay brset porta,x DB0 begins jmp passbenar wait: tst beq clr d5ms_flag wait d5ms_flag

jmp begin start3: lds ldx * ldaa ldaa staa * ldaa ldaa staa * ldx ldaa staa cli #STACK #REGBLK #11111111b #$ff portd,x #11111100b #$fc ddrd,x #REGBLK #DB6 tmsk1,x

; turn off 7-segment display ; 0 =input, 1 = output

Ahmad Reza Musthafa| 17

Sistem Keamanan Rumah Assembly Motorola 68HC11 * begin2: ldab #$bf ;01001001 bf stab disp_data ldab #$bf stab disp_data+1 ldab #$bf stab disp_data+2 ldab #$bf stab disp_data+3 ldx #disp_data jsr move jsr sel_digit beg: ;brset portc,x DB0 beg brclr portc,x DB0 menuir brclr portc,x DB1 gamer brclr porta,x DB0 home jsr delay jmp begin2 ;brset portc,x DB0 beg gamer:jmp game home:jmp start ;start4s:jmp start4 wait2: tst d5ms_flag beq wait clr d5ms_flag jmp begin2 ;==============================ini menu ir menuir: jsr spk_off ldx #menuirx1 ldab #16 jsr lcd_line1 ldx #menuirx2 ldab #16 jsr lcd_line2 jsr delay jsr delay jsr delay jsr delay hem: ldx #REGBLK brclr portc,x DB0 start4 jsr delay_10ms brclr portc,x DB1 start4a jsr delay_10ms brclr porta,x DB0 menunu jmp hem menunu:jmp smenu start4a: lds #STACK jsr delay_10ms jsr delay_10ms ldx #REGBLK clr sccr2,x * ldaa #2 staa ddrd,x clr jsr portd,x lcd_ini Ahmad Reza Musthafa| 18

Sistem Keamanan Rumah Assembly Motorola 68HC11

back4a: ldaa portd+$1000 rora bcs no_IR_light2 ldx #msg3 ldab #16 jsr lcd_line1 ldx #msg2 ldab #16 jsr lcd_line2 jmp back4a no_IR_light2: ldx ldab #16 jsr ldx ldab #16 jsr jsr jsr

#msg5 lcd_line1 #msg4 lcd_line2 delay_10ms delay_10ms

ldx #REGBLK jsr delay brclr porta,x DB0 menuirs jmp back4a start4: lds jsr jsr ldx clr * ldaa staa clr jsr #2 ddrd,x portd,x lcd_ini #STACK delay_10ms delay_10ms #REGBLK sccr2,x

back4: ldaa portd+$1000 rora bcs no_IR_light ldx #msg3 ldab #16 jsr lcd_line1 ldx #msg2 ldab #16 jsr lcd_line2 jmp start0

no_IR_light: ldx ldab #16 jsr ldx ldab #16 jsr jsr jsr

#msg5 lcd_line1 #msg4 lcd_line2 delay_10ms delay_10ms Ahmad Reza Musthafa| 19

Sistem Keamanan Rumah Assembly Motorola 68HC11

ldx #REGBLK jsr delay brclr porta,x DB0 menuirs jmp back4 menuirs:jmp menuir

game: jsr lcd_ini ldaa #$ff staa portd,x ldx #gameawal ldab #16 jsr lcd_line1 ldx #MSG1a ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #MSG1b ldab #16 jsr lcd_line2 jsr delay jsr delay ldx #MSG1c ldab #16 jsr lcd_line2 jsr delay jsr delay jmp passbenar: jsr jmp mulaigame ; turn off 7-segment display

lcd_ini menu

mulaigame: jsr lcd_ini jmp start6

move: ldy mnext: ldaa jsr staa inx iny cpy bne rts sel_digit: ldx inc ldab andb tstb beq decb beq decb beq

#disptn 0,x seven_segment 0,y

#disptn+4 mnext

#REGBLK select select #3 digit3 digit2 digit1 Ahmad Reza Musthafa| 20

Sistem Keamanan Rumah Assembly Motorola 68HC11 * digit0: ldaa staa bclr bset bset bset rts digit1: ldaa staa bset bclr bset bset rts digit2: ldaa staa bset bset bclr bset rts digit3: ldaa staa bset bset bset bclr rts start6: ldx #game1 ldab #16 jsr lcd_line1 ldx #jwb1 ldab #16 jsr lcd_line2 satu: ldx #REGBLK jsr delay brclr portc,x DB1 start7 jsr delay brclr portc,x DB0 kalah ;jsr delay jmp satu disptn portb,x portd,x 4 portd,x 8 portd,x $10 portd,x $20 disptn+1 portb,x portd,x 4 portd,x 8 portd,x $10 portd,x $20 disptn+2 portb,x portd,x 4 portd,x 8 portd,x $10 portd,x $20 disptn+3 portb,x portd,x 4 portd,x 8 portd,x $10 portd,x $20

; matikan digit lainnya

start7: ldx

#game2 ldab #16 jsr lcd_line1 ldx #jwb2 ldab #16 jsr lcd_line2 dua: ldx #REGBLK Ahmad Reza Musthafa| 21

Sistem Keamanan Rumah Assembly Motorola 68HC11 jsr delay brclr portc,x DB0 start8 jsr delay brclr portc,x DB1 kalah ;jsr delay jmp dua start8: ldx

#game3 ldab #16 jsr lcd_line1 ldx #jwb3 ldab #16 jsr lcd_line2 tiga: ldx #REGBLK jsr delay brclr portc,x DB1 start9 jsr delay brclr portc,x DB0 kalah ;jsr delay jmp tiga

start9: ldx

#game4 ldab #16 jsr lcd_line1 ldx #jwb4 ldab #16 jsr lcd_line2 empat: ldx #REGBLK jsr delay brclr portc,x DB0 menang jsr delay brclr portc,x DB1 kalah ;jsr delay jmp empat kalah: jsr lcd_ini kalah2: ldx #kalahs ldab #16 jsr lcd_line1 ldx #kalahs2 ldab #16 jsr lcd_line2 jsr delay jsr delay jsr delay jmp smenu menang: jsr lcd_ini menang2: ldx #menangs ldab #16 jsr lcd_line1 ldx #menangs2 ldab #16 Ahmad Reza Musthafa| 22

Sistem Keamanan Rumah Assembly Motorola 68HC11 lcd_line2 delay delay delay ; jsr lcd_ini jmp smenu jsr jsr jsr jsr

c0 c0s d0 d0s e0 f0 f0s g0 g0s a0 a0s b0

equ equ equ equ equ equ equ equ equ equ equ equ

30578 28862 27242 25714 24270 22908 21622 20409 19263 18182 17161 16198

; 32.703 Hz at 8 MHz ; 34.648 Hz at 8 MHz ; 36.708 Hz at 8 MHz ; 38.890 Hz at 8 MHz ; 41.203 Hz at 8 MHz ; 43.653 Hz at 8 MHz ; 46.249 Hz at 8 MHz ; 48.999 Hz at 8 MHz ; 51.913 Hz at 8 MHz ; 55.000 Hz at 8 MHz ; 58.270 Hz at 8 MHz ; 61.735 Hz at 8 MHz

c8

equ

; for rest note

NOTE_TABLE: fdb fdb fdb * note_c equ note_cs equ note_d equ note_ds note_e equ note_f equ note_fs equ note_g equ note_gsequ note_a equ note_asequ note_b equ

c0,c0s,d0,d0s,e0,f0,f0s,g0,g0s,a0,a0s,b0 0,0,0,0 ; dummy byte c8 0 1 2 equ 4 5 6 7 8 9 10 11

* dur18= 1/8 note, dur14= 1/4 note, $fe= rest_note, $ff = end of song dur132 dur116 dur18 dur14 dur12 start0: lds ldx #STACK #REGBLK equ equ equ equ equ 12 25 50 100 200

ldx #REGBLK ldaa staa ldaa staa * ldx #REGBLK Ahmad Reza Musthafa| 23 #$ff portd,x #$fc ddrd,x

Sistem Keamanan Rumah Assembly Motorola 68HC11 ldaa staa ldx stx * ldx #REGBLK ldaa #DB5+DB6 staa tmsk1,x cli jsr spk_on jsr start_sound lds #STACK ldx #REGBLK bakada: ;inca rola staa portb,x ldx #REGBLK brclr porta,x DB0 menunus jsr delay_10ms jsr delay_10ms jsr start0 jmp bakada menunus:jmp menuir spk_on: pshx ldx #REGBLK bclr tctl1,x OM3 bset tctl1,x OL3 pulx rts spk_off: pshx ldx #REGBLK bset tctl1,x OM3 bclr tctl1,x OL3 pulx rts * tmr6oc2a: ldaa sound_start beq tmr3 ldaa sound_dur deca staa sound_dur bne tmr3 ldx xsound_save repeat: ldab 0,x cmpb #255 beq sound_end ldaa 1,x cmpa #255 beq sound_end staa sound_dur inx inx stx xsound_save cmpb #$fe bne not_rest ldaa #1 staa rest_note jsr spk_off jmp tmr3 #DB6 tmsk1,x #F3500HZ spk_tone

; 3.5KHz

; start sound

; toggle speaker

; turn off speaker

; duration

Ahmad Reza Musthafa| 24

Sistem Keamanan Rumah Assembly Motorola 68HC11 not_rest: clr jsr ldx aslb abx ldx stx jmp sound_end: ldaa beq ldx jmp no_rep: ldx stx jsr clr tmr3: ldx #REGBLK

rest_note spk_on #NOTE_TABLE

0,x spk_tone tmr3 sound_repeat no_rep xsound_beg repeat #F3500HZ spk_tone spk_off sound_start ; 3.5KHz

ldd addd std bclr rti * spk5oc3: ldx ldd addd std bclr rti * * start_sound: ldx stx ldaa staa ldab ldaa staa inx inx stx ldx aslb abx ldx stx ldaa staa rts SONG: fcb fcb

#TB5MS toc2,x toc2,x tflg1,x NOTDB6

#REGBLK spk_tone toc3,x toc3,x tflg1,x NOTDB5

#SONG xsound_beg #1 sound_repeat 0,x 1,x sound_dur

xsound_save #NOTE_TABLE

0,x spk_tone #1 sound_start

$50+note_e,dur18 $fe,dur18 Ahmad Reza Musthafa| 25

Sistem Keamanan Rumah Assembly Motorola 68HC11 fcb 255,255

org jmp org jmp tmr6oc2: ldx inc ldd addd std bclr rti org jmp end

JTOC3 spk5oc3 JTOC2 tmr6oc2a

#REGBLK d5ms_flag #TB5MS toc2,x toc2,x tflg1,x NOTDB6

JTOC2 tmr6oc2

Ahmad Reza Musthafa| 26