Reputation: 133
I want to set the color when I call printf
from assembly.
This is my code:
Out:
mov rdi, answer
mov rsi, r10
mov rax,0
call printf
section .data
answer: db "\033[0;31m%d\033[0m",10,0
I use NASM to compile and gcc to link:
nasm -f elf64 "%f"
gcc -o %e %e.o
However, the output is:
\033[0;31m(my r10)\033[0m
Upvotes: 3
Views: 809
Reputation: 75062
Use `
for surrounding strings to have escape sequence work in NASM.
Reference: 3.4.2 Character Strings
Try this:
Out:
mov rdi, answer
mov rsi, r10
mov rax,0
call printf
section .data
answer: db `\033[0;31m%d\033[0m`,10,0
Upvotes: 3