Is there anything that assembly language can't do but only machine language can?

ε祈祈猫儿з 提交于 2020-05-28 04:41:27

问题


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?


回答1:


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

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"

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

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

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...)

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?

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:
    ...

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.

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



来源:https://stackoverflow.com/questions/46755351/is-there-anything-that-assembly-language-cant-do-but-only-machine-language-can

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!