NASM Linux Assembly Printing Integers

前端 未结 3 1173
失恋的感觉
失恋的感觉 2021-02-04 18:41

I am trying to print a single digit integer in nasm assembly on linux. What I currently have compiles fine, but nothing is being written to the screen. Can anyone explain to me

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 19:10

    This is adding, not storing:

    add edx, ecx        ; stores ecx in edx
    

    This copies ecx to eax and then overwrites it with 4:

    mov eax, ecx        ; moves ecx to eax for writing
    mov eax, 4          ; sys call for write
    

    EDIT:

    For a 'write' system call:

    eax = 4
    ebx = file descriptor (1 = screen)
    ecx = address of string
    edx = length of string
    

提交回复
热议问题