crt1.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. *
  5. * This file is part of GNU Mes.
  6. *
  7. * GNU Mes is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * GNU Mes is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "mes/lib-mini.h"
  21. int __stdin;
  22. int __stdout;
  23. int __stderr;
  24. char **environ;
  25. int main (int argc, char **argv, char **envp);
  26. /* FIXME: this is going to be called `FUNCTION__start'
  27. int
  28. _start ()
  29. {
  30. asm ("mov____$i8,%eax !0");
  31. asm ("mov____%eax,0x32 &GLOBAL___stdin");
  32. asm ("mov____$i8,%eax !1");
  33. asm ("mov____%eax,0x32 &GLOBAL___stdout");
  34. asm ("mov____$i8,%eax !2");
  35. asm ("mov____%eax,0x32 &GLOBAL___stderr");
  36. asm ("mov____%ebp,%eax");
  37. asm ("add____$i8,%eax !4");
  38. asm ("movzbl_(%eax),%eax");
  39. asm ("add____$i8,%eax !3");
  40. asm ("shl____$i8,%eax !0x02");
  41. asm ("add____%ebp,%eax");
  42. asm ("mov____%eax,0x32 &GLOBAL_environ");
  43. asm ("push___%eax");
  44. asm ("mov____%ebp,%eax");
  45. asm ("add____$i8,%eax !8");
  46. asm ("push___%eax");
  47. asm ("mov____%ebp,%eax");
  48. asm ("add____$i8,%eax !4");
  49. asm ("movzbl_(%eax),%eax");
  50. asm ("push___%eax");
  51. main ();
  52. asm ("mov____%eax,%ebx");
  53. asm ("mov____$i32,%eax %1");
  54. asm ("int____$0x80");
  55. asm ("hlt");
  56. }
  57. */