Hi, I am trying to convert the following into 8086 assembly.
int fact(n) /* ANSI C version: */
int n; /* int fact(int n) */
if (n == 1)
return n * fact(n-1);
printf("input a number 1-9 : ");
printf("factorial %d = %d\n",i,fact(i));
I have already done the parts that read a number from the keyboard and the result, so please ignore those parts of the code that concern these operations.
I have spend a lot of time, but I cannot implement recursion in the above code.
can you please help me. thanx in advance
below is the code i've done, but it doesnt give me results
.MODEL TINY ; Data and code fit in one 64K segment
.STACK ; allocate a stack
.CODE ; start of code segment
result equ [bp+6]
param equ [bp+4]
fact: push bp
base: mov dx,1
end: pop cx
l0: mov ax,4c00h
int 21h ; return control to DOS with errorlevel 0
n db ? ; uninitialised short n
k db ?
times dw 4
prompt db 'type a number from 1 to 9: $'