Swap Hilfsprogramm

Reading time ~1 minute

Framework für Swap von zwei Werten

#include <stdio.h>
#include <inttypes.h>

extern void bubble_asm(int64_t*, int);

int main(int argc, char const * argv[])
{
    int64_t buffer[16];
    buffer[0] = 0;
    buffer[1] = 1;

    bubble_asm(buffer, 16);

    printf("%"PRIX64"\n", buffer[0]);
    printf("%"PRIX64"\n", buffer[1]);
    return 0;
}

Framework für Swap von dem höchsten Wert ans Ende von einer Liste von 16

#include <stdio.h>
#include <inttypes.h>

extern void bubble_asm(int64_t*, int);

int main(int argc, char const * argv[])
{
    int64_t buffer[16];
    for (size_t i = 0; i < 16; i++)
        buffer[i] = 15-i;

    bubble_asm(buffer, 16);

    for (size_t i = 0; i < 15; i++)
        printf("%"PRIX64", ", buffer[i]);
    printf("%"PRIX64"\n", buffer[15]);

    return 0;
}