質問

私はそれをビデオバッファーに移動することにより、白い背景に青の文字「D」を書き込もうとしています。このコードの何が問題になっていますか?

INCLUDE Irvine16.inc

.code
main PROC

mov ax,@data
mov ds,ax

mov si, 0b800h
mov word ptr [si], 44h
mov word ptr [si+2] 0701h

mov ah, 08h
int 21h

exit

main ENDP

上記の変更を加えました。今では組み立てられていますが、何も表示されません。

役に立ちましたか?

解決

サンプルの例:

name "hello-world"
org 100h

; set video mode     
mov ax, 3     ; text mode 80x25, 16 colors, 8 pages (ah=0, al=3) 
int 10h       ; do it! 

; cancel blinking and enable all 16 colors: 
mov ax, 1003h
mov bx, 0
int 10h


; set segment register: 
mov     ax, 0b800h
mov     ds, ax

; print "hello world" 
; first byte is ascii code, second byte is color code. 

mov [02h], 'h'

mov [04h], 'e'

mov [06h], 'l'

mov [08h], 'l'

mov [0ah], 'o'

mov [0ch], ','

mov [0eh], 'w'

mov [10h], 'o'

mov [12h], 'r'

mov [14h], 'l'

mov [16h], 'd'

mov [18h], '!'




; color all characters: 
mov cx, 12  ; number of characters. 
mov di, 03h ; start from byte after 'h' 

c:  mov [di], 11101100b   ; light red(1100) on yellow(1110) 
    add di, 2 ; skip over next ascii code in vga memory. 
    loop c

; wait for any key press: 
mov ah, 0
int 16h

ret

このサンプルがあなたを助けることを願っています

他のヒント

1)0B800Hはです セグメント ビデオバッファーのアドレス。 mov word ptr [si], 44h アドレスだけです オフセット (こちら:0b800h)のセグメントアドレスの DS - と DSビデオバッファーを指していません。ビデオセグメントをロードすることをお勧めします ES セグメントオーバーライドを使用するには(ES:).

2)文字と色の形で単語。ビデオバッファーには、最初に文字が登場し、次に色が登場します。背景と前景の色はそれぞれニブル(4ビット)を使用します。 「リトルエンディアンネス」(Google for it)のために、単語には形式の色/文字が必要です。

これはIrvine16互換性のある例です。

INCLUDE Irvine16.inc
INCLUDELIB Irvine16.lib

.CODE
main PROC
;   mov ax,@data                ; No .DATA in this example
;   mov ds,ax

    mov si, 0b800h              ; Initialize ES with video buffer
    mov es, si

    xor si, si                  ; Position 0 is top left
    mov word ptr es:[si], 7144h ; White background ('7'), blue foreground (1), letter 'D' (44)

    mov ah, 08h                 ; Wait for key - http://www.ctyme.com/intr/rb-2561.htm
    int 21h

    exit                        ; Irvine16: end of program
main ENDP

END main

ここでリスト15をご覧ください。

http://stuff.pypt.lt/ggt80x86a/asm8.htm

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top