有什么汇编语言无法做到的,只有机器语言可以做到吗? [英] Is there anything that assembly language can't do but only machine language can?

查看:127
本文介绍了有什么汇编语言无法做到的,只有机器语言可以做到吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我将学习一些基本的汇编语言,我已经搜索了wiki,而我意识到的是,汇编语言只是机器语言的文本版本",以便于人类阅读?因此,这意味着任何机器语言可以完成的汇编语言也可以完成,对吗?或者它在汇编语言中存在一些局限性,就像高级编程语言和汇编语言之间的鸿沟一样(有些事情在高级语言中我们做得不好,所以我们不得不使用汇编语言),所以在某些情况下我们别无选择,只能机器语言?

Recently I'm going to learn some basic assembly language, I have searched wiki and what I realize is that assembly language is just a "text version" of machine language in order to let human read? So it means that anything machine language can do assembly language can also finish, right? Or it exists some limitation in assembly language just like a gap between high level programming language and assembly language(Something we can't do well in high level language so we have to use assembly), so is there some situation we have no choice but machine language?

另一个问题是我发现一种比机器语言低的语言是微码"?有人知道机器码和微码之间的关系吗?

Another question is that I found a language lower than machine language is "microcode"? Do anyone know the relationship between machine code and microcode?

推荐答案

这取决于您如何定义汇编代码与机器代码之间的区别:

It depends on how you define the difference between assembly and machine code:

如果您将由汇编程序翻译的任何源"代码称为汇编程序代码",则明确的答案是使用的所有汇编程序的99%:否"

If you call any "source" code which is translated by an assembler "assembler code" the clear answer is for 99% of all assemblers used: "No"

您可以使用诸如.bytedb之类的指令将所需的任何机器代码指令添加到汇编器源代码中,或者您的汇编器以如下方式命名该指令:

You can add any machine code instruction you like to your assembler source code using instructions like .byte or db or however your assembler names that instruction like this:

move X,Y
.byte 1
.byte 2
.byte 3
add Y,X

如果您说:以数字形式输入的任何指令(使用.byte指令)都不是汇编程序,则答案是:通常是":

If you say: Any instruction entered as number (using the .byte instruction) is NOT assembler the answer is: "Often yes":

例如在8088上,有一些指令可以用多种方式表示:例如jmpmov ax, value. (对于像MIPS这样的许多RISC CPU来说,情况更糟……)

On the 8088 for example there are some instructions which can be represented in multiple ways: jmp or mov ax, value for example. (For many RISC CPUs like MIPS this is even worse...)

如果您在汇编器中键入此类指令,则汇编器可以自由决定如何翻译该指令. CPU将以相同的方式执行两个变体,那么汇编程序为什么要给您提供在两个变体之间进行选择的可能性?

If you type such an instruction in an assembler the assembler is free to decide how the instruction will be translated. The CPU will execute both variants the same way so why should the assembler give you the possibility to choose between the two variants?

但是,其他要求可能会迫使您显式使用以下两种变体之一:似乎有些DOS模拟器要求某种文件格式的第一条指令是jmp指令的3字节变体.

However other requirements may force you explicitly to use one of the two variants: There seem to be DOS emulators which require the first instruction of a certain file format to be the 3-byte variant of a jmp instruction.

如果您只编写以下汇编代码:

If you simply write the following assembler code:

    jmp _start
_start:
    ...

如果汇编器使用指令jmp _start的3字节或2字节变体,则无法控制.我想大多数汇编程序都会使用2字节的变体.

You have no control if the assembler uses the 3-byte or the 2-byte variant of the instruction jmp _start. I guess most assemblers will use the 2-byte variant.

如果它使用2字节变体,则这样的DOS模拟器将无法读取该文件!

If it uses the 2-byte variant such a DOS emulator will not be able to read that file!

这篇关于有什么汇编语言无法做到的,只有机器语言可以做到吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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