-
Notifications
You must be signed in to change notification settings - Fork 27
/
pmem.zap
40 lines (31 loc) · 796 Bytes
/
pmem.zap
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
.SEGMENT "0"
.FUNCT PMEM?,PTR
LESS? PTR,PMEM-STORE /FALSE
LESS? PTR,PMEM-STORE+180 /TRUE
RFALSE
.FUNCT PMEM-RESET,FULL?
ASSIGNED? 'FULL? /?CND1
SET 'FULL?,TRUE-VALUE
?CND1: GRTR? PMEM-WORDS-USED,0 \?CND3
SET 'PMEM-WORDS-USED,0
SUB PMEM-STORE-LENGTH,PMEM-STORE-WORDS
MUL 2,STACK
COPYT PMEM-STORE,0,STACK
?CND3: SET 'PMEM-STORE-WORDS,PMEM-STORE-LENGTH
SET 'PMEM-STORE-POINTER,PMEM-STORE
RTRUE
.FUNCT DO-PMEM-ALLOC,TYPE,LENGTH,STOR,LEFT,NEW
SET 'STOR,PMEM-STORE-POINTER
SET 'LEFT,PMEM-STORE-WORDS
IGRTR? 'LENGTH,LEFT \?CND1
ICALL2 P-NO-MEM-ROUTINE,TYPE
?CND1: ADD PMEM-WORDS-USED,LENGTH >PMEM-WORDS-USED
SUB LEFT,LENGTH >PMEM-STORE-WORDS
MUL LENGTH,2
ADD STOR,STACK >PMEM-STORE-POINTER
DEC 'LENGTH
PUTB STOR,0,LENGTH
PUTB STOR,1,TYPE
RETURN STOR
.ENDSEG
.ENDI