summaryrefslogtreecommitdiff
path: root/asm_print.c
blob: f2326613d6c91883d5440f73f50e3075ee3fae64 (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
30
31
32
#include <string.h>
#include <stddef.h>

#ifndef __stupid
#define __stupid

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"
    );
}

#endif