0

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 
Taimour
  • 459
  • 5
  • 21

1 Answers1

0

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    
Taimour
  • 459
  • 5
  • 21
  • 1
    This 'solution' is a total mess. AH=9 for int 10h is a "print a character" function. AL should contain character code, CX - number of repeats and BL - color attribute. So you are printing an unknown number (whatever is in CX) of /0 characters when you call `int 10h`. And then you immediately call `int 21h` - that alone should point out that code is wrong. Assuming interrupt 10h handler won't change registers, you are calling function 09h (print $-terminated string) for unknown string address (DX is not initialized). – Vindicar Oct 27 '18 at 08:44