crt1.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 main (int argc, char *argv[], char *envp[]);
  22. int
  23. _start ()
  24. {
  25. asm ("mov____$i8,%eax !0");
  26. asm ("mov____%eax,0x32 &__stdin");
  27. asm ("mov____$i8,%eax !1");
  28. asm ("mov____%eax,0x32 &__stdout");
  29. asm ("mov____$i8,%eax !2");
  30. asm ("mov____%eax,0x32 &__stderr");
  31. asm ("mov____%ebp,%eax");
  32. asm ("add____$i8,%eax !4");
  33. asm ("movzbl_(%eax),%eax");
  34. asm ("add____$i8,%eax !3");
  35. asm ("shl____$i8,%eax !0x02");
  36. asm ("add____%ebp,%eax");
  37. asm ("mov____%eax,0x32 &environ");
  38. asm ("push___%eax");
  39. asm ("mov____%ebp,%eax");
  40. asm ("add____$i8,%eax !8");
  41. asm ("push___%eax");
  42. asm ("mov____%ebp,%eax");
  43. asm ("add____$i8,%eax !4");
  44. asm ("movzbl_(%eax),%eax");
  45. asm ("push___%eax");
  46. main ();
  47. asm ("mov____%eax,%ebx");
  48. asm ("mov____$i32,%eax %1");
  49. asm ("push___%ebx");
  50. asm ("push___%ebx");
  51. asm ("int____$0x80");
  52. asm ("hlt");
  53. }