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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With