How to print text in color with interrupts?

纵然是瞬间 提交于 2019-12-14 03:22:09

问题


This is my code it print in white color which is the default one. I know how to print in color without interrupts, but I don't want to do that. I want to print it in any other color using interrupts.How can I do that?? Any Idea? Thanks in advance I am using emu8086 as an assembler

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:


Here is the solution, I got it. Make the following changes in print subroutine

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    


来源:https://stackoverflow.com/questions/20811752/how-to-print-text-in-color-with-interrupts

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