So I'm trying to write factual process, uses loop instruction, that parameter passed through runtime stack is done.
To apply the factorial process I also need a sequence of instructions in the main process. Anyone wants to help me with this part, what is it to me so far?
. Eax == 0 || Ex == 1; In special cases MaxEx, 1; Factorial == 1 JMP L2; Quit process .ELSEIF eax & gt; 12; N Huge MOV edx, OFFSET msg record call CRLF call write string JMP L2; Leave the process. ENDIF mov ecx, eax; Ecx = counter L1: dec ecx; Ecx = n - 1 mul ecx; Eax = n * (n - 1) cfcx, 1; Counter & gt; 1? GA L1, is that true? Then continue L2: Rate NonRicFact ENDP I made a non-recursive factorial process which is LOOP Uses Instructions The parameter is sent through the stack, but you can remove the stack and use the global variable my_factor. This short program runs in EMU 8086:
.stack 100h.data my_factor dw5 Cod; Initial Data Segment Mov AX, @ data mov DS, ax push my_factor call non_recursive_factorial; Finish Mov ax, 4c00h int 21h proc non_recursive_factorial pop axis; Address the Retriever to call. Pop my_factor; Reactive parameter push ax; Go back to call back. Mov ax, my_factor mov cx, my_factor dec cx while: mul cx; Ax * cx = dx: axis while retp
at the end of the process, the result is in AX. Then you can display it or something else.
No comments:
Post a Comment