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/34827507/

相关文章:

linux - 奇怪的返回值 "134"在 Bash 脚本中调用 Gawk

linux - 使用变量作为命令的输入

linux - Perforce 客户端权限

assembly - asm指令 "ldr"和 "ldr_post"有什么不同?

c - 基于汇编32位(x86)编写C代码

assembly - 关于AT&T语法汇编中的cmp/jg、jle等

c++ - 从动画文件中提取基本信息

linux - 阶乘 assembly x86

c++ - 优化 volatile 堆栈变量的存储/构造是否合法?

汇编学习资源?