写入地址而不使用段寄存器

Jac*_*ack 2 x86 assembly real-mode nasm x86-16

我知道这段代码实际上会将数据写入ds:[100h]

mov [100h], ax
Run Code Online (Sandbox Code Playgroud)

但是,如何在100H不使用段基的任何段寄存器的情况下直接写入线性地址?

fuz*_*fuz 5

没有办法绕过段寄存器; 每个内存访问都与某个段寄存器相关.如果要写入绝对地址,首先加载具有适当段的段寄存器:

        xor cx, cx
        mov es, cx        ; es = 0000
        mov [es:100h], ax ; [0000:0100] = ax
Run Code Online (Sandbox Code Playgroud)

要在8086或80286系统上加载大于16位的线性地址,请尝试以下操作:

addr    dd 0x12345        ; the address we want to load from
        ...
        mov bl, [addr]    ; load low part
        xor bh,bh
        mov cx, [addr+1]  ; load high part
        shl cx, 4         ; adjust high part for segment selector
        mov es, cx        ; load segment register
        mov [es:bx], ax   ; store ax
Run Code Online (Sandbox Code Playgroud)