“int”和“int”之间的区别
操作系统如何知道区分
int x = 0; //variable
和
int 0x80; //interrupt, call system_call()
how does OS know to differentiate between
int x = 0; //variable
and
int 0x80; //interrupt, call system_call()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
巧合的是,“integer”的前 3 个字母与“interrupt”的前 3 个字母相同。两种不同的语言使用了这三个字母,它们的含义不同。
同样,“chat”在法语和英语中都是一个词,但在法语中它的意思是“猫”,而在英语中它的意思是“谈话”。
By co-incidence, the first 3 letters of 'integer' are the same as the first 3 letters of 'interrupt'. Two different languages have used these 3 letters, and they mean different things.
Similarly, 'chat' is a word in both French and English, but in French it means 'cat' and in English it means 'talk'.
int x = 0;
是 C 代码。int 0x80;
是汇编代码。此外,操作系统根本不知道这一点,因为编译器/汇编器将其转换为机器代码......
int x = 0;
is C code.int 0x80;
is assembly code.Moreover, the OS don't know about that at all, since the compiler / assembler converts it to machine code...
一个看起来像 C,另一个看起来像汇编程序。
如果生成 int x = 0; 的汇编程序使用编译器中的 -S 开关
您会看到代码实际上有多么不同。
One looks like C the other looks like assembler.
If you generate the assembler for int x = 0; with the -S switch in your compiler
you would see how different the code actually is.
因为它们是两种不同的编程语言。
第一个是C语言中的变量声明和定义,第二个是Linux x86中用于调用系统调用的汇编指令。
它们很可能由两个不同的编译器解释,或者如果它们位于同一文件中,则第二条指令位于汇编代码块中,编译器知道必须以不同方式对待。
Because they are two different programming languages.
The first is a variable declaration and definition in C, the second is the assembly instruction for calling system calls in Linux x86.
They are likely to be interpreted by two different compilers, or if they are in the same file the second instruction is in a block of assembly code, that the compiler knows that must be treated differently.