How to change or set background color in 8086 assembly?

29,200

Solution 1

You can change the background and foreground color for all the screen by using BIOS function 06h

MOV AH, 06h    ; Scroll up function
XOR AL, AL     ; Clear entire screen
XOR CX, CX     ; Upper left corner CH=row, CL=column
MOV DX, 184FH  ; lower right corner DH=row, DL=column 
MOV BH, 1Eh    ; YellowOnBlue
INT 10H

The numbers suit the text video mode of 80x25.

One of the best sources of information on BIOS and DOS Interrupts for the IBM PC is Ralf Brown's Interrupt List. INT 10h is the general BIOS interrupt for video routines. A complete list of the INT 10h routines can be found here. I have used the BIOS routine INT 10h/AH=06 which is documented as:

VIDEO - SCROLL UP WINDOW

AH = 06h
AL = number of lines by which to scroll up (00h = clear entire window)
BH = attribute used to write blank lines at bottom of window
CH,CL = row,column of window's upper left corner
DH,DL = row,column of window's lower right corner

Return:
Nothing

Solution 2

This is blue screen:

mov ah, 09h
mov cx, 1000h
mov al, 20h
mov bl, 17  ; This is Blue & White.

You can change 17 to other color numbers;

  • 0 = Black
  • 1 = Blue
  • 2 = Green
  • 3 = Aqua
  • 4 = Red
  • 5 = Purple
  • 6 = Yellow
  • 7 = White
  • 8 = Gray,
  • 9 = Light Blue.

Example:

mov bl, 47

This is Red & White.

Share:
29,200
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I am learning 8086 assembly. I need to change the background colour of the screen using 8086 assembly. I saw a few tutorials where they could set only a portion of the screen. I don't want to do this by DOS Interrupts whereas all the tutorials are in DOS Interrupts. It would be good if anyone show me the code to set the whole portion of the screen(background colour) using BIOS Interrupts.