Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.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
Linux NASM中要打印10次的X86汇编程序未能终止_Linux_Assembly_X86_Nasm - Fatal编程技术网

Linux NASM中要打印10次的X86汇编程序未能终止

Linux NASM中要打印10次的X86汇编程序未能终止,linux,assembly,x86,nasm,Linux,Assembly,X86,Nasm,嗨,我写这个汇编代码是为了打印字符串hai 10次,方法是用10初始化寄存器cl,用dec递减,并在使用JNE指令时检查它是否过零。但是我发现循环没有终止。为什么这里cl没有变为零,为什么循环没有终止? 代码如下 segment .text global _start _start : mov cl,0xa ;counter set to 10 L1: ;printing message mov eax,4 mov ebx,1 mov ecx,msg mov edx,len int 80h

嗨,我写这个汇编代码是为了打印字符串hai 10次,方法是用10初始化寄存器cl,用dec递减,并在使用JNE指令时检查它是否过零。但是我发现循环没有终止。为什么这里cl没有变为零,为什么循环没有终止? 代码如下

segment .text
global _start
_start :
mov cl,0xa   ;counter set to 10
L1:
;printing message
mov eax,4
mov ebx,1
mov ecx,msg
mov edx,len
int 80h
dec cl ;decrimenting the counter
cmp cl,0x0 ;compare if counter reach zero
jne L1 ;if counter not reached zero rotate in loop
mov eax,1
mov ebx,0
int 80h
section .data
msg db "hai",0xa
len equ $- msg

cl是ECX的低位字节,在循环中设置。当您的代码未按预期运行时,请使用调试器。如果您不清楚@PeterCordes编写的内容,则当您将
msg
的位置移动到
ecx
时,您将覆盖循环计数器。感谢您的回复。