Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 在8086中将数据从一个存储器位置传输到另一个存储器位置_Assembly_X86 16 - Fatal编程技术网

Assembly 在8086中将数据从一个存储器位置传输到另一个存储器位置

Assembly 在8086中将数据从一个存储器位置传输到另一个存储器位置,assembly,x86-16,Assembly,X86 16,问题是: 编写汇编语言程序,将段7000H中16字节的数据从偏移量0200H移动到0300H 如何编写程序?我是说,我该怎么记地址?我应该考虑偏移地址还是基地址? 如何编写程序 您可以编写一个循环,该循环依次从源地址读取和在目标地址写入 我是说,我该怎么记地址? 我应该考虑偏移地址还是基地址? 要寻址内存,您需要同时使用两个地址组件 将给定的段值放入段寄存器中。DS是更常见的选择: mov ax, 7000h mov ds, ax 将提供的源偏移量放入地址寄存器,如BX、SI或

问题是:

编写汇编语言程序,将段7000H中16字节的数据从偏移量0200H移动到0300H

如何编写程序?我是说,我该怎么记地址?我应该考虑偏移地址还是基地址?

如何编写程序

您可以编写一个循环,该循环依次从源地址读取和在目标地址写入

我是说,我该怎么记地址? 我应该考虑偏移地址还是基地址?

要寻址内存,您需要同时使用两个地址组件

将给定的段值放入段寄存器中。DS是更常见的选择:

mov     ax, 7000h
mov     ds, ax
将提供的源偏移量放入地址寄存器,如BX、SI或DI:

将提供的目标偏移量放入不同的地址寄存器:

mov     di, 0300h
您将请求的字节数放入剩余的一个通用寄存器中,如果我们想使用循环指令,CX是自然的选择,实际上也是唯一的选择:

mov     cx, 16
所有上述选择都会导致以下循环:

Again:
    mov     al, [si]   ;Get 1 byte from the source range
    inc     si         ;Point to the next byte
    mov     [di], al   ;Write 1 byte in the destination range
    inc     di         ;Point to the next byte
    loop    Again      ;Decrement the counter and jump to the label "Again"
                       ; if the counter is not yet exhausted.
这只是您任务的一个解决方案。还有很多。 然而,最短的解决方案使用像MOVS这样的专用指令。在你的课本上查一下,看看开始使用它需要什么。发现快乐


请注意,上述所有代码并不构成一个完整的工作程序。

它们为您提供了段基和偏移量。由此,您可以轻松计算绝对地址。但您甚至不需要它,因为8086使用段偏移量寻址,所以它们提供您需要插入的所有值。这是一个非常简单的练习,如果您了解段寄存器是什么,并且熟悉字符串指令,尤其是MOVSB。
Again:
    mov     al, [si]   ;Get 1 byte from the source range
    inc     si         ;Point to the next byte
    mov     [di], al   ;Write 1 byte in the destination range
    inc     di         ;Point to the next byte
    loop    Again      ;Decrement the counter and jump to the label "Again"
                       ; if the counter is not yet exhausted.