| | |
Changing Text Colour with NASM Assembly
Thread Solved |
Does anyone know how to change the colour of strings using x86 NASM Assembler? I've found tutorials like this:
Which prints the letter "A" once in the colour you choose. This is a handy tutorial, but I would like to be able to print the entire screen text (i.e more than one string) in the same colour. Anyone have any ideas?
Assembly Syntax (Toggle Plain Text)
mov ah, 09h mov al, 97 mov bx, 100b mov cx, 01h int 10h
Which prints the letter "A" once in the colour you choose. This is a handy tutorial, but I would like to be able to print the entire screen text (i.e more than one string) in the same colour. Anyone have any ideas?
Last edited by MichaelSammels; Oct 12th, 2009 at 8:01 am.
Thanks,
Michael
Michael
0
#2 Oct 13th, 2009
Color text-mode memory lies at segment 0xb800 and is 4000 bytes
in length 80*25*2 cuz each visible character on the screen
is accompanied by a text attribute byte.
00000000 Text Attribute Byte
XXBGxxFG
The low-nibble defines the foreground and the high-nibble
the background, and there is a way to disable the blink
bit.
Function 9 - Output Char And Attribute At Hardware Cursor
CX-Repeat
BH-Display Page
BL-Attribute
AL-Character
AH-9
INT 0x10
To clear the screen to one f/b color try this code:
This code writes a blue 'A' char to 0,0:
in length 80*25*2 cuz each visible character on the screen
is accompanied by a text attribute byte.
00000000 Text Attribute Byte
XXBGxxFG
The low-nibble defines the foreground and the high-nibble
the background, and there is a way to disable the blink
bit.
Function 9 - Output Char And Attribute At Hardware Cursor
CX-Repeat
BH-Display Page
BL-Attribute
AL-Character
AH-9
INT 0x10
To clear the screen to one f/b color try this code:
Assembly Syntax (Toggle Plain Text)
clrscr: mov dx, 0 ; Set cursor to top left-most corner of screen mov bh, 0 mov ah, 0x2 int 0x10 mov cx, 2000 ; print 2000 chars mov bh, 0 mov bl, 0x21 ; green bg/blue fg mov al, 0x20 ; blank char mov ah, 0x9 int 0x10 ret
This code writes a blue 'A' char to 0,0:
Assembly Syntax (Toggle Plain Text)
mov cx, 0xb800 mov es, cx mov ax, 0x141 mov [es:0], ax waitkey: mov ah, 0x6 mov dl, 0xff int 0x21 jz waitkey ret
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
![]() |
Similar Threads
- What Editors Create This Code? (HTML and CSS)
- using nasm in ubuntu (Assembly)
- changing text in vb.net2003 (VB.NET)
- Changing text-size ??? (JavaScript / DHTML / AJAX)
- Change text colour in console (C++)
- Input Text colour in forms and submit (Graphics and Multimedia)
- changing desktop icons text colour (Windows NT / 2000 / XP)
Other Threads in the Assembly Forum
- Previous Thread: total rookie,pls help me
- Next Thread: Array input question in assembly
| Thread Tools | Search this Thread |





