head_em.s 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. .define .lino,.filn
  2. .define EXIT,WRITE,BRK
  3. .define begtext,begdata,begbss
  4. .define EARRAY,ERANGE,ESET,EIDIVZ,EHEAP,EILLINS,ECASE,EBADGTO
  5. .define hol0,.reghp,.limhp,.trpim,.trppc
  6. .sect .text
  7. .sect .rom
  8. .sect .data
  9. .sect .bss
  10. ! EM runtime start-off for the Mantra 68000 system
  11. LINO_AD = 0
  12. FILN_AD = 4
  13. EARRAY = 0
  14. ERANGE = 1
  15. ESET = 2
  16. EIDIVZ = 6
  17. EHEAP = 17
  18. EILLINS = 18
  19. ECASE = 20
  20. EBADGTO = 27
  21. .sect .text
  22. begtext:
  23. ! Mantra puts the argument and environment vectors
  24. ! themselves on top of the stack, instead of POINTERS
  25. ! to these vectors. We get things right here.
  26. move.l 4(sp),a0
  27. clr.l -4(a0)
  28. move.l sp,a0
  29. sub.l #8,sp
  30. move.l (a0),(sp)
  31. add.l #4,a0
  32. move.l a0,4(sp)
  33. 1:
  34. tst.l (a0)+
  35. bne 1b
  36. move.l 4(sp),a1
  37. cmp.l (a1),a0
  38. blt 2f
  39. sub.l #4,a0
  40. 2:
  41. move.l a0,8(sp)
  42. ! Now the stack contains an argc (4 bytes), argv-pointer and
  43. ! envp pointer.
  44. jsr __m_a_i_n
  45. add #012,sp
  46. EXIT:
  47. move.l d0,-(sp)
  48. jsr __exit
  49. WRITE: jmp __write
  50. BRK: jmp __brk
  51. .sect .data
  52. begdata:
  53. hol0:
  54. .lino:
  55. .data4 0 ! lino
  56. .filn:
  57. .data4 0 ! filn
  58. .reghp:
  59. .data4 endbss
  60. .limhp:
  61. .data4 endbss
  62. .trppc:
  63. .data4 0
  64. .trpim:
  65. .data4 0
  66. .sect .bss
  67. begbss: !initialization is not needed because ALL entries are in zero space!