如何用 int10h 打印矩阵?

How to print matrix with int10h?

正如我的问题所说,我需要用 int10h 打印一个矩阵,但不仅如此,这个矩阵由 0 和 1 组成,其中 0 代表蓝色,1 代表红色。所以我的问题是如何打印这个矩阵以及如何在打印时将蓝色和红色设为红色?我正在使用 TASM,可以使用 16 位或 32 位寄存器。 这是一个例子:

oneMatrix db 00000000000
             00000110000
             00011110000
             00000110000
             00000110000
             00000110000
             00011111100
             00000000000

所以你可以在那里看到,1 形成了一个的形状。如何使用 int 10h 打印它,其中 0 是蓝色,1 是红色?

使用BIOS.WriteCharacterAndAttribute函数09h。根据手头的字符(从矩阵读取)在 BL 中放置蓝色或红色前景色。

    mov si, offset oneMatrix
    mov cx, 1    ; ReplicationCount
    mov bh, 0    ; DisplayPage
More:

    ... position the cursor where next character has to go

    lodsb
    mov bl, 01h  ; BlueOnBlack
    cmp al '0'
    je  Go
    mov bl, 04h  ; RedOnBlack
Go:
    mov ah, 09h  ; BIOS.WriteCharacterWithAttribute
    int 10h

    ... iterate as needed

看看this recent answer。有一些相似之处...


如果您需要输出以在图形屏幕上创建字形,那么下一个代码将有所帮助:

    mov  si, offset oneMatrix
    mov  bh, 0      ; DisplayPage

    mov  bp, 8      ; Height
    mov  dx, ...    ; UpperleftY
OuterLoop:

    mov  di, 11     ; Width
    mov  cx, ...    ; UpperleftX
InnerLoop:
    lodsb
    cmp al '0'
    mov al, 1      ; Blue
    je  Go
    mov al, 4      ; Red
Go:
    mov ah, 0Ch    ; BIOS.WritePixel
    int 10h
    inc cx         ; Next X
    dec di
    jnz InnerLoop

    inc dx         ; Next Y
    dec bp
    jnz OuterLoop