.model small
.stack 256
.data
	rez dw ?
.code

start:
	mov ax,5
	call fact

        mov ah,04ch
	int 21h 

fact PROC
	clc
	pushf
	push dx
	push bp
	mov bp,sp
	cmp ax,1
	je gata_apel
	push ax
	dec ax
	call fact
	jc poz_cf
	mul word ptr [bp-2]
	jnc continue
poz_cf :
	or word ptr [bp+4],1
continue:
	add sp,2
gata_apel:
	pop bp
	pop dx
	popf
	ret
fact endp
end start