程序集不打印空行

assembly doesn't print empty line

我刚开始学习 x86 汇编,我尝试编写一个简单的程序,将所有 ascii 字符和换行符打印到标准输出。 它按预期打印除换行符之外的所有内容,我不明白为什么。 我在 64 位 ubuntu 操作系统上用 nasm 编译了它。 这是代码:

section .data
curr db ' '

section .text

global _start

_start:

    next:

        ;print current character
        mov eax,4
        mov ebx,1
        mov ecx,curr
        mov edx,1
        int 0x80

        ;check condition and increment curr
        inc byte [curr]
        cmp byte [curr],126
        jle next

    ;new line and exit <--- doesn't work ???
    mov eax,4
    mov ebx,1
    mov ecx,10
    mov edx,1
    int 0x80

    mov eax,1
    mov ebx,1
    int 0x80

问题是在那个系统调用中,ECX是一个指针,而不是你要打印的字符。也许像这样修改它?

 MOV byte [curr], 10
 MOV ECX, curr
 MOV EAX, 4
 MOV EDX, 1
 INT 0x80