Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 组件中的循环不';行不通_Assembly - Fatal编程技术网

Assembly 组件中的循环不';行不通

Assembly 组件中的循环不';行不通,assembly,Assembly,我在尝试在asm中创建循环时遇到了一些问题。 所以我用循环创建了另一个代码。 问题是,当我减少或增加ecx时,变量会出错。 如果我使用没有dec的循环指令,它也不会工作。 如何使用ecx循环 代码 ecx值不保证在printf调用中保留。改用下列寄存器之一:ebx,ebp,esi,edi。您也应该通过将choise寄存器推到堆栈上并在之后恢复来保存它们。您是对的,jmp runloop在那里没有任何用处。 section .text global main extern p

我在尝试在asm中创建循环时遇到了一些问题。 所以我用循环创建了另一个代码。 问题是,当我减少或增加
ecx
时,变量会出错。 如果我使用没有dec的循环指令,它也不会工作。 如何使用
ecx
循环

代码


ecx
值不保证在
printf
调用中保留。改用下列寄存器之一:
ebx
ebp
esi
edi
。您也应该通过
将choise寄存器推到堆栈上并在之后恢复来保存它们。

您是对的,
jmp runloop
在那里没有任何用处。
section .text
     global main

     extern printf
section .data
FORMAT: db "L", 10, 0 ; just to print the L 10 times
main:

     mov ecx, 10 ; start the counter in 10
     jmp runloop ; i imagine i dont need it
runloop:
     push FORMAT
     call printf
     add esp, 4
     dec ecx
     cmp ecx, 0
     jne runloop