莱斯指令目的是什么? [英] Les instruction purpose?

查看:202
本文介绍了莱斯指令目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是目的 LES 汇编指令?

为什么我们需要加载 ES 寄存器?书中给出了下面的例子:

  LES BX,磷;负载峰值到ES:BX
MOV ES:[BX]人;保存好AL

为什么我们需要加载 ES BX 在这种情况下,<? / p>

此外,为什么我们使用 ES:[BX] ?如果 P 指向内存100H,是不是既 ES BX 100H 200H =( BX + ES )?


解决方案

它与一个混乱的架构微处理器太糟糕了,你正在学习汇编。你得到容易混淆的概念,如LES指令。

传统的微处理器的寄存器有大到足以容纳一个完整的内存地址。可以简单地(以索引和通常是那些附近)通过寄存器的存储器位置的地址加载到寄存器,然后访问该位置。

某些机器(特别是这似乎英特尔286是你正在编写的),只有16位寄存器,但可以解决1MB的内存。在这种情况下,寄存器不具有足够的位:需要20位,但该寄存器仅16位

的解决方案是有一个包含丢失的位的第二寄存器中。一个简单的方案将是需要2个寄存器,其中之一具有较低的16位,其中一个具有的高16位,以产生一个32位地址。然后引用两个寄存器指令是有道理的:你既需要得到一个完整的内存地址

Intel选择一个混乱方案:索引寄存器(BX你的情况)含有的低16位,另一个寄存器(​​称为ES)包含16位这是左移4位,并添加到索引寄存器,得到所得的地址。 ES被称为段注册,但这将毫无意义,除非你去阅读关于<一个href=\"http://stackoverflow.com/questions/501208/what-projects-do-you-feel-sorry-for/1183967#1183967\">Multics操作系统大约1968年。

[段和段寄存器确实是全面实施了Multics的方式一个有趣的想法。如果你不知道这是什么,你必须的电脑和/或信息architectues任何的兴趣,找到埃利奥特Organick书了Multics和阅读它从头到尾。你会感到沮丧的是我们在60年代末已经和似乎已经失去了50年的进步。]

剩下的是什么在x86的想法是pretty太大的玩笑,至少它的现代的操作系统使用的方式。你真的不关心;当一些硬件设计人员presents你的机器,你必须忍受它,因为它是。

对于Intel 286,你只需要加载一个段寄存器和索引寄存器来得到一个完整的地址。每台机器insturction必须引用一个索引寄存器和一个段寄存器,以形成一个完整的地址。对于Intel 286,有4个这样的段reigsters:DS,SS,ES和CS。每个指令类型明确指定索引寄存器和隐含选择了4段寄存器之一,除非你提供一个明确的覆盖,上面写着要使用哪一个。 JMP指令使用CS,除非你说,否则。 MOV指令使用DS,除非你说,否则。 PUSH指令使用SS除非你说,否则(一个在这种情况下,你最好不要)。 ES是额外的段;你只能通过显式referncing它的指令(除了块移动[MOVB}指令,它同时使用DS和ES隐含的)使用它。

希望有所帮助。

最佳与一个更现代的微处理器,其中,段寄存器愚蠢不是问题的工作

What is purpose of les instruction in assembly?

Why do we need to load es segment and a register? Book gives following example:

les    bx, p           ; Load p into ES:BX
mov    es:[bx], al     ; Store away AL

Why do we need to load es and bx in this case?

Also why do we use es:[bx]? If p points to 100h in memory, isn't both es and bx 100h = 200h (bx+es)?

解决方案

Its too bad you are learning assembler for a microprocessor with a messy architecture. You get confusing concepts such as the LES instruction.

Conventional microprocessor have registers large enough to contain a full memory address. You can simply load the address of a memory location into a register, and then access that location (and usually those nearby with indexing) via the register.

Some machines (notably the Intel 286 which seems to be what you are programming), had only 16 bit registers but could address 1mB of memory. In this case, a register doesn't have enough bits: you need 20 bits, but the registers are only 16 bits.

The solution is to have a second register that contains the missing bits. A simple scheme would have been to require 2 registers, one of which had the lower 16 bits, one of which had the upper 16 bits, to produce a 32 bit address. Then the instruction that references two registers makes sense: you need both to get a full memory address.

Intel chose a messier scheme: the index register (bx in your case) contains the lower 16 bits, and the other register (called ES) contains 16 bits which are left-shifted 4 bits, and added to the index register, to get the resulting address. ES is called a "segment" register, but this will make no sense unless you go read about the Multics operating system circa 1968.

[Segments and segment registers really are an interesting idea when fully implemented the Multics way. If you don't know what this is, and you have any interest in computer and/or information architectues, find the Elliot Organick book on Multics and read it cover to cover. You will be dismayed at what we had in the late 60s and seem to have lost in 50 years of "progress".]

What's left of the idea in the x86 is pretty much a joke, at least the way it it used in "modern" operating systems. You don't really care; when some hardware designer presents you with a machine, you have to live with it as it is.

For the Intel 286, you simply have to load a segment register and an index register to get a full address. Each machine insturction has to reference one index register and one segment register in order to form a full address. For the Intel 286, there are 4 such segment reigsters: DS, SS, ES, and CS. Each instruction type explicitly designates an index register and implicitly chooses one of the 4 segment registers unless you provide an explicit override that says which one to use. JMP instructions use CS unless you say otherwise. MOV instructions use DS unless you say otherwise. PUSH instructions use SS unless you say otherwise (an in this case you better not). ES is the "extra" segment; you can only use it by explicitly referncing it in the instruction (except the block move [MOVB} instruction, which uses both DS and ES implicitly).

Hope that helps.

Best to work with a more modern microprocessor, where segment register silliness isn't an issue.

这篇关于莱斯指令目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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