File: asm.c

package info (click to toggle)
chibicc 1.0.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,832 kB
  • sloc: ansic: 62,911; sh: 275; makefile: 92
file content (23 lines) | stat: -rwxr-xr-x 405 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "test.h"

char *asm_fn1(void) {
  asm("mov $50, %rax\n\t"
      "mov %rbp, %rsp\n\t"
      "pop %rbp\n\t"
      "ret");
}

char *asm_fn2(void) {
  asm inline volatile("mov $55, %rax\n\t"
                      "mov %rbp, %rsp\n\t"
                      "pop %rbp\n\t"
                      "ret");
}

int main() {
  ASSERT(50, asm_fn1());
  ASSERT(55, asm_fn2());

  printf("OK\n");
  return 0;
}