source: trunk/minix/lib/i86/rts/nprtso.s@ 20

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

Minix 3.1.2a

File size: 1.2 KB
Line 
1! This is the Pascal 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.extern __m_a_i_n, _exit, prtso, hol0, __penvp
6.extern begtext, begdata, begbss, endtext, enddata, endbss
7.text
8begtext:
9prtso:
10 xor bp, bp ! clear for backtrace of core files
11 mov bx, sp
12 mov ax, (bx) ! argc
13 lea dx, 2(bx) ! argv
14 lea cx, 4(bx)
15 add cx, ax
16 add cx, ax ! envp
17
18 ! Test if environ is in the initialized data area and is set to our
19 ! magic number. If so then it is not redefined by the user.
20 mov bx, #_environ
21 cmp bx, #__edata ! within initialized data?
22 jae 0f
23 testb bl, #1 ! aligned?
24 jnz 0f
25 cmp (bx), #0x5353 ! is it our environ?
26 jne 0f
27 mov __penviron, bx ! _penviron = &environ;
280: mov bx, __penviron
29 mov (bx), cx ! *_penviron = envp;
30
31 push cx ! push envp
32 push dx ! push argv
33 push ax ! push argc
34
35 mov .ignmask, #56
36
37 call __m_a_i_n ! run Pascal program
38
39 push ax ! push exit status
40 call __exit
41
42 hlt ! force a trap if exit fails
43
44.data
45begdata:
46 .data2 0 ! for sep I&D: *NULL == 0
47__penviron:
48 .data2 __penvp ! Pointer to environ, or hidden pointer
49
50.bss
51begbss:
52 .comm __penvp, 2 ! Hidden environment vector
Note: See TracBrowser for help on using the repository browser.