为什么Windows,Linux等汇编语言之间存在差异? [英] Why There is a difference between assembly languages like Windows, Linux?

查看:113
本文介绍了为什么Windows,Linux等汇编语言之间存在差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对所有这些低级的东西,汇编语言还是比较陌生的,并且想了解更多详细信息.为什么Linux和Windows汇编语言之间存在差异?

I am relatively new to all this low level stuff,assembly language.. and want to learn more detail. Why there is a difference between Linux, Windows Assembly languages?

据我了解,当我编译C代码时,操作系统并不能真正产生纯机器代码或汇编代码,它会产生与OS相关的二进制代码.但是为什么?

As I understand when I compile a C code Operating system does not really produce pure machine or assembly code, it produces OS dependent binary code.But why ?

例如,当我使用x86系统时,CPU只能理解x86 ASM吗?那么为什么我们不编写纯x86汇编代码,以及为什么基于操作系统存在不同的汇编版本呢?如果我们要编写纯ASM或OS生成纯ASM,那么在操作系统之间是否不会存在二进制兼容性问题?

For example when I use a x86 system, CPU only understands x86 ASM am I right?.So Why we dont write pure x86 assembly code and why there are different assembly variations based on Operating system? If we would write pure ASM or OS produce pure ASM there wouldn't be binary compatilibty issues between Operating systems or Not ?

我真的很想知道背后的所有原因.任何详细的答案,文章,书都很棒.谢谢.

I am really wondering all reasons behind them. Any detailed answer, article, book would be great. Thanks.

推荐答案

没有区别.如果处理器相同,则汇编代码相同. Windows上编译的x86代码与Linux上的x86代码二进制兼容.编译器不会产生与操作系统相关的二进制代码,但可以将代码打包为其他格式(例如PE与ELF).

There is no difference. The assembly code is the same if the processor is the same. x86 code compiled on Windows is binary compatible with x86 code on Linux. The compiler does not produce OS-dependent binary code, but it may package the code in a different format (e.g. PE vs. ELF).

区别在于所使用的库.为了使用OS东西(例如I/O),您必须链接到操作系统的库.毫不奇怪,Windows系统库在Linux机器上不可用(除非您当然有Wine),反之亦然.

The difference is in which libraries are used. In order to use OS stuff (I/O for example) you must link against the operating system's libraries. Unsurprisingly, Windows system libraries are not available on a Linux machine (unless you have Wine of course) and vice-versa.

这篇关于为什么Windows,Linux等汇编语言之间存在差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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