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