QChí Nguyễn
QChí Nguyễn

Reputation: 307

System call in nasm not working

I try write follow code, use int 0x80 to print number 5 but it don't print anything.

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

Upvotes: 1

Views: 143

Answers (1)

Michael
Michael

Reputation: 58497

System call 4 expects ecx to contain a pointer to a NUL-terminated string.

So instead of mov ecx, dword [num1] you should use mov ecx, num1.

Upvotes: 2

Related Questions