工作原理printf的内部? [英] how printf works internally.?

查看:192
本文介绍了工作原理printf的内部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
   C / C ++无装配函数的定义

喜再次,
我想知道我是如何工作的printf内部......通过内部是什么意思的底层系统调用/ ISR中等使用的机制......而不是变量参数列表...

hi again, I want to know how printf works internally...by internally I mean what underlying system calls/ISRs etc mechanism is used...and not about the variable argument list...

原因:我使用FASM但很少有控制台I / O,我知道我可以用printf可从C库(我不知道如何,但是这是一个不同点)

Reason:I am using FASM but there is little there for console i/o, I know I can use printf available from the c library(I don't know how but that's a different point)

感谢。

推荐答案

写(2)系统调用设置为文件描述符 STDOUT (其值为1)。

The write(2) system call is used with the file descriptor set to STDOUT (its value is 1).

要调用的组件的系统调用,EAX寄存器具有保持系统调用的ID(我觉得的特定数量的write() 3)和寄存器的其余部分(EBX,ECX ...)必须包含的参数。然后做一个 INT 80H 将从您的流程切换控制处理系统调用内核例程。

To invoke a system call from assembly, the eax register has to hold the id of the system call (I think the particular number of write() is 3) and the rest of the registers (ebx, ecx, ...) have to contain the arguments. Then doing an int 80h will switch the control from your process to the kernel routine that handles system calls.

以上是特定于平台的,但实际上,类似Unix的所有操作系统这样的。

The above is platform-specific, but virtually all Unix-like operating systems work like that.

这篇关于工作原理printf的内部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