1 year ago

#341324

test-img

Azer

How can I use printf in one line multiple times(AT&T syntax)?

I have the following code:

.global _start 
.data 
i : .space 10, 0
format: .asciz "%d \n"
.text
_start:
jmp test1
loop1:
movq $i, %rsi
incq (%rsi)    
movq (%rsi),%rax
pushq %rax
pushq %rcx
movq $format,%rdi
movq %rax,%rsi
xorq %rax,%rax
call printf
popq %rcx
popq %rax
test1:
movq $i, %r8
movq (%r8), %r9
cmp $8, %r9
jl loop1
movq $0, %rdi
movq $60, %rax
syscall

It prints 8 digits starting from 1 to 8 each in a new line, but when I try to print them all in one line by changing the format like this: format: .asciz "%d", it prints nothing. Is there any idea why it happens?

assembly

printf

att

0 Answers

Your Answer

Accepted video resources