-
Notifications
You must be signed in to change notification settings - Fork 4
/
MyHeapAsm.a
executable file
·159 lines (120 loc) · 3.96 KB
/
MyHeapAsm.a
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
; --> MyHeapAsm.TEXT, a subset of MemTraps.text used by MacPaint
;
.INCLUDE MAC:SysMacs.Text
.INCLUDE MAC:SysEqu.Text
.PROC MoreMasters
;-------------------------------------------------------
;
; PROCEDURE MoreMasters;
;
_MoreMasters
RTS
.FUNC MemError
.DEF ErrorCode
;----------------------------------------------------------------------
;
; Function MemError: ErrCode;
;
Move.W ErrorCode,4(SP) ;last error
RTS
;
; Holds the last result code from the Memory Manager
;
ErrorCode .Word 0
.FUNC MaxMem
;-------------------------------------------------------
;
; FUNCTION MaxMem(VAR grow: LongInt): LongInt;
;
Move.L (SP)+,A1 ;get return address
_MaxMem ;let OS do it
Move.L A0,D1 ;max growth allowed
Move.L (SP)+,A0 ;get the pointer to VAR grow
Move.L D1,(A0)
Move.L D0,(SP) ;save result
Jmp (A1) ;return to caller
.FUNC FreeMem
;-------------------------------------------------------
;
; FUNCTION FreeMem: LongInt;
;
_FreeMem
MOVE.L D0,4(SP)
RTS
.PROC SetApplLimit,1
.REF ErrorCode
;-------------------------------------------------------
;
; PROCEDURE SetApplLimit(zoneLimit: Ptr);
;
MOVE.L (SP)+,A1 ;get return address
MOVE.L (SP)+,A0 ;get zoneLimit
_SetApplLimit ;trap to memory manager
LEA ErrorCode,A0 ;point to LastPH save location
Move.W D0,(A0) ;save error
JMP (A1) ;Return
.PROC SetGrowZone
;-------------------------------------------------------
;
; PROCEDURE SetGrowZone(growProc: ProcPtr);;
;
MOVE.L (SP)+,A1 ;get return address
MOVE.L (SP)+,A0 ;get procedure pointer
_SetGrowZone ;trap to memory manager
JMP (A1) ;and return
.FUNC NewHandle
;-------------------------------------------------------
;
; FUNCTION NewHandle(byteCount: LongInt): Handle;
;
MOVE.L (SP)+,A1 ;get return address
MOVE.L (SP)+,D0 ;get the handle size
_NewHandle
MOVE.L A0,(SP)
JMP (A1)
.PROC DisposHandle
;-------------------------------------------------------
;
; PROCEDURE DisposHandle(h: Handle);
;
MOVE.L (SP)+,A1 ;get return address
MOVE.L (SP)+,A0 ;get the handle
_DisposHandle
JMP (A1)
.PROC HLock
;-------------------------------------------------------
;
; PROCEDURE HLock(h: Handle);
;
MOVE.L (SP)+,A1 ;get return address
MOVE.L (SP)+,A0 ;get the handle
BSET #LOCK,(A0) ;set lock bit in master
JMP (A1) ;and return
.PROC HUnLock
;-------------------------------------------------------
;
; PROCEDURE HUnLock(h: Handle);
;
MOVE.L (SP)+,A1 ;get return address
MOVE.L (SP)+,A0 ;get the handle
BCLR #LOCK,(A0) ;clear lock bit in master
JMP (A1) ;and return
.PROC HPurge
;-------------------------------------------------------
;
; PROCEDURE HLock(h: Handle);
;
MOVE.L (SP)+,A1 ;get return address
MOVE.L (SP)+,A0 ;get the handle
BSET #PURGE,(A0) ;set purge bit in master
JMP (A1) ;and return
.PROC HNoPurge
;-------------------------------------------------------
;
; PROCEDURE HUnLock(h: Handle);
;
MOVE.L (SP)+,A1 ;get return address
MOVE.L (SP)+,A0 ;get the handle
BCLR #PURGE,(A0) ;clear purge bit in master
JMP (A1) ;and return
.END