我还需要在汇编语言中更改控制台背景的颜色和文本的颜色

时间:2013-11-15 15:48:15

标签: assembly io console x86 masm

这里的代码是汇编中的Hello World简单程序

.model small
.stack 100h
.data
msg db 0AH,0DH,"Hello World","$"
.code
mov ax,@data
mov ds,ax
mov ah,09h
mov dx,offset msg
int 21h

mov ah,4ch
int 21h

我希望代码也能改变控制台背景和文本颜色的颜色。 我正在使用Dosbox来运行此代码。

1 个答案:

答案 0 :(得分:0)

我只是想通过

来解决它
 mov bl,9; this is for color
 mov cx, 11; this is for number of characters
 int 10h; puts the color behing

刚刚开始 mov dx,offset msg 还要添加

 mov ax,4C00h
    int 21h

工作代码段

.model small
.stack 100h
.data
    msg db "Hello World!","$"
.code

main proc
    mov ax,@data
    mov ds,ax

    mov ah,09h
    mov bl,9; this is for color
    mov cx, 11; this is for number of characters
    int 10h; puts the color behing

    mov dx,offset hello_message
    int 21h

    mov ax,4C00h
    int 21h

main endp
end main