Pristine Ack-5.5
[Ack-5.5.git] / mach / m68k2 / libsys / head_em.s
1 .define .lino,.filn
2 .define EXIT,BRK,WRITE
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 Bleasdale 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         ! Bleasdale 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         add.l   #2,sp !convert argc from 4-byte to 2-byte
54         jsr     __m_a_i_n
55         add     #010,sp
56 EXIT:
57         move.w  d0,-(sp)
58         jsr     __exit
59
60 BRK:
61         jmp     __brk
62
63 WRITE:
64         jmp     __write
65
66         .sect .data
67 begdata:
68 hol0:
69 .lino:
70         .data2  0,0     ! lino
71 .filn:
72         .data4  0       ! filn
73 .reghp:
74         .data4  endbss
75 .limhp:
76         .data4  endbss
77 .trppc:
78         .data4  0
79 .trpim:
80         .data2  0
81
82
83         .sect .bss
84 begbss: !initialization is not needed because ALL entries are in zero space!