Commit | Line | Data |
---|---|---|
4b9ccde7 | 1 | # @(#)mcrt0.s 4.1 (Berkeley) 12/21/80 |
9c8fc5ca BJ |
2 | # C runtime startoff including monitoring |
3 | ||
4 | .set exit,1 | |
5 | .set cbufs,300 | |
6 | ||
7 | .globl start | |
8 | .globl _monitor | |
9 | .globl _sbrk | |
10 | .globl _main | |
11 | .globl _exit | |
12 | .globl _IEH3exit | |
13 | .globl _etext | |
14 | .globl _environ | |
15 | .globl __cleanup | |
16 | .comm countbase,4 | |
17 | ||
18 | ||
19 | start: | |
20 | .word 0x0000 | |
21 | subl2 $8,sp | |
22 | movl 8(sp),(sp) # argc | |
23 | movab 12(sp),r0 | |
24 | movl r0,4(sp) # argv | |
25 | L1: | |
26 | tstl (r0)+ # null args term ? | |
27 | bneq L1 | |
28 | cmpl r0,*4(sp) # end of 'env' or 'argv' ? | |
29 | blss L2 | |
30 | tstl -(r0) # envp's are in list | |
31 | L2: | |
32 | movl r0,8(sp) # env | |
33 | movl r0,_environ # indir is 0 if no env ; not 0 if env | |
34 | ||
35 | subl3 $eprol,$_etext,r1 | |
36 | addl2 $7,r1 | |
37 | extzv $3,$16,r1,r1 | |
38 | addl2 r1,r1 # tally size | |
39 | addl2 $8*cbufs+12,r1 # entrance count plus header | |
40 | pushl $cbufs # # entrance counters | |
41 | pushl r1 # bufsiz | |
42 | pushl r1 # for sbrk | |
43 | calls $1,_sbrk | |
44 | cmpl r0,$-1 | |
45 | beql nospace | |
46 | # bandaid for sbrk not clearing memory (remove bandaid when fixed) | |
47 | # addl3 (sp),(sp),r1 | |
48 | #L100: | |
49 | # clrb -1(r0)[r1] | |
50 | # sobgtr r1,L100 | |
51 | # end bandaid | |
52 | pushl r0 | |
53 | addl3 $12,r0,countbase | |
54 | pushab _etext | |
55 | pushab eprol | |
56 | calls $5,_monitor | |
57 | calls $3,_main | |
58 | pushl r0 | |
59 | calls $1,_exit | |
60 | ||
61 | .data | |
62 | _environ: .space 4 | |
63 | emsg: | |
64 | .byte 'N,'o,' ,'s,'p,'a,'c,'e,' ,'f,'o,'r,' | |
65 | .byte 'm,'o,'n,'i,'t,'o,'r,' ,'b,'u,'f,'f,'e,'r,0xa,0x0 | |
66 | em1: | |
67 | .text | |
68 | ||
69 | nospace: | |
70 | pushl $em1-emsg | |
71 | pushab emsg | |
72 | pushl $2 | |
73 | calls $3,_write | |
74 | ||
75 | _exit: | |
76 | _IEH3exit: | |
77 | .word 0x0000 | |
78 | calls $0,__cleanup | |
79 | pushl $0 | |
80 | calls $1,_monitor | |
81 | chmk $exit | |
82 | eprol: | |
83 | ||
84 |