谁将高级语言转换为汇编语言 [英] Who converts High Level Language to Assembly language

查看:490
本文介绍了谁将高级语言转换为汇编语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过计算机指令/程序的基本功能,我了解到我们使用高级语言编写源代码.编译器将其转换为低级语言(机器代码/目标代码).我还了解到,汇编程序将汇编语言转换为机器代码/目标代码.
然后我有以下疑问:

  1. 如果编译器直接将高级转换为低级,则会从此处生成此汇编语言.

  2. 如果转换过程必须使用汇编语言,即

高级语言====>汇编语言====>目标代码/机器代码,
然后谁将这种高级语言转换为汇编语言,它的用途是什么?

解决方案

这是一个非常笼统的问题(老实说,这也很难理解).

用于高级语言的编译器可以将高级代码转换为汇编器,而辅助实用程序可以将汇编器转换为您所谓的机器代码.编译器也可以直接生成机器代码.这两个选项均有效,由编译器的设计者确定哪个最合适.

也就是说,汇编距离成为机器码"仅一步之遥,因此能够读取汇编以确定编译器已完成的工作通常很有用.有时,这将导致洞察力,使人们可以优化高级代码.其他时候,一个1337程序员可能会选择手动编辑该程序集.因此,即使编译器似乎直接生成机器代码,通常也可以代之以汇编代码.

有关更多详细信息,请参见此SO答案./p>

Well Going through basic Functioning of computer's instruction /program, I learnt that We write source code in High Level Language.Compilers convert it into low level language (Machine code/object code). I also learnt that Assembler converts assembly language into machine code/object code.
Then I have got following doubts:

  1. From where this assembly language is generated if compilers directly convert high level to low level.

  2. if the conversion process has to go through assembly language i.e

High Level Language ====> Assembly language ====> object code/machine code,
then who converts this high level language to assembly language and what is the use of it?

解决方案

This is a very general question (and also a bit difficult to understand, to be honest).

A compiler for a high-level language could convert high level code into assembler and a secondary utility could convert assembler into what you call machine code. A compiler could also produce machine code directly. Either option is valid and it is up to the compiler's designers to determine which is most appropriate.

That said, assembly is one step away from being "machine code", so it is often useful to be able to read it to determine what the compiler has done. Sometimes this will lead to insights that allow one to optimize the high level code; other times, a 1337 programmer might opt to edit the assembly by hand. For this reason, even if a compiler appears to produce machine code directly, it is often the case that it can produce assembly code instead.

See this SO answer for further details.

这篇关于谁将高级语言转换为汇编语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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