如何用中断打印彩色文本?

时间:2013-12-28 06:30:13

标签: assembly colors x86-16 16-bit

这是我的代码,它以白色打印,这是默认的。我知道如何在没有中断的情况下进行彩色打印,但我不想这样做。我想用中断打印任何其他颜色。我怎么能这样做?任何的想法?提前致谢 我使用emu8086作为汇编程序

data segment
    wellcome db 'Wellcome User !',13, 10 ,'$'
    how    db 'how are you',13,10,'$'
ends

stack segment
    dw  64 dup(0)
ends

code segment 

    start:
        push ax      
        mov ax,data
        mov ds,ax
        mov es,ax    
        pop ax     

        lea si, wellcome
        call print

        lea dx, how
        call print  
    MOV  AH, 00h;wait for any key
    INT  16h

    mov ax, 0x4c00; terminating 
    int 21h                                                        
print: 
            ;printing the line
            mov ah, 9
            int 21h
    ret                                  
ends 

1 个答案:

答案 0 :(得分:0)

这是解决方案,我明白了。在打印子例程

中进行以下更改
print: 
       ;printing the line
       mov bl,2  ;color attribute
       mov ah, 9 
       mov al,0  ;avoding extra characters
       int 10h   ;printing colors
       int 21h
ret