简体   繁体   English

nasm中的系统调用不起作用

[英]System call in nasm not working

I try write follow code, use int 0x80 to print number 5 but it don't print anything. 我尝试编写跟随代码,使用int 0x80打印数字5,但不打印任何内容。

segment .bss
        num1 resb 1

section .text
        global _start
_start:
        mov dword [num1],5
        add [num1],byte '0'
        mov ecx, dword [num1]
        mov eax, 4
        mov ebx, 1
        mov edx, 1
        int 0x80

        mov eax, 1
        int 0x80

System call 4 expects ecx to contain a pointer to a NUL-terminated string. 系统调用4期望ecx包含一个指向NUL终止的字符串的指针。

So instead of mov ecx, dword [num1] you should use mov ecx, num1 . 因此mov ecx, dword [num1]您应该使用mov ecx, num1代替mov ecx, dword [num1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM