简体   繁体   English

机器码和汇编语言有什么关系?

[英]What is the relation between machine code and assembly language?

I want to know the relation between machine code and assembly language.我想知道机器码和汇编语言之间的关系。

Are assemblers made together by the architecture manufacturer?汇编器是由架构制造商共同制造的吗?

Otherwise, is it possible for anyone to manufacture assemblers by referring to the architecture manufacturer's set of Instruction?否则,任何人都可以通过参考架构制造商的指令集来制造汇编器吗?

Have a nice day!祝你今天过得愉快!

if you wish to be in the processor business be it a chip or an IP core, you will not get very far without a toolchain.如果您希望从事处理器业务,无论是芯片还是 IP 核,如果没有工具链,您将走不远。 Be it a home grown like the old days (There are still folks that do this) or say gnu or llvm.无论是像过去一样成长的家庭(仍然有人这样做)或说 gnu 或 llvm。

Likewise, you will not get very far without instruction set documentation.同样,如果没有指令集文档,您将无法走多远。 That documentation pretty much always includes a syntax.该文档几乎总是包含语法。 Now that syntax ideally matches the syntax for the assembler tool that the vendor has created or supported.现在,该语法与供应商创建或支持的汇编器工具的语法完美匹配。 But you may see tools evolve without the documentation matching.但是您可能会看到工具在没有文档匹配的情况下发展。 You need some minimal way to describe the instruction set with something human readable.您需要一些最小的方法来用人类可读的东西来描述指令集。 So this has been the norm.所以这已经成为常态。

But having a standard is not the way things happen.但是有一个标准并不是事情发生的方式。 Easy to see with popular platforms, ARM, MIPS x86 (not talking about intel vs at&t), etc.使用流行平台很容易看到,ARM、MIPS x86(不谈论intel vs at&t)等。

The assembler author(s) are perfectly free to do whatever they want, as we have seen.正如我们所见,汇编程序作者可以完全自由地做他们想做的任何事情。

orange pickle,apple[#4]

could be a perfectly valid instruction, all you need is one person to create an assembler with that syntax, and then it exists.可能是一个完全有效的指令,您所需要的只是一个人用该语法创建一个汇编程序,然后它就存在了。

Now how useful and how popular would your assembler be?现在你的汇编器会有多有用和流行吗? Not very.不是特别的。 Overloading of mov in x86 was in desperate need of different mnemonics, but even there you would feel some resistance despite resolving a lot of issues of the original byte ptr type solutions.在 x86 中重载 mov 迫切需要不同的助记符,但即使在那里你也会感到一些阻力,尽管解决了原始字节 ptr 类型解决方案的许多问题。

Basically if the assembler generates usable machine code for the target, it is an assembly language.基本上,如果汇编程序为目标生成可用的机器代码,则它是一种汇编语言。 Also understand that while two tools may support ldr r0,[r1] the mnemonics for the instructions are not the whole assembly language.还要理解,虽然两个工具可能支持 ldr r0,[r1] 指令的助记符不是整个汇编语言。 Most of the time the incompatibilities are beyond the instructions themselves, how do you make a comment, define a label, macro, represent numbers (decimal, hex, etc).大多数情况下,不兼容性超出了指令本身,您如何进行注释、定义标签、宏、表示数字(十进制、十六进制等)。 But we see with the mainstream tools the instructions themselves are incompatible (not talking about intel vs at&t differences).但是我们看到主流工具的指令本身是不兼容的(不是在谈论 intel 与 at&t 的区别)。 So this has already happened, and continues to happen.所以这已经发生了,而且还在继续发生。

Some are made by the vendor they create/own the tool.有些是由他们创建/拥有工具的供应商制造的。 Some are contracted.有些是签约的。 And free tools, GNU, LLVM, for example employees will support that effort directly.而免费工具、GNU、LLVM,例如员工将直接支持这项工作。 And likewise there are tools that have been created that are created by people completely separated from the vendor.同样,有些工具是由与供应商完全分开的人创建的。

Is it possible to create an assembler from the documentation.是否可以从文档中创建汇编程序。 Actually that is rare as I used to and sometimes still do learn an instruction set by writing a disassembler.实际上,这在我以前很少见,有时仍然通过编写反汇编程序来学习指令集。 Some are better than others, usually you need a working tool in order to figure out the gaps in the documentation.有些比其他的要好,通常你需要一个工作工具来找出文档中的差距。 But, yes, if the documents are well written you could certainly create your own assembler, linker, etc.但是,是的,如果文档写得很好,您当然可以创建自己的汇编器、链接器等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM