mikroprosesor tentang peta memori tanpa gambar
TRANSCRIPT
UJIAN TENGAH SEMESTERMIKROPROSESOR DAN ANTARMUKA
RANGKAIAN PROGRAM DAN APLIKASI SISTEM MINIMUM 8088 UNTUK APLIKASI KEYPAD, LCD, DOT MATRIKS DAN PIT
OLEH :YOFI SEPTRINO ASHAR
0910953100
DOSEN :Ir. DARWISON, MT
JURUSAN TEKNIK ELEKTROFAKULTAS TEKNIK
UNIVERSITAS ANDALAS2010
RANGKAIAN PROGRAM DAN APLIKASI SISTEM MINIMUM 8088 UNTUK APLIKASI KEYPAD, LCD, DOT DAN PIT
RAM0 (2KB)
Kosong
Kosong
RAM1 (8KB)
EPROM27128 ( 16 KB )
00000H
007FFH
FC000H
40300H
21FFFH
40303H
20000H
kosong
PPI 0
PPI 1
kosong
FFFFFH
60300H
60303H
kosong
PIC FC000H
FC000H
TUGAS
Rangkaian Program dan Aplikasi Sistem Minimum 8088 Untuk Aplikasi Keypad, LCD,
Dot Matriks Skala Besar Dan Sensor Jarak SHARP GP2D02yang terdiri dari :
p 8088
RAM-0 6116 ( 2 KB )
RAM-1 6264 ( 8 KB )
EPROM 27128 ( 16 KB )
PPI 8255 (2 buah)
PIC 8259 (1 buah)
Peta memori
Tabel Kebenaran untuk peta memori di atas adalah :
Tipe
memori
Alamat Ket
A19 – A16 A15 – A12 A11 – A8 A7 – A4 A3 – A0
RAM-0
6116
( 2 KB )
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Awal (00000H)
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 Akhir (007FFH)
0 0 0 0 0 0 0 0 0 x x x x x x x x x x x Kapasitas (7FFH)
RAM-1
6264
( 8 KB )
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Awal (20000H)
0 0 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 Akhir (21FFFH)
0 0 0 0 0 0 0 x x x x x x x x x x x x x Kapasitas (1FFFH)
PPI-0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 Awal (40300H)
0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 Akhir (40303H)
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 x x Kapasitas (3H)
PP-1 0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 Awal (60300H)
0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 Akhir (60300H)
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 x x Kapasitas (3H)
PIC 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Awal (80000H)
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Akhir (80001H)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x Kapasitas (1H)
EPROM
27128
( 16 KB )
1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Awal (FC000H)
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Akhir (FFFFFH)
0 0 0 0 0 0 x x x x x x x x x x x x x x Kapasitas (3FFF)
Tabel dari pin – pin dekoder yang digunakan
Tipe memori Kapasitas Alamat Ket
A19 A18 A17
memori
RAM-0 6116 2 KB 0 0 0 Y0
RAM-1 6264 8 KB 0 0 1 Y1
PPI-0 0 1 0 Y2
PPI-1 0 1 1 Y3
PIC 1 0 0 Y4
EPROM 27128 16 KB 1 1 1 Y7
Menentukan alamat jump reset
ROM yang digunakan adalah 16 Kb
FFFFF (µP 8088 mampu mengakses 1 Mb)
3FFF (Kapasitas ROM)
FC000 (awal EPROM)
FFFF0 (tempat jump reset pada 8088)
FC000 (awal EPROM)
3FF0 (lokasi jump reset pada EPROM 16 Kb)
Misal origin yang diinginkan adalah 200H sehingga perhitungannya adalah.
FC000 : FC00 : 0000 (org 0H)
200
FBE00 : FBE0 : 0200 (org 200H)
Program listing
; DIGUNAKAN UNTUK MENAMPILKAN DATA DARI KEYPAD KE DISPLAY LCD
; DATA LCD : PA; E : PB5; RS : PB6
; data keypad; PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0; OE X X X B A D C
CODE_SEG SEGMEN ; code_seg sebagai segmen ASSUME CS:CODE_SEG,DS:C0DE_SEG,SS:CODE_SEG ORG 100H ; program ditulis mulai origin 100h
start: jmp mulai ; Awal program pada Org 100h
pa2 equ 304hpb2 equ 305hpc2 equ 306hcw2 equ 307h
DISPCLR EQU 00000001BFUNCSET EQU 00111000BENTRMOD EQU 00000110BDISPON EQU 00001100B
awal db ?data db ?dat_key db ?ratusan db ?puluhan db ?satuan db ?akhir db ?
mulai:Mov AX, CS ; Menyamakan data segmen dengan code
; segmenMov DS, AXXor AX, AX ; Mengenolkan ES dan SS supaya
; mengarah pada alamat RAM Minimum SistemMov ES, AX ; ES = 0 -> segmen address RAMMov SS, AX ; SS = 0 -> segmen address RAm
Lea SI, Awal ; menyalin data dari ROM ke RAMLea CX, Akhir ; CX diisi offset AkhirDtMov DI, SI ; DI = [SI]Sub Cx, SI ; CX = [cx]-[SI] = AkhirDt-AwalDt
; = jumlah data
Cld ; membuat direction flag = 0 -> SI&DI; incremented
Rep Movsb ; ulang {ES:[DI]<-DS:[SI]} sebanyak [CX]
Mov SP,2000h ; SP = 2000h = 8Kb->nilai maksimum RAM
Xor AX,AX ; menolkan data segmen agar menunjuk; alamat data di RAM yang telah; disalinkan dari ROm pada sistem min
Mov DS,AX ; DS = 0 -> segmen address RAM
mov al,10000000bmov dx,cwout dx,al
call init_lcd
putar:mov dx,pc2 ; status tombol ditekan PC7 = 0in al,dxand al,128cmp al,128je putar
in al,dxand al,00001111bcall konv_keypad_to_binmov data_key,al
mov data,80hcall controlout
mov al,data_keymov ah,0add ax,30hmov data,alcall dataout
tunggu:mov dx,pc2 ; status tombol dilepas PC7 = 1in al,dxand al,128cmp al,0je tunggu
jmp putar
; PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0
; OE X X X B A D C KEY; 0 1 0 0 1; 1 0 0 0 2; 1 1 0 0 3; 0 0 0 1 4; 0 1 0 1 5; 1 0 0 1 6; 1 1 0 1 7; 0 0 1 0 8; 0 1 1 0 9; 1 0 1 0 0; 1 1 1 0 *; 0 0 1 1 #
konv_keypad_to_bin proc nearcmp al,4jne klmov al,1ret
k1:cmp al,8jne k2mov al,2ret
k2:cmp al,12jne k3mov al,3ret
k3:cmp al,1jne k4mov al,4ret
k4:cmp al,4jne k5mov al,4ret
k5:cmp al,5jne k6mov al,5ret
k6:cmp al,9jne k7mov al,6
retk7:
cmp al,13jne k8mov al,7ret
k8:cmp al,2jne k9mov al,8ret
k9:cmp al,6jne k0mov al,9ret
k0:cmp al,10jne kbmov al,0ret
kb:cmp al,14jne kpmov al,14ret
kp:cmp al,3jne metumov al,3ret
metu:ret
konv_keypad_to_bin endp
;----------------------------; PEMESANAN TEMPAT;----------------------------; E : PB0 : 0 1 0; RS : PB1 : 0controlout proc near
mov dx,pb2mov al,0out dx,alcall delay_lcd
mov dx,pb2mov al,1
out dx,alcall delay_lcd
mov dx,pa2mov al,dataout dx,alcall delay_lcd
mov dx,pb2mov al,0out dx,alcall delay_lcdret
controlout endp
;----------------------------; PENEMPATAN DATA;----------------------------; E : PB0 : 0 1 0; RS : PB1 : 1dataout proc near
mov dx,pb2mov al,2out dx,alcall delay_lcd
mov dx,pb2mov al,3out dx,alcall delay_lcd
mov dx,pa2mov al,dataout dx,alcall delay_lcd
mov dx,pb2mov al,2out dx,alcall delay_lcdret
dataout endp
;-----------------------------; INISIALISASI LCD;-----------------------------init_lcd proc near
mov data,DISPCLR
call controloutcall delay_lcd
mov data,FUNCSETcall controloutcall delay_lcd
mov data,ENTRMODcall controloutcall delay_lcd
mov data,DISPONcall controloutcall delay_lcdret
init_lcd endp
delay_lcd proc near ; procedure delaypush cx ; simpan cxmov cx,01fffh ; isi cx dengan lama delayloop $ ; loopng sampai cx=0pop cx ; keluarkan cxret ; kembali ke program utama
delay_lcd endp ; akhir procedure delay
delay proc near ; procedure delaypush cx ; simpan cxmov cx,0ffffh ; isi cx dengan lama delayloop $ ; loopng sampai cx=0pop cx ; keluarkan cxret ; kembali ke program utama
delay endp ; akhir procedure delay
ORG 20F0H ; alamat yang dituju setelah resetDB 0EAH ; JMP reset keDW 0100H ; alamat offset 0100hDW 0FDF0H ; alamat segmen 0FBFH
CODE_SEG ENDS ; batas segmen code_seg END START ; akhir program
;---------------------------------------------------; APLIKASI PIC (PROGRAMMABLE INTERRUPT CONTROLLER);---------------------------------------------------CODE_SEG SEGMENT ; code_seg sebagai segment
ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEG ORG 100H ; program ditulis mulai origin 100h
start: jmp mulai ; Awal program pada Org 0100H
porta equ 00h ; Menentukan alamat port A,B,Cportb equ 01h ; dan ctrlword sesuai denganportc equ 02h ; hardwarenyacw equ 03hpica equ 04hpicb equ 05hicw1 equ 00010011b ;edge triggered, single, ICW4icw2 equ 00001000bicw4 equ 00000001bocw1 equ 11111100b ; ir0 dan ir1 enable
; ir2-ir7 disable
awal db ?data1 db ?data2 db ?akhir db ?
mulai: Mov AX, CS ; Menyamakan data segment dengan code segment Mov DS, AX Xor AX, AX ; Mengenolkan ES dan SS supaya ; mengarah pada alamat RAM Minimum Sistem Mov ES, AX ; ES = 0 -> segment address RAM Mov SS, AX ; SS = 0 -> segment address RAM
Lea SI, Awal ; menyalin data dari ROM ke RAM Lea CX, Akhir ; CX diisi offset AkhirDt Mov DI, SI ; DI = [SI] Sub CX, SI ; CX = [CX]-[SI] = AkhirDt-AwalDt
; = jumlah data Cld ; Membuat Direction flag = 0 -> SI&DI incremented Rep Movsb ; ulang { ES:[DI] <-- DS:[SI] } sebanyak [CX]
Mov SP,2000h ; SP = 2000h = 8Kb -> nilai maksimum RAM
Xor AX,AX ; Menolkan data segment agar menunjuk alamat data di RAM yang telah disalinkan
; dari ROM pada sistem minimum Mov DS,AX ; DS = 0 -> segment address RAM
lea bx,animasi1mov es:[20h],bxmov es:[22h],cs ; ir0
lea bx,animasi2mov es:[24h],bxmov es:[26h],cs ; ir1
mov al,icw1mov dx,picaout dx,al ; ICW1 dikeluarkan
mov al,icw2mov dx,picbout dx,al ; ICW2 dikeluarkan
mov al,icw4mov dx,picbout dx,al ; ICW4 dikeluarkan
mov al,ocw1mov dx,picbout dx,al ; OCW1 dikeluarkan
mov al,80h ; inisialisasi ppi mov dx,cw out dx,al ; semua port output
call offsti
lagi:call kedipjmp lagi
;------------------------; prosedur untuk pooling;------------------------kedip proc near
call offcall delay
call oncall delayret
kedip endp
;--------------------; prosedur untuk ir0;--------------------animasi1 proc near
pushf
push axpush cxpush dxcall offmov data1,1mov data2,128mov cx,8
putarA_C:mov dx,portamov al,data1not alout dx,alnot alshl al,1mov data1,al
mov dx,portcmov al,data2not alout dx,alnot alshr al,1mov data2,alcall delayloop putarA_Ccall off
mov data1,00000001bmov data2,10000000bmov cx,4
putarB:mov dx,portbmov al,data1or al,data2not alout dx,alcall delay
mov al,data1shl al,1mov data1,al
mov al,data2shr al,1mov data2,al
loop putarBcall off
mov al,00100000b ;ocw2 non specific EOImov dx,picaout dx,alpop dxpop cxpop axpopfiret
animasi1 endp
;--------------------; prosedur untuk ir1;--------------------animasi2 proc near
pushfpush axpush cxpush dxcall offmov data1,00010000bmov data2,00001000bmov cx,4
putarB2:mov dx,portbmov al,data1or al,data2not alout dx,alcall delay
mov al,data1shr al,1mov data1,al
mov al,data2shl al,1mov data2,al
loop putarB2call off
mov data1,128mov data2,1mov cx,8
putarA_C2:mov dx,portamov al,data1not al
out dx,alnot alshr al,1mov data1,al
mov dx,portcmov al,data2not alout dx,alnot alshl al,1mov data2,alcall delayloop putarA_C2call offmov al,00100000b ; ocw2 non specific EOImov dx,picaout dx,al ; ocw2 dikeluarkan dengan A0 = 0pop dxpop cxpop axpopfiret
animasi2 endp
off proc nearmov al,255mov dx,portaout dx,al
mov dx,portbmov al,255out dx,al
mov dx,portcmov al,255out dx,alret
off endp
on proc nearmov al,0mov dx,portaout dx,al
mov dx,portbmov al,0out dx,al
mov dx,portcmov al,0out dx,alret
on endp
delay proc near ; Procedure delaypush cx
mov cx,0ffffh ; isi cx dengan lama delay loop $ ; loopng sampai cx=0 pop cx ; keluarkan cx ret ; kembali ke program utamadelay endp ; akhir procedure delay
; ROM 2764 ORG 20F0H ; alamat yang dituju setelah reset DB 0EAH ; JMP reset ke DW 0100H ; alamat offset 0100h DW 0FDF0H ; alamat segmen 0FDFh
CODE_SEG ENDS ; batas segment code_seg END START ; akhir program
;-------------------------------------; Scanning Keypad Heksa;-------------------------------------PORTA EQU 300hPORTB EQU 301hPORTC EQU 302hCWORD EQU 303h
INIT EQU 99h ; A input mode 0; B input mode 0; C input mode 0
jmp main
Table db 'A1470258B369CDEF'
main:mov al,INIT ; initialize PPImov dx,CWORDout dx,al ; send to Control Word
Again:xor bx,bx ; zero table indexmov ah,11110111b ; set pattern for outputmov cx,4 ; loop 4 times
ColScan:mov dx,PORTBmov al,ah ; output patternout dx,al
mov dx,PORTAmov al,dx ; read key statusnot aland al,00001111b ; mask it
jz NextCol ; zero means no key pressedpush cxmov cx,4 ; loop 4 times
RowScan:shr al,1 ; shift data into carryjz Gotlt ; zero means it is the datainc bx ; else continuekoop RowScanpop cx ; recover okd counter
NextCol:add bx,4 ; next coulomn table entryshr ah,1 ; geser pola ke kolom lain
loop ColScan ; next coulomn
NoKey:jmp ReadKey ; no key pressed...
Gotlt:pop cx ; purge stackmov cx,1000
1: loop1 ; delay to debouncecall printmov cx,0ffffh ; wait for type matic
Wait:mov dx,PORTAmov al,dx ; wait for key upnot aland al,00001111bloopnz Wait ; still down
or cx,cx ; cx = means time outjz Print ; if time out then print
; character
jmp ReadKey ; else read key from PC
Print:call Printmov cx,0fffh ; typematic ratejmp Wait ; wait again
ReadKey:mov ah,1int 16h ; is any key pressed in PCjz Again ; no, lets scan again
mov ah,0 ; yes, then flush itint 16hint 20h ; back to DOS
; this routine will print character vai BIOS call; input : AK - character to print; output : None; All register not effectedPrint PROC
push axmov al,Table[bx]mov al,0Eh ; BIOS writettyint 10hpop axret
Print ENDP
;-----------------------------------------------------------------; PROGRAM DIGUNAKAN UNTUK DISPLAY DOT MATRIK DARI KANAN KE KIRI;-----------------------------------------------------------------
CODE_SEG SEGMENT ; code_seg sebagai segment ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEG,ES:CODE_SEG ORG 100H ; program ditulis mulai origin 100h
start: jmp mulai ; Awal program pada Org 0100H
PA equ 00h ; Menentukan alamat port A,B,CPB equ 01h ; dan ctrlword sesuai denganPC equ 02h ; hardwarenyacw equ 03h
awal db ?VAR1 DB ?VAR2 DW ?
DATA DB 7EH,09H,09H,09H,7EH,00H ;ADB 7FH,49H,49H,49H,36H,00H ;BDB 3EH,41H,41H,41H,41H,00H ;CDB 7FH,41H,41H,41H,3EH,00H ;DDB 7FH,49H,49H,49H,49H,00H ;EDB 7FH,09H,09H,09H,09H,00H ;FDB 3EH,41H,49H,49H,39H,00H ;GDB 7FH,08H,08H,08H,7FH,00H ;HDB 7FH,00H ;IDB 00H,30H,41H,41H,3FH,00H ;JDB 7FH,08H,14H,22H,41H,00H ;KDB 7FH,40H,40H,40H,40H,00H ;LDB 7FH,02H,04H,02H,7FH,00H ;MDB 7FH,02H,04H,08H,7FH,00H ;NDB 3EH,41H,41H,41H,3EH,00H ;ODB 7FH,09H,09H,09H,06H,00H ;PDB 3EH,41H,49H,51H,3EH,00H ;QDB 7FH,09H,19H,29H,46H,00H ;RDB 26H,49H,49H,49H,32H,00H ;SDB 01H,41H,7FH,41H,01H,00H ;TDB 3FH,40H,40H,40H,3FH,00H ;U
DB 00H,00H,00H,00H,00H,00H DB 00H,00H,00H,00H,00H,00H
DB 00H,00H,00H,00H,00H,00HDB 00H,00H,00H,00H,00H,00HDB 00H,00H,00H,00H,00H,00H
akhir db ?
mulai: Mov AX, CS ; Menyamakan data segment dengan code segment Mov DS, AX Xor AX, AX ; Mengenolkan ES dan SS supaya ; mengarah pada alamat RAM Minimum Sistem Mov ES, AX ; ES = 0 -> segment address RAM Mov SS, AX ; SS = 0 -> segment address RAM
Lea SI, Awal ; menyalin data dari ROM ke RAM Lea CX, Akhir ; CX diisi offset AkhirDt Mov DI, SI ; DI = [SI] Sub CX, SI ; CX = [CX]-[SI] = AkhirDt-AwalDt ; = jumlah data Cld ; Membuat Direction flag = 0 -> SI&DI incremented Rep Movsb ; ulang { ES:[DI] <-- DS:[SI] } sebanyak [CX]
Mov SP,2000h ; SP = 2000h = 8Kb -> nilai maksimum RAM
Xor AX,AX ; Menolkan data segment agar menunjuk alamat data di RAM yang telah disalinkan ; dari ROM pada sistem minimum Mov DS,AX ; DS = 0 -> segment address RAM
mov al,80h ; init ppi mov dx,cw ; pada 80H MODE = 0 out dx,al ; port AC = output, B = input
MANEH:CALL SIJIJMP MANEH
SIJI PROC NEARMOV CX,01H
PUTAR: PUSH CXLEA BX,DATAMOV VAR1,37HMOV VAR2,00HDEC VAR1
LOP1: MOV SI,VAR2MOV AH,37H
LOP: DEC AHDEC SIMOV DX,PAMOV AL,BYTE PTR[BX+SI]OUT DX,ALCALL OUTUCALL DELAY
LOP2: CMP AH,VAR1JNE LOP
MOV SI,VAR2INC VAR2
MOV AH,VAR1DEC VAR1CMP VAR1,00HJNE LOP1JMP LOP13
PUTAR1: JMP PUTAR
LOP13: MOV VAR2,00HLOP4: MOV SI,VAR2
MOV VAR1,00HLOP3: MOV DX,PA
MOV AL,BYTE PTR[BX+SI]
OUT DX,ALCALL OUTICALL DELAY
INC VAR1CMP SI,90HJE LOP5INC SI
LOP5: CMP VAR1,37HJNE LOP3MOV SI,VAR2INC VAR2CMP VAR2,90HJNE LOP4CALL DELAYMOV DX,PAMOV AL,00HOUT DX,ALCALL DELAYPOP CXLOOP PUTAR1RET
SIJI ENDP
OUTI PROC NEARMOV DX,PBMOV AH,VAR1MOV AL,AHOUT DX,ALRET
OUTI ENDP
OUTU PROC NEARMOV DX,PBMOV AL,AHOUT DX,ALRET
OUTU ENDP
DELAY PROC NEARMOV CX,10 ; 1ffh
LAGI: PUSH CXMOV CX,10 ; 18hLOOP $POP CXLOOP LAGIRET
DELAY ENDP
; ROM 2764 ORG 20F0H ; alamat yang dituju setelah reset DB 0EAH ; JMP reset ke DW 0100H ; alamat offset 0100h DW 0FDF0H ; alamat segmen 0FDFh
CODE_SEG ENDS ; batas segment code_seg END start ; akhir program
;Program passwordSTART: JMP MULAIKATA DB 'MASUKAN PASSWORD ANDA DISINI : $'PASSWORD DB '06175046'PASSWORD1DB 4,?,4 DUP(?)KATA1 DB 13,10, 'PASSWORD ANDA SALAH ULANGI
LAGI !',13,10,13,10,'$'KATA2 DB 13,10, 'PASSWORD ANDA BENAR !',13,10,13,10,'$'MULAI: MOV AH,09H
MOV DX,OFFSET KATAINT 21H ;MENCETAK KATAMOV AH,0AHMOV DX,OFFSET PASSWORD1 ;AMBIL PASSWORDINT 21HPUSH DSPOP ES ;ES=DSMOV DI,OFFSET PASSWORDMOV SI,OFFSET PASSWORD1 + 2MOV CX,03HCLD ;PROSES KE BAWAH
ULANG: CMPSB ;PROSES CMPSBJC SALAH ;JIKA TIDAK SAMA KE SALAHLOOP ULANGMOV AH,09HMOV DX,OFFSET KATA2INT 21H ;CETAK KATAMOV AH,4CHINT 21H ;AKHIR PROGRAM
SALAH: MOV AH,09HMOV DX,OFFSET KATA1INT 21H ;CETAK KATAJMP MULAI ;LONCAT KE MULAI
; PROG13.ASM APLIKASI PIT (PROGRAMMABLE INTERVAL TIMER); POSISI GATE 0 = 0; GATE 1 = 0
; GATE 2 = 0; CLK2INT; OUTPUT CLK PADA TERMINAL BIRU OUT2
;----------------------------------------; control word PIT;----------------------------------------; D7 D6 D5 D4 D3 D2 D1 D0; SC1 SC0 RL1 RL0 M2 M1 M0 BCD
;---------; SC1 SC0;---------; 0 0 counter 0; 0 1 counter 1; 1 0 counter 2; 1 1 illegal
;---------; RL1 RL0;---------; 0 0 counter latching operation; 0 1 read/load hanya MSB; 1 0 read/load hanya LSB; 1 1 read/load LSB kemudian MSB
;----------; M2 M1 M0;----------; 0 0 0 mode 0intterupt on terminal count; 0 0 1 mode 1hardware retriggerable one shot; 0 1 0 mode 2time intterupt; 0 1 1 mode 3square wave generator; 1 0 0 mode 4software trigger strobe; 1 0 1 mode 5hardware trigger strobe
;-----; BCD;-----; 0 binary counter 16 bit; 1 BCD counter
CODE_SEG SEGMENT ; code_seg sebagai segment ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEG ORG 100H ; program ditulis mulai origin 100h
start: jmp mulai ; Awal program pada Org 0100H
pit0 equ 08h ; timer 0pit1 equ 09h ; timer 1pit2 equ 0ah ; timer 2pitcw equ 0bh ; control word
; clock input di clk2 = 2 MHz; untuk menjadikan out 2 = 1 KHz, maka dibagi 2000 = 20H 00H
mulai:mov al,10110111b ; 1 kHz square wave, LSB then MSB, BCDmov dx,pitcwout dx,al
; faktor pembagi 2000h = 20h 00hmov dx,pit2 ; counter 2mov al,00hout dx,al ; LSB of count
mov al,20hout dx,al ; MSB of count
lagi:jmp lagi
; ROM 2764 ORG 20F0H ; alamat yang dituju setelah reset DB 0EAH ; JMP reset ke DW 0100H ; alamat offset 0100h DW 0FDF0H ; alamat segmen 0FDFh
CODE_SEG ENDS ; batas segment code_seg END START ; akhir program