开发者

writing to a file in nasm using system calls

开发者 https://www.devze.com 2023-01-31 21:53 出处:网络
As part of an assignment, I\'m supposed to write to a file using system calls. Everything works fine except when I try to open the file in gedit (Linux). It says it can\'t identify the character encod

As part of an assignment, I'm supposed to write to a file using system calls. Everything works fine except when I try to open the file in gedit (Linux). It says it can't identify the character encoding. Notepad (on Windows) opens the file just fine.

Why doesn't this work on Linux ?

Here's the code:

    section .text

    global _start

        _start:
                    mov EAX, 8
                    mov EBX, filename
                    mov ECX, 0700
                    int 0x80
       开发者_运维百科             mov EBX, EAX
                    mov EAX, 4
                    mov ECX, text
                    mov EDX, textlen
                    int 0x80
                    mov EAX, 6
                    int 0x80
                    mov eax, 1
                    int 0x80
        
    section .data

        filename db "./output.txt", 0
        text db "hello world", 0
        textlen equ $ - text

-- update: adding a linefeed character after the output string fixed it.


change line 3 to this : mov ECX, 0x0700


fixed it, see update in the question.

0

精彩评论

暂无评论...
验证码 换一张
取 消