-
Notifications
You must be signed in to change notification settings - Fork 0
/
S3OBJ.OPL
94 lines (79 loc) · 1.38 KB
/
S3OBJ.OPL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
PROC reloc:(ptr%)
local rel%,relc%,s%
local d%,sptr%,id$(8)
local hlen%
sptr%=addr(id$)
relc%=ptr%
pokeb sptr%,8
s%=0
while s%<8
sptr%=uadd(sptr%,1)
pokeb sptr%,peekb(relc%)
relc%=uadd(relc%,1)
s%=s%+1
endwh
if id$<>"S3AsmOPL" : raise -69 : endif
hlen%=peekw(relc%)
sptr%=uadd(ptr%,hlen%+2)
s%=peekw(uadd(ptr%,hlen%))
relc%=uadd(sptr%,s%)
rel%=peekw(relc%)
relc%=uadd(relc%,2)
while rel%
d%=uadd(sptr%,peekw(relc%))
relc%=uadd(relc%,2)
pokew d%,uadd(peekw(d%),sptr%)
rel%=rel%-1
endwh
return sptr%
ENDP
PROC loado:(f$)
local r%,h%,cell%,size%,pos&
local relc%,rel%,d%,id$(8)
r%=IOOPEN(h%,f$,$0400+$0200)
if r%>=0
pokeb addr(id$),8
r%=IOREAD(h%,addr(id$)+1,8)
if id$<>"S3AsmObj"
raise -69
endif
r%=IOREAD(h%,addr(d%),2)
pos&=d%
r%=IOSEEK(h%,1,pos&)
r%=IOREAD(h%,addr(size%),2)
cell%=alloc:(size%)
if cell%=0
IOCLOSE(h%)
raise -10
endif
r%=IOREAD(h%,cell%,size%)
r%=IOREAD(h%,addr(rel%),2)
if rel%
relc%=alloc:(rel%*2)
if relc%=0
IOCLOSE(h%)
raise -10
endif
r%=IOREAD(h%,relc%,rel%*2)
while rel%<>0
d%=uadd(cell%,peekw(relc%))
relc%=uadd(relc%,2)
pokew d%,uadd(peekw(d%),cell%)
rel%=rel%-1
endwh
endif
IOCLOSE(h%)
if r%>0
return cell%
endif
endif
raise r%
ENDP
PROC alloc:(size%)
local ret%
ret%=alloc(size%)
if ret%=0
raise -10
endif
return(ret%)
ENDP