hello.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright (C) 2021 Rain */
  2. /* This file is part of XNIX. */
  3. /*
  4. XNIX is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) and later version.
  8. */
  9. /*
  10. XNIX is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. */
  15. /*
  16. You should have received a copy of the GNU General Public License
  17. along with XNIX. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #include <sys/syscall.h>
  20. static char msg[] = "hello, world";
  21. __uint64_t utask_a(__uint64_t arg) {
  22. __uint64_t addr;
  23. /* we must use this, because &msg will returns the
  24. * msg(%rip) (0x800000 based), but msg is in the
  25. * .data section.
  26. * */
  27. __asm__ __volatile__ (
  28. "leaq msg, %0\n\t"
  29. : "=r" (addr)
  30. );
  31. do_call_1(2, addr);
  32. do_call_0(1);
  33. /* it won't here */
  34. for (;;);
  35. }