boot.s 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #
  2. ! $Source: /cvsroot/tack/Ack/plat/linux386/boot.s,v $
  3. ! $State: Exp $
  4. ! $Revision: 1.3 $
  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. move.l (0, sp), d0 ! d0 = argc
  29. move.l (4, sp), d1 ! d1 = argv
  30. move.l d0, d2
  31. asl.l #2, d2
  32. move.l (sp, d2), d2
  33. add.l #12, d2 ! d2 = environ
  34. move.l d2, -(sp) ! environ
  35. move.l d0, -(sp) ! argc
  36. move.l d1, -(sp) ! argv
  37. pea (0) ! dummy, representing the return address
  38. jmp (__m_a_i_n)
  39. #if 0
  40. mov eax, (esp) ! eax = argc
  41. lea ebx, 4(esp) ! ebx = argv
  42. lea ecx, (esp)(eax*4)
  43. add ecx, 12 ! environ
  44. push ecx ! environ
  45. push ebx ! argc
  46. push eax ! argv
  47. push eax ! dummy, representing the return argument
  48. xor ebp, ebp
  49. #endif
  50. ! This provides an emergency exit routine used by EM.
  51. .define EXIT
  52. .extern EXIT
  53. EXIT:
  54. pea (1)
  55. jmp (__exit)
  56. ! This is used by the trap routine for diagnostics.
  57. .define WRITE
  58. .extern WRITE
  59. WRITE:
  60. jmp (_write)
  61. ! Define symbols at the beginning of our various segments, so that we can find
  62. ! them. (Except .text, which has already been done.)
  63. .sect .data; begdata:
  64. .sect .rom; begrom:
  65. .sect .bss; begbss:
  66. ! Some magic data. All EM systems need these.
  67. .define .trppc, .ignmask, _errno
  68. .comm .trppc, 4
  69. .comm .ignmask, 4
  70. .comm _errno, 4