Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.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_X86_Printf_System Calls - Fatal编程技术网

Assembly 我的程序正在打印所有的可能性

Assembly 我的程序正在打印所有的可能性,assembly,x86,printf,system-calls,Assembly,X86,Printf,System Calls,我的程序正在打印所有的可能性,它是在汇编中编写的。我正在使用cmp助记符和写系统调用(Linux)。如果我使用printf,一切都正常工作,所以我认为问题在于我的系统调用,而不是跳转 section .data msg1: dw "Y > X",10,0 msg2: dw "X > Y",10,0 msg1_len: equ $-msg1 msg2_len: equ $-msg2 section .text ;extern printf glo

我的程序正在打印所有的可能性,它是在汇编中编写的。我正在使用cmp助记符和写系统调用(Linux)。如果我使用printf,一切都正常工作,所以我认为问题在于我的系统调用,而不是跳转

section .data
    msg1: dw "Y > X",10,0
    msg2: dw "X > Y",10,0
    msg1_len: equ $-msg1
    msg2_len: equ $-msg2


section .text

;extern printf

global main

main:
    mov ebx, 10
    mov ecx, 20
    cmp ebx, ecx
    jc .xGreater
.xGreater:
    mov eax, 4
    mov ebx, 1
    mov ecx, msg1
    mov edx, msg1_len
    int 0x80
    jmp .done
.yGreater:
    mov eax, 4
    mov ebx, 1
    mov ecx, msg2
    mov edx, msg2_len
    int 0x80
    jmp .done
.done:
    mov eax, 1
    mov ebx, 0
    int 0x80

您的
msg1\u len:eq$-msg1
行位于
msg2
之后的错误位置,因此它也包括
msg2
的长度

学习使用调试器


PS:另外,您可能希望消息使用
db
而不是
dw
,并且系统调用不需要终止零。

有一天,人们可能会意识到x86只是一种可以编写汇编代码的体系结构。