0

This is the code that I am using:

printing:
    decq    %r13
    movq    $0, %rax
    movq    %r8, %rsi
    movq    $output, %rdi
    call     printf
    cmpq    $0, %r13
    jg    printing

where %r13 is used as the counter.

So as I saw while debugging in GDB, if I have a value of 5 in %r13, the subroutine printing does get executed 5 times, 1 after another. But for some reason, I never get the value that is in %r8 printed more than once. No matter if the number in %r13 is 1 or 50.

And if I change the value of %r8 or %rsi, then that value also gets printed only once.

What could be causing printf just not to print the contents of %r8 more than one time?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
hellwraiz
  • 359
  • 2
  • 13
  • 1
    Please post your complete code or a [mcve]. Also please let us know what operating system you are programming for. – fuz Sep 13 '22 at 19:15
  • 2
    `r8` is call-clobbered, so later executions of `movq %r8, %rsi` will pass some garbage value. – Peter Cordes Sep 13 '22 at 19:16

0 Answers0