Initial revision
[ssr] / StraySrc / Libraries / DLLLib / s / wSpace
1 ;
2 ; wspace.s
3 ;
4 ; Handling of DLL workspace and similar things
5 ;
6 ; © 1994 Straylight
7 ;
8
9 ;----- Standard stuff -------------------------------------------------------
10
11 GET libs:header
12 GET libs:swis
13
14 ;----- Other external dependencies ------------------------------------------
15
16 IMPORT |x$stack_overflow|
17 IMPORT malloc
18
19 IMPORT |__errno|,WEAK ;Vile hack :-(
20
21 ;----- Main code ------------------------------------------------------------
22
23 AREA |DLL$$Code|,CODE,READONLY
24
25 ; --- _dll_giveMemory ---
26
27 EXPORT |_dll_giveMemory|
28 |_dll_giveMemory| ROUT
29
30 MOV ip,sp
31 STMFD sp!,{v1,fp,ip,lr,pc}
32 SUB fp,ip,#4
33 CMP sp,sl
34 BLLT |x$stack_overflow|
35
36 MOV v1,#0 ;Start with magic number at 0
37 00 SWI DLL_InstanceVars ;Give DLL some variables
38 CMP v1,#0 ;Is this the end yet?
39 LDMEQDB fp,{v1,fp,sp,pc}^ ;Yes -- return to caller
40 BL malloc ;Allocate variables as reqd.
41 B %b00 ;And give to the DLL
42
43 LTORG
44
45 ; --- _dll_appspace ---
46
47 EXPORT |_dll_appspace|
48 |_dll_appspace| ROUT
49
50 MOV ip,lr ;Keep hold of link register
51 MOV a1,sl ;Point to stack limit thingy
52 SWI DLL_AppData ;Tell DLLManager about this
53 MOVS pc,ip ;Return to caller
54
55 LTORG
56
57 ; --- _dll_clibdata ---
58
59 EXPORT |_dll_clibdata|
60 |_dll_clibdata| ROUT
61
62 MOV ip,lr ;Keep link register safe
63 LDR a1,=|__errno| ;Find the C Library's space
64 SWI DLL_GiveCLibData ;Pass on the CLib data
65 MOVS pc,ip ;Return to caller
66
67 LTORG
68
69 ;----- That's all, folks ----------------------------------------------------
70
71 END