Bell 32V development
[unix-history] / usr / src / libc / csu / mcrt0.s
CommitLineData
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
18start:
19 .word 0x0000
20 subl2 $8,sp
21 movl 8(sp),(sp) # argc
22 movab 12(sp),r0
23 movl r0,4(sp) # argv
24L1:
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
30L2:
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
62emsg:
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
65em1:
66 .text
67
68nospace:
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
81eprol:
82
83