asm change cmd background color

微笑、不失礼 提交于 2019-12-02 10:20:23

问题


I wrote the part that changes the text color, but I can't find a way to change the background color, this code is for tasm assembly:

model small
stack 256
.data
ent db 0ah,0dh,'$'
array  db 2,4,5,6
       db 7,8,9,5
       db 1,2,3,4
       db 5,6,7,8
temp dw 0
.code
main :
    mov  ax,@data
    mov  ds,ax

    mov ah, 06h
    mov al, 0
    mov cx, 0
    mov dh, 79
    mov dl, 79
    mov bh, 4h

    int 10h

This is a my code but it doesn't work:

  mov ah, 0bh
    mov bh, 01h
    mov bl, 2h

    int 10h

    mov ah, 02h
    mov dl, 34h

    int 21h


 mov ax,4c00h ; exit from program
 int 21h

end main

回答1:


In BIOS function 6, BH contains an 8-bit color. Its lower 4 bits specify the foreground color while the upper 4 bits specify the background color. Try, for example, mov bh, 14h instead of mov bh, 4h. It should start writing red on blue instead of red on black.



来源:https://stackoverflow.com/questions/8553330/asm-change-cmd-background-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!