Assembly 为什么这个循环的结果是20而不是120?

Assembly 为什么这个循环的结果是20而不是120?,assembly,x86-16,machine-language,Assembly,X86 16,Machine Language,为什么这个循环的结果是20而不是120 ORG 100H facto dw ? START: MOV CX, 5 MOV AX, 5 DEC CX repeat : MUL CX MOV facto , AX LOOP repeat ENDS END START : 尽管使用了一些不需要的命令,但代码运行良好。 下面是在FASM中进行测试的完整代码。您将看到,我将mov-cx、5和dec-cx组合到mov-cx、4中,并

为什么这个循环的结果是20而不是120

ORG 100H 
  facto dw ? 
START: 
   MOV CX, 5 
   MOV AX, 5
   DEC CX  
   repeat : 
     MUL CX 
     MOV facto , AX 
   LOOP repeat 
ENDS
END START :

尽管使用了一些不需要的命令,但代码运行良好。 下面是在FASM中进行测试的完整代码。您将看到,我将mov-cx、5和dec-cx组合到mov-cx、4中,并将分配从ax移动到事实上,以避免不必要的代码执行

format PE console
entry main
include '%INCLUDE%/win32a.inc'

section '.data' data readable writeable
facto dd 0

section '.text' code readable executable

main:
    mov ecx, 4
    mov eax, 5
L0:
    mul ecx
loop L0
    mov [facto], eax
    invoke  ExitProcess,    eax

section '.idata' data import readable
library kernel32,'kernel32.dll'

import kernel32,\
ExitProcess,'ExitProcess'

对我有效,循环结束时AX=120=0x78。(我在Linux静态可执行文件中使用NASM进行了测试,并使用GDB进行了单步测试)。不是。