NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on June 12, 2007, 03:09:56 PM
-
Hello
How can I change text color or background color in linux? In windows it can be done in this way:
%macro screen 2
xor bh,bh
mov al,%1
mov ah,%2
shl ah,4
or bh,ah
or bh,al
mov ah,06h
xor al,al
xor ch,ch
xor cl,cl
mov dl,80
mov dh,40
int 10h
mov ah,02h
xor bh,bh
xor dh,dh
xor dl,dl
int 10h
%endmacro
Thanks
-
Well, one way would be VT100 escape sequences...
http://www.termsys.demon.co.uk/vtansi.htm (http://www.termsys.demon.co.uk/vtansi.htm)
For example:
global _start
section .data
setcolor db 1Bh, '[36;40m', 0 ; cyan on black
.len equ $ - setcolor
section .text
_start:
mov eax, 4
mov ebx, 1
mov ecx, setcolor
mov edx, setcolor.len
int 80h
mov eax, 1
xor ebx, ebx
int 80h
Needless to say, you'll want a little more than this. (setting everything back to "normal" would be polite)
Another method would be to open /dev/vcsa0 (or some other number?). That will give you, after a short "header", a setup much like "direct screen write" from dos - character in even bytes, attribute in odd bytes.
I'm not aware of anything "like" the bios interrupts available in 16-bit code. I suspect the VT100 approach is your best bet.
Best,
Frank
-
Hello
I have one more question.
When I try to create macros I getting error: "The NetwidSegmentation"
There is the code of macros:
%macro colour 2
pushad
pushf
mov eax,4
mov ebx,1
jmp %%wr
%%setcolor db 1Bh,'[31;40m',0
%%wr: mov ecx,%%setcolor
mov edx,%2
int 80h
;mov eax,1
;mov ebx,0
;int 80h
popf
popad
%endmacro
Please, tell me what i am doing wrong
Thanks