boot.s 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #
  2. ! $Source$
  3. ! $State$
  4. ! $Revision$
  5. ! Declare segments (the order is important).
  6. .sect .text
  7. .sect .rom
  8. .sect .data
  9. .sect .bss
  10. .sect .text
  11. begtext:
  12. ! This code is placed at the beginning of the ELF executable and is the
  13. ! first thing that runs.
  14. !
  15. ! On entry, the stack looks like this:
  16. !
  17. ! sp+.. NULL
  18. ! sp+8+(4*argc) env (X quads)
  19. ! sp+4+(4*argc) NULL
  20. ! sp+4 argv (argc quads)
  21. ! sp argc
  22. !
  23. ! The ACK actually expects:
  24. !
  25. ! sp+8 argc
  26. ! sp+4 argv
  27. ! sp env
  28. mov eax, (esp) ! eax = argc
  29. lea ebx, 4(esp) ! ebx = argv
  30. lea ecx, (esp)(eax*4)
  31. add ecx, 12 ! environ
  32. push ecx ! environ
  33. push ebx ! argc
  34. push eax ! argv
  35. push eax ! dummy, representing the return argument
  36. xor ebp, ebp
  37. jmp __m_a_i_n
  38. ! This provides an emergency exit routine used by EM.
  39. .define EXIT
  40. .extern EXIT
  41. EXIT:
  42. push 1
  43. jmp __exit
  44. ! Define symbols at the beginning of our various segments, so that we can find
  45. ! them. (Except .text, which has already been done.)
  46. .sect .data; begdata:
  47. .sect .rom; begrom:
  48. .sect .bss; begbss:
  49. ! Some magic data. All EM systems need these.
  50. .define .trppc, .ignmask, _errno
  51. .comm .trppc, 4
  52. .comm .ignmask, 4
  53. .comm _errno, 4