如何汇编语言工作? [英] How do assembly languages work?

查看:149
本文介绍了如何汇编语言工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇汇编语言work-我仍然一般,因为我不仅是英特尔x86汇编说话(虽然它是唯一一个我远程熟悉的)如何。要有点更清晰...

I'm very curious how assembly languages work- I remain general because I'm not talking only about intel x86 assembly (although it's the only one I'm remotely familiar with). To be a bit more clear...

mov %eax,%ebx

如何在电脑知道什么样的MOV指令呢?它如何知道EAX和EBX是寄存器?人们是否写汇编语言语法?他们怎么写?我想没有什么是从编写替代的东西,如或<$ c中的 MOV 指令汇编语言阻止某人$ C>马等等,(显然这不是语义在所有)

How does the computer know what an instruction like "mov" does? How does it know that eax and ebx are registers? Do people write grammars for assembly languages? How do they write this? I imagine nothing is stopping someone from writing an assembly language that substitutes the mov instruction with something like dog or horse etc., (obviously this isn't semantic at all)

很抱歉,如果这是不是太清楚,但它的东西,我觉得有点puzzling-我知道这不可能是魔法,但我看不出它是如何工作。我抬头一看维基百科上的一些东西,但都似乎说的是它翻译下来到机器code,那么,我要问的是,翻译是如何发生的,我想。

Sorry if this isn't too clear, but it's something I find a bit puzzling- I know it can't be magic, but I can't see how it works. I've looked up some stuff on wikipedia, but all it seems to say is it translates it down to machine code, well, what I'm asking is how that translation occurs I suppose.

思考?

编辑:我知道这东西是在参考手册和事物的定义,我想我想知道的是你如何告诉你的处理器好吧,当你看到 MOV 你会做到这一点。我也知道,它可能是一个逻辑吨的序列gates..but必须有某种方式来识别的处理器是 MOV 是指符号使用这些逻辑门

I realize that this stuff is defined in reference manuals and things, I guess what I wish to know is how you tell your processor "Okay, when you see mov you're gonna do this". I also know that it's a sequence of probably a ton of logic gates..but there has to be some way for the processor to recognize is that mov is the symbol that means "use these logic gates"

推荐答案

你所看到的有记忆法,这很容易让一个程序员写组件中,但不是在助记符形式的可执行文件。
当您通过汇编程序通过这些汇编指令,它们被翻译成机器code,他们重新present,这是CPU和它的各种协处理器间preT和执行(其一般取成小单位由CPU,称为微操作)。

What you see there are mnemonics, which make it easy for a programmer to write assembly, it is however not executable in mnemonic form. when you pass these assembly instructions through an assembler, they are translated into machine code they represent, which is what the CPU and its various co-processors interpret and execute (its generally taken down into smaller units by the CPU, called micro-ops).

你的好奇,它究竟怎样了,还有那是一个漫长的过程,但拥有所有该信息。

if your curious as to how exactly it does that, well thats a long process, but this has all that information.

所有的语义等都是由汇编程序,这将检查有效性和完整性尽可能处理(仍然可以组装但无效code!)。这基本上使装配一个低层次的语言,即使它有一个1对1相关的输出机器code(当使用基于宏汇编,但宏的还是扩大到1:1除外)。

All the semantics etc are handled by the assembler, which checks for validity and integrity where possible (one can still assemble invalid code however!). this basically makes assembly a low-level language, even though it has a 1 to 1 correlation to the outputted machine code (except when using macro based assemblers, but then the macro's still expand to 1 to 1).

这篇关于如何汇编语言工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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