I\'m doing an iso file in assembly and I want to add color to the text (in this case: red).
Does anyone know how to do it?
[BITS 16]
[ORG 0x7C00]
jmp ma
You can use Int 10/AH:0x09. It has the same arguments as Int 10/AH:0x0E, except that BH is the text color. Simply add the following line to your code.
mov ah, 09h
mov bh, 0xF0 ; add this line, this is the text color (white on black)
int 10h
Another alternative that I use, since BIOS functions, aren't available in protected mode. Using the memory at 0x0B800. The general code then becomes:
mov ebx, 0xb800 ; the address for video memeory
mov ah, 0xF0 ; the color byte is stored in the upper part of ax (ah).
printstr:
lodsb ; load char at si into al and increment si.
cmp al, 0
je .done
mov [ebx], ax ; move the character into video memeory.
add ebx, 2 ; move the video memeory pointer up two bytes.
jmp printstr
.done:
ret
Additional resources for looking into this may include: