News for hackers. Stuff that matters.
Re:Hello world in C inline assembly (2020) by onderweg on Sunday June 16, 2024 @02:32AM (#40695096)
Is anyone aware of a similar example, for ARM assembly on macOS?
Re:Hello world in C inline assembly (2020) by brontitall on Monday June 17, 2024 @02:27AM (#40702845)
Not inline, but this was linked in a comment on HN a few days ago

https://github.com/below/HelloSilicon

Re:Hello world in C inline assembly (2020) by oguz-ismail on Monday June 17, 2024 @04:15AM (#40703398)

    int
    main(void) {
        register const char *msg asm("x1") = "hello, world!\n";
        asm volatile (
            "mov w0, #1\n"
            "mov w2, #14\n"
            "mov w16, #4\n"
            "svc #128\n"
            :
            : "r" (msg)
        );
    }
Re:Hello world in C inline assembly (2020) by robxorb on Monday June 17, 2024 @10:31AM (#40705999)
How does one compile this?

EDIT: my bad, my source had a typo - it's as easy as you'd think:

  $ cc hello.c -o hello
  $ ./hello
Re:Hello world in C inline assembly (2020) by onderweg on Monday June 17, 2024 @12:14PM (#40707285)
thanks!