DATA_1E		EQU	20H
DATA_6E		EQU	7CEH
  
SEG_A		SEGMENT	BYTE PUBLIC
		ASSUME	CS:SEG_A, DS:SEG_A
  
  
		ORG	100h
  
PHONE		PROC	FAR
  
START:
		CALL	SUB_9			
		MOV	AX,3
		INT	10H
		CALL	SUB_10			
		MOV	AX,100H
		MOV	CX,2000H
		INT	10H
LOC_1:
		MOV	CX,6
  
LOCLOOP_2:
		CALL	SUB_6			
		CALL	SUB_1			
		CALL	SUB_11			
		CALL	SUB_4			
		CALL	SUB_7			
		CALL	SUB_2			
		CALL	SUB_12			
		CALL	SUB_4			
		LOOP	LOCLOOP_2
  
		MOV	CX,0AH
		CALL	SUB_8			
		CALL	SUB_3			
		CALL	SUB_13			
  
LOCLOOP_3:
		CALL	SUB_4			
		CALL	SUB_4			
		LOOP	LOCLOOP_3
  
		JMP	SHORT LOC_1		
  
PHONE		ENDP
  
  
SUB_1		PROC	NEAR
		MOV	DX,3F2H
		MOV	AL,10H
		OUT	DX,AL
		RETN
SUB_1		ENDP
  
  
SUB_2		PROC	NEAR
		MOV	DX,3F2H
		MOV	AL,21H			
		OUT	DX,AL
		RETN
SUB_2		ENDP
  
SUB_3		PROC	NEAR
		MOV	DX,3F2H
		MOV	AL,0
		OUT	DX,AL
		RETN
SUB_3		ENDP
  
  
SUB_4		PROC	NEAR
		PUSH	CX
		MOV	CX,64H
  
LOCLOOP_4:
		CALL	SUB_5			
		LOOP	LOCLOOP_4
  
		MOV	AH,1
		INT	16H
		JNZ	LOC_6
		POP	CX
		RETN
  
SUB_5:
		PUSH	CX
		MOV	CX,CS:DATA_2
  
LOCLOOP_5:
		LOOP	LOCLOOP_5
  
		POP	CX
		RETN
LOC_6:
		MOV	AH,0
		INT	16H
		CALL	SUB_8			
		CALL	SUB_3			
		MOV	AX,3
		INT	10H
		MOV	AH,4CH			
		INT	21H
SUB_4		ENDP
  
  
  
SUB_6		PROC	NEAR
		MOV	BX,952H
		JMP	SHORT LOC_7		
		DB	90H
  
  
SUB_7:
		MOV	BX,5D3H
LOC_7:
		MOV	AL,0B6H
		OUT	40H,AL			
		MOV	AL,BL
		OUT	42H,AL			
		MOV	AL,BH
		OUT	42H,AL			
		IN	AL,61H			
		OR	AL,3
		OUT	61H,AL			
		RETN
SUB_6		ENDP
  
  
SUB_8		PROC	NEAR
		IN	AL,61H			
		AND	AL,0FCH
		OUT	61H,AL			
		RETN
SUB_8		ENDP
  
  
SUB_9		PROC	NEAR
		CLI
		MOV	AL,36H			
		OUT	43H,AL			
		MOV	AL,0A9H
		OUT	40H,AL			
		MOV	AL,4
		OUT	40H,AL			
		XOR	AX,AX
		MOV	ES,AX
		MOV	DI,DATA_1E
		PUSH	WORD PTR ES:[DI]
		PUSH	WORD PTR ES:[DI+2]
		MOV	WORD PTR ES:[DI],20AH
		MOV	ES:[DI+2],CS
		XOR	CX,CX
		XOR	BX,BX
		MOV	DX,3E9H
		STI
LOC_8:
		CMP	DX,3E9H
		JE	LOC_8
LOC_9:
		INC	CX
		JNZ	LOC_10
		INC	BX
LOC_10:
		OR	DX,DX
		JNZ	LOC_9
		CLI
		POP	WORD PTR ES:[DI+2]
		POP	WORD PTR ES:[DI]
		MOV	AL,36H			
		OUT	43H,AL			
		MOV	AL,0
		OUT	40H,AL			
		OUT	40H,AL			
		STI
		XOR	AX,AX
		PUSH	AX
		MOV	AX,3E9H
		PUSH	AX
		PUSH	BX
		PUSH	CX
		CALL	SUB_14			
		MOV	CS:DATA_2,AX
		RETN
SUB_9		ENDP
  
		PUSH	AX
		DEC	DX
		MOV	AL,20H			
		OUT	20H,AL			
		POP	AX
		IRET
DATA_2		DW	0
  
  
SUB_10		PROC	NEAR
		PUSH	CS
		POP	ES
		MOV	BP,OFFSET DATA_3
		MOV	DX,0B5H
		MOV	CX,3
		MOV	BX,0E00H
		MOV	AX,1100H
		INT	10H
		MOV	BP,OFFSET DATA_4
		MOV	DX,0C5H
		MOV	CX,3
		MOV	BX,0E00H
		MOV	AX,1100H
		INT	10H
		MOV	BP,OFFSET DATA_5
		MOV	DX,0D5H
		MOV	CX,3
		MOV	BX,0E00H
		MOV	AX,1100H
		INT	10H
		RETN
SUB_10		ENDP
  
  
  
