38 lines
473 B
NASM
38 lines
473 B
NASM
|
|
BITS 32
|
|
|
|
GLOBAL divover
|
|
|
|
SECTION .text
|
|
|
|
mem dd 01h
|
|
|
|
divover:
|
|
|
|
mov eax, [esp+4]
|
|
mov ecx, [esp+8]
|
|
|
|
mov ebx, mem
|
|
mov [ebx], ecx
|
|
|
|
div ebx
|
|
ret
|
|
|
|
; mov eax, [esp+4] ; n в eax
|
|
; cmp eax, 1
|
|
; je ret1 ; 1 ! = 1
|
|
;
|
|
; push ecx ; save used ecx
|
|
;
|
|
; dec eax ; eax = n-1
|
|
; push eax
|
|
; call fact ; в eax (n-1)!
|
|
; pop ecx ; ecx = n
|
|
; inc ecx
|
|
; mul ecx ; eax *= ecx
|
|
;
|
|
; pop ecx ; restore used ecx
|
|
;
|
|
;ret1:
|
|
; ret
|