code segment
assume cs:code,ds:code,es:code,ss:code

PPIC_C	EQU 1FH
PPIC	EQU 1dh
PPIB	EQU 1bh
PPIA	EQU 19h

INTA equ 10H
INTA2 equ 12H

	org 1000h
	
	call INIT
	
	mov al , 10000000b
	out PPIC_C,al
	
	mov al,11111111b
	out PPIA,al
	
	mov al,00000000b
	out PPIC,al
	
	mov ah,11110001b
	mov al,ah
	out PPIB , al 
	
L2:	mov al, 0CH ;OCW3
	out INTA,al
	in AL,INTA
	test al,80H
	JZ L2
	
	SHL AH,1
	test ah,00010000b
	JNZ L1
	OR ah,11110000b
	JMP L3
	
L1:	mov ah,11110001b
L3:	mov al,ah
	out PPIB,al
	
	mov al,20H ;OCW2
	out INTA,al
	JMP L2
	
	INIT PROC NEAR
	;ICW1
	MOV AL,13H
	OUT INTA,AL
	;ICW2
	MOV AL,40H
	OUT INTA2,AL
	;ICW4
	MOV AL,01H
	OUT INTA2,AL
	;inturrupt mask
	;OCW1
	MOV AL,11111011B
	OUT INTA2,AL
	
	
	
	
	RET
	INIT endp
	
	code ENDS
	end