簡體   English   中英

如何在 intel 8086 模擬器中為代碼段保留字節

[英]How can you reserve bytes for code segment in intel 8086 emulator

我想知道是否有任何方法可以為代碼段(特別是 256)保留更多字節,因為我需要所有段至少有 256 個字節長。 我嘗試了適用於所有其他細分市場的resb ,但這似乎不起作用。

通常,您只需在代碼段中編寫指令,最多為 65536 字節。

滿足代碼段中至少 256 個字節的要求:

; 2 instructions, for a total of 5 bytes
; padded with an extra 251 bytes
    mov  ax, 4C00h   ; DOS.Terminate
    int  21h
    db   251 dup (0)

但是如果你想在代碼段中存儲數據(未初始化的或初始化的),你可以。

一些例子:

; Filling a buffer in the code segment
; Use the CS: segment override prefix

    mov  al, 0
    mov  bx, OFFSET Buffer
  Next:
    mov  [cs:bx], al
    inc  bx
    inc  al
    jnz  Next

; Displaying a text from the code segment
; Setting DS equal to CS

    push cs          ; Pointer needs to be in DS:DX
    pop  ds
    mov  dx, OFFSET Message
    mov  ah, 09h     ; DOS.PrintString
    int  21h

    mov  ax, 4C00h   ; DOS.Terminate
    int  21h

Buffer  db 256 dup (0)
Message db 'Hello from the code segment', 10, 13, '$'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM