. service tells you which device it couldn't stat
[minix3.git] / lib / i386 / rts / m2rtso.s
blob92b6ce08067ee0fe477d7f88b896083a80ce5764
1 ! This is the Modula-2 run-time start-off routine. It's job is to take the
2 ! arguments as put on the stack by EXEC, and to parse them and set them up the
3 ! way _m_a_i_n expects them.
5 .sect .text; .sect .rom; .sect .data; .sect .bss
7 .define begtext, begdata, begbss
8 .sect .text
9 begtext:
10 .sect .rom
11 begrom:
12 .sect .data
13 begdata:
14 .sect .bss
15 begbss:
17 .define m2rtso, hol0, __penviron, __penvp, __fpu_present
18 .sect .text
19 m2rtso:
20 xor ebp, ebp ! clear for backtrace of core files
21 mov eax, (esp) ! argc
22 lea edx, 4(esp) ! argv
23 lea ecx, 8(esp)(eax*4) ! envp
25 ! Test if environ is in the initialized data area and is set to our
26 ! magic number. If so then it is not redefined by the user.
27 mov ebx, _environ
28 cmp ebx, __edata ! within initialized data?
29 jae 0f
30 testb bl, 3 ! aligned?
31 jnz 0f
32 cmp (ebx), 0x53535353 ! is it our environ?
33 jne 0f
34 mov (__penviron), ebx ! _penviron = &environ;
35 0: mov ebx, (__penviron)
36 mov (ebx), ecx ! *_penviron = envp;
38 push ecx ! push envp
39 push edx ! push argv
40 push eax ! push argc
42 ! Test the EM bit of the MSW to determine if an FPU is present and
43 ! set __fpu_present if one is found.
44 smsw ax
45 testb al, 0x4 ! EM bit in MSW
46 setz (__fpu_present) ! True if not set
48 call __m_a_i_n ! run Modula-2 program
50 push eax ! push exit status
51 call __exit
53 hlt ! force a trap if exit fails
55 .sect .rom
56 .data4 0 ! Separate I&D: *NULL == 0
57 ! Also keeps the first string in the
58 ! program from appearing at location 0!
59 .sect .data
60 __penviron:
61 .data4 __penvp ! Pointer to environ, or hidden pointer
63 .sect .bss
64 .comm __penvp, 4 ! Hidden environment vector
65 .comm __fpu_present, 4 ! FPU present flag
67 .extern endtext ! Force loading of end labels.