如何打印单个ASCII字符? [英] How to print a single ASCII char?
本文介绍了如何打印单个ASCII字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在DOS组装中,我们可以这样做:
In DOS Assembly we can do this:
mov dl, 41h
mov ah, 02h
int 21h
但是Linux nasm x86 Assembly如何?
But how about Linux nasm x86 Assembly?
推荐答案
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
写入单个字符可能不会产生所需的输出,因为根据终端设置,它可能会被缓存,因此您可能需要刷新输出以确保它出现在您写入的任何位置.
Writing a single character may not produce the desired output, because depending on the terminal settings, it may be cached, so you may need to flush the output, to make sure that it appears wherever you write to.
这是 Linux 32位系统调用.
这篇关于如何打印单个ASCII字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文