source: trunk/minix/lib/i386/rts/m2rtso.s@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.7 KB
Line 
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.
4
5.sect .text; .sect .rom; .sect .data; .sect .bss
6
7.define begtext, begdata, begbss
8.sect .text
9begtext:
10.sect .rom
11begrom:
12.sect .data
13begdata:
14.sect .bss
15begbss:
16
17.define m2rtso, hol0, __penviron, __penvp, __fpu_present
18.sect .text
19m2rtso:
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
24
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;
350: mov ebx, (__penviron)
36 mov (ebx), ecx ! *_penviron = envp;
37
38 push ecx ! push envp
39 push edx ! push argv
40 push eax ! push argc
41
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
47
48 call __m_a_i_n ! run Modula-2 program
49
50 push eax ! push exit status
51 call __exit
52
53 hlt ! force a trap if exit fails
54
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
62
63.sect .bss
64 .comm __penvp, 4 ! Hidden environment vector
65 .comm __fpu_present, 4 ! FPU present flag
66
67.extern endtext ! Force loading of end labels.
Note: See TracBrowser for help on using the repository browser.