2013-11-15 18 views
0

這裏的代碼是的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來運行此代碼。

+0

可能重複:http://stackoverflow.com/questions/8553330/asm-change-cmd-background -color –

+0

相關:http://stackoverflow.com/questions/15462807/printing-a-string-without-os – nrz

回答

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解決,抵消味精 另外補充

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