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