linux - 如何打印单个 ASCII 字符?

标签 linux assembly x86 nasm

在 DOS 汇编中我们可以这样做:

mov dl, 41h
mov ah, 02h
int 21h

但是 Linux nasm x86 汇编怎么样?

最佳答案

section     .data

msg     db  'H'
len     equ $ - msg


section     .text
global      _start

_start:

mov     edx,len
mov     ecx,msg
mov     ebx,1    ;file descriptor (stdout)
mov     eax,4    ;system call number (sys_write)
int     0x80

mov     eax,1    ;system call number (sys_exit)
int     0x80

写入单个字符可能不会产生所需的输出,因为根据终端设置,它可能会被缓存,因此您可能需要刷新输出,以确保它出现在您写入的任何地方。

这是 linux 32 Bit system calls 的列表.

关于linux - 如何打印单个 ASCII 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20466018/

相关文章:

assembly - 这个只有一个操作数的 x86-64 addq 指令是什么意思? (摘自CSAPP书籍第三版)

linux - 如何检查 bash 中用户输入的值是否存在?

linux - 对不同文件夹中的文件执行 bash 脚本

assembly - 需要帮助来理解这些 ARM 指令

c++ - Java 字节码的即时编译

assembly - 将两个无符号 16 位值相乘,不使用乘法或除法指令 [8086 汇编]

python - 创建使用 Multiprocessing 和 Multiprocessing.Queues 的 linux 守护进程

c++ - fork() 之后如何处理 execvp(...) 错误?

c++ - C++ 中的内联汇编失败?

gcc - 是什么导致 "x.asm:(.text+0xd): undefined reference to ` y'”?