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

INT_V	equ 42h*4

STACK EQU 540H

	org 1000h
	
	xor bx,bx
	mov es,bx
	mov ds,ax
	mov ss,bx
	mov sp,STACK
	
	mov ax ,offset INT_SERVICE	
	mov bx,INT_V
	mov word ptr es:[bx],ax
	
	xor ax,ax
	mov word ptr es:[bx+2],ax
	
	call INIT
	
	;initialize
	mov al , 10000000b
	out PPIC_C,al
	

	
   LABLE:
    mov si,offset DATA
	
	mov al, byte ptr CS:[si]
	out PPIA,al

	STI
	
	L2:
	NOP
JMP L2
	
INT_SERVICE:
	
L3:	out PPIA,al
	INC si
	MOV AL,BYTE PTR[SI]
	out PPIA,al

	CMP AL,00H
	
	
	JZ L4
	JMP L5
	L4:
	mov si,offset DATA
	L5:
	mov al,20H ;OCW2
	out INTA,al
	STI	
	IRET
	
	
	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

  DATA:  DB  11000000B ; “P G F E D C B A” values for number 0 
  DB  11111001B 
  DB  10100100B 
  DB  10110000B 
  DB  10011001B 
  DB  10010010B 
  DB  10000010B 
  DB  11111000B 
  DB  10000000B 
  DB  10010000B 
  DB 00H
  
  WAIT1 PROC NEAR
	MOV CX,0FFH
	LABLE12:
	NOP
	NOP
	LOOP LABLE12
	
	
	RET
	WAIT1 endp
  
  
 
	code ends
	end

