;в data сделай
rect_x2 dw 0
_rect_y2 dw 0
_rect_x1 dw 0
_rect_y1 dw 0
;////////////////////////// draw_rectangle //////////////////////////
; соглашение о вызове
; параметры в стек помещать так: color,x1,y1,x2,y2
draw_rectangle proc
push bp
mov bp,sp
pusha
mov ax,screen_buffer
mov es,ax
mov ax,[bp+4]; color
mov cx,[bp+6]; y2
mov di,[bp+8]; x2
mov bx,[bp+10]; y
mov si,[bp+12]; x
mov _rect_y2,cx
imul di,320
mov _rect_x2,di
mov _rect_y1,bx
mov _rect_x1,si
mov cx,ax
mov di,ax
mov dx,ax
;ax,cx,dx,di - color
imul si,320
; it is possible to add unrolling
draw_line_seg:
mov word ptr es:[si+bx+0],ax
inc bx
cmp bx,_rect_y2
jb draw_line_seg
add si,320
mov bx,_rect_y1
cmp si,_rect_x2
jb draw_line_seg
popa
pop bp
ret 10
draw_rectangle endp