SUB_11		PROC	NEAR
		MOV	AX,0B800H
		MOV	ES,AX
		MOV	DI,DATA_6E
		MOV	WORD PTR ES:[DI],0CB5H
		MOV	WORD PTR ES:[DI+2],0CB6H
		MOV	WORD PTR ES:[DI+4],0CB7H
		RETN
SUB_11		ENDP
  
  
  
SUB_12		PROC	NEAR
		MOV	AX,0B800H
		MOV	ES,AX
		MOV	DI,DATA_6E
		MOV	WORD PTR ES:[DI],0CC5H
		MOV	WORD PTR ES:[DI+2],0CC6H
		MOV	WORD PTR ES:[DI+4],0CC7H
		RETN
SUB_12		ENDP
  
  
  
SUB_13		PROC	NEAR
		MOV	AX,0B800H
		MOV	ES,AX
		MOV	DI,DATA_6E
		MOV	WORD PTR ES:[DI],0CD5H
		MOV	WORD PTR ES:[DI+2],0CD6H
		MOV	WORD PTR ES:[DI+4],0CD7H
		RETN
SUB_13		ENDP
  
DATA_3		DB	0
		DB	 00H, 0FH, 1FH, 3CH, 01H, 03H
		DB	 04H, 09H, 12H, 20H, 7FH, 40H
		DB	 7FH, 00H, 00H,0E0H, 1FH, 07H
		DB	 8DH,0FEH, 01H, 54H,0AAH, 00H
		DB	0FFH, 00H,0FFH, 00H, 00H, 00H
		DB	 80H,0C0H,0E0H, 10H, 08H, 88H
		DB	 48H, 24H,0F4H, 18H,0F0H
DATA_4		DB	0
		DB	 00H, 00H, 0FH, 1FH, 3DH, 03H
		DB	 04H, 09H, 12H, 20H, 7FH, 40H
		DB	 7FH, 00H, 00H, 3FH,0C7H, 01H
		DB	 8CH,0FEH, 01H, 54H,0AAH, 00H
		DB	0FFH, 00H,0FFH, 00H, 00H, 80H
		DB	0C0H,0E0H, 10H, 08H, 08H, 88H
		DB	 44H, 24H,0F4H, 18H,0F0H
DATA_5		DB	0
		DB	 00H, 00H, 0FH, 1FH, 3DH, 03H
		DB	 04H, 09H, 12H, 20H, 7FH, 40H
		DB	 7FH, 00H, 00H, 00H,0FFH, 07H
		DB	 8DH,0FEH, 01H, 54H,0AAH, 00H
		DB	0FFH, 00H,0FFH, 00H, 00H, 00H
		DB	 80H,0C0H,0E0H, 10H, 10H, 88H
		DB	 44H, 24H,0F4H, 18H,0F0H
  
  
SUB_14		PROC	NEAR
		POP	CX
		PUSH	CS
		PUSH	CX
		XOR	CX,CX
		JMP	SHORT LOC_11		
		POP	CX
		PUSH	CS
		PUSH	CX
		MOV	CX,1
		JMP	SHORT LOC_11		
		POP	CX
		PUSH	CS
		PUSH	CX
		MOV	CX,2
		JMP	SHORT LOC_11		
		POP	CX
		PUSH	CS
		PUSH	CX
		MOV	CX,3
LOC_11:
		PUSH	BP
		PUSH	SI
		PUSH	DI
		MOV	BP,SP
		MOV	DI,CX
		MOV	AX,[BP+0AH]
		MOV	DX,[BP+0CH]
		MOV	BX,[BP+0EH]
		MOV	CX,[BP+10H]
		OR	CX,CX
		JNZ	LOC_12
		OR	DX,DX
		JZ	LOC_20
		OR	BX,BX
		JZ	LOC_20
LOC_12:
		TEST	DI,1
		JNZ	LOC_14
		OR	DX,DX
		JNS	LOC_13
		NEG	DX
		NEG	AX
		SBB	DX,0
		OR	DI,0CH
LOC_13:
		OR	CX,CX
		JNS	LOC_14
		NEG	CX
		NEG	BX
		SBB	CX,0
		XOR	DI,4
LOC_14:
		MOV	BP,CX
		MOV	CX,20H
		PUSH	DI
		XOR	DI,DI
		XOR	SI,SI
  
LOCLOOP_15:
		SHL	AX,1
		RCL	DX,1
		RCL	SI,1
		RCL	DI,1
		CMP	DI,BP
		JB	LOC_17
		JA	LOC_16
		CMP	SI,BX
		JB	LOC_17
LOC_16:
		SUB	SI,BX
		SBB	DI,BP
		INC	AX
LOC_17:
		LOOP	LOCLOOP_15
  
		POP	BX
		TEST	BX,2
		JZ	LOC_18
		MOV	AX,SI
		MOV	DX,DI
		SHR	BX,1
LOC_18:
		TEST	BX,4
		JZ	LOC_19
		NEG	DX
		NEG	AX
		SBB	DX,0
LOC_19:
		POP	DI
		POP	SI
		POP	BP
		RETF	8
LOC_20:
		DIV	BX
		TEST	DI,2
		JZ	LOC_21
		XCHG	AX,DX
LOC_21:
		XOR	DX,DX
		JMP	SHORT LOC_19		
SUB_14		ENDP
  
  
SEG_A		ENDS
  
  
  
		END	START
