.286
.model small
.code       
org 100h
start:
		mov ax, 13h
		int 10h
		mov ax, 0a000h
		mov es, ax

		push 1
		push 1
		push 20
		push 20
		call Line

		push 20
		push 20
		push 30
		push 70
		call Line

		push 30
		push 70
		push 1
		push 1
		call Line

		mov ah, 08h
		int 21h

		mov ax, 3
		int 10h
		int 20h
;------------------------------
Line 		proc 	near
	push bp
	mov  bp,sp
LY2 EQU		word ptr [bp+4]
LX2 EQU		word ptr [bp+6]
LY1 EQU		word ptr [bp+8]
LX1 EQU		word ptr [bp+10]
	pusha
		mov ifY, 0
		mov cur, 0

		mov ax, LX2
		sub ax, LX1
		jg LLX
		neg ax
		mov si, LX2
	    mov mybeg, si
		jmp TOY
LLX:
		mov si, LX1
	    mov mybeg, si
TOY:	mov bx, LY2
		sub bx, LY1
		jg LLY
		neg bx
	    mov otbeg, si
		jmp TOW
LLY:
		mov si, LY1
	    mov otbeg, si
TOW:	cmp bx, ax
		jl	MYX
		mov cx, mybeg
		mov si, otbeg
		mov mybeg, si
		mov otbeg, cx
		mov ifY, 1
		push ax
		mov ax, bx
		pop bx
MYX:	mov gend, ax
		mov ots,  bx
mainloop:
		mov ax, ots
		mov bx, cur
		mul bx
		mov bx, gend
		div bx
		mov dx, ax
		add dx, otbeg
		cmp ifY, 0
		jz  defs
		mov ax, mybeg
		add ax, cur
        mov cx, ax
        shl ax, 6
        shl cx, 8
        add ax, cx
        add ax, dx
        mov si, ax
        mov ax, COL
        mov byte ptr es:[si], al
        jmp GGG
defs:
		mov cx, dx
        shl dx, 6
        shl cx, 8
        add dx, cx
        add dx, mybeg
        add dx, cur
        mov si, dx
        mov ax, COL
        mov byte ptr es:[si], al
GGG:
		inc cur
		mov ax, cur
		cmp ax, gend
		jle mainloop
	popa
	pop bp
	ret 8
ifY		db 0
mybeg	dw ?
otbeg	dw ?
cur		dw 0
gend	dw ?
ots		dw ?
endp
COL	dw 4
end start