0

そのため、非再帰的な階乗手順を記述しようとしていますが、ループ命令を使用しています。そのパラメーターはランタイムスタックを介して渡されます。

また、階乗プロシージャを呼び出すために、メイン PROC で一連の命令が必要です。誰もがこの部分で私を助けたいと思っています, これは私がこれまで持っているものです.

.IF eax == 0 || eax == 1  ;special cases
          mov eax, 1              ;factorial == 1
          jmp L2              ;quit procedure
        .ELSEIF eax > 12      ;n is too large
          mov edx, OFFSET msgError
          call Crlf
          call WriteString
          jmp L2              ;quit procedure
        .ENDIF

        mov ecx, eax              ;ecx = counter

            L1:
        dec ecx                   ;ecx = n - 1
        mul ecx                   ;eax = n * (n - 1)

        cmp ecx, 1            ;is counter > 1?
        ja L1                     ;true? then continue

        L2:
        ret

    nonRecurFact ENDP
4

1 に答える 1