Tutorium 15

Reading time ~1 minute

Nachbesprechung Übung 12

Programmieraufgabe

global collatz_cb

section .text
collatz_cb:
    xor rax, rax
.loop:
    shr rdi, 1
    jz  .end
    inc rax             ; inc does not set carry flag
    jnc .loop
    rcl rdi, 1
    lea rdi, [1+rdi*3]  ; lea abuse
    jmp .loop
.end:
    ret
#include <stdio.h>
#include <inttypes.h>

extern uint64_t collatz_cb(uint64_t);

int main(void)
{ printf("%"PRIu64"\n", collatz_cb(5)); }

Keine Vorbesprechung