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 | .sect .text; .sect .rom; .sect .data; .sect .bss
|
---|
6 |
|
---|
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:
|
---|
16 |
|
---|
17 | .define prtso, hol0, __penviron, __penvp, __fpu_present
|
---|
18 | .sect .text
|
---|
19 | prtso:
|
---|
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;
|
---|
35 | 0: 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 | mov (.ignmask), 56
|
---|
49 |
|
---|
50 | call __m_a_i_n ! Run Pascal program
|
---|
51 |
|
---|
52 | push eax ! push exit status
|
---|
53 | call __exit
|
---|
54 |
|
---|
55 | hlt ! force a trap if exit fails
|
---|
56 |
|
---|
57 | .sect .rom
|
---|
58 | .data4 0 ! Separate I&D: *NULL == 0
|
---|
59 | ! Also keeps the first string in the
|
---|
60 | ! program from appearing at location 0!
|
---|
61 | .sect .data
|
---|
62 | __penviron:
|
---|
63 | .data4 __penvp ! Pointer to environ, or hidden pointer
|
---|
64 |
|
---|
65 | .sect .bss
|
---|
66 | .comm __penvp, 4 ! Hidden environment vector
|
---|
67 | .comm __fpu_present, 4 ! FPU present flag
|
---|
68 |
|
---|
69 | .extern endtext ! Force loading of end labels.
|
---|