NASM Linux Assembly Printing Integers

前端 未结 3 1176
失恋的感觉
失恋的感觉 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 18:51

    From man 2 write

    ssize_t write(int fd, const void *buf, size_t count);
    

    In addition to the other errors that have been pointed out, write() takes a pointer to the data and a length, not an actual byte itself in a register as you are trying to provide.

    So you will have to store your data from a register to memory and use that address (or if it's constant as it currently is, don't load the data into a register but load its address instead).

提交回复
热议问题