summaryrefslogtreecommitdiff
path: root/asm_print.c
blob: ccd610e10dd14f9140e565dd36a38c260cadd0cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <string.h>
#include <stddef.h>

void dprint(const char* str);

int main(void)
{
    const char* message = "Hello, World!";

    dprint(message);

    return 0;
}

void dprint(const char* str)
{
    size_t len = strlen(str);

    asm volatile (
        "movq $1, %%rax;"
        "movq $1, %%rdi;"
        "movq %0, %%rsi;"
        "movq %1, %%rdx;"
        "syscall;"
        :
        : "r" (str), "r" (len)
        : "%rax", "%rdi", "%rsi", "%rdx"
    );
}