-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.xpl
142 lines (134 loc) · 1.98 KB
/
header.xpl
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
decl
type
queue {
integer value;
queue next;
}
endtype
decl
integer initialize(integer strt;);
integer alloc();
integer free(integer position;);
integer initializeQueue(integer strt;);
integer enque(queue &qvar;integer expr;);
integer deque(queue &qvar;);
integer allocQueue();
integer freeQueue(integer position;);
enddecl
integer initialize(integer strt;){
decl
integer p,r;
enddecl
begin
p = 0;
while(p<100)do
r = writemem(strt+(p*10)+9,0);
p = p+1;
endwhile;
return 0;
end
}
integer alloc(){
decl
integer p,r,value,strt;
enddecl
begin
strt = 0;
value = 0;
p = 0;
while(p<100)do
r = readmem(strt+(p*10)+9);
if(r==0)then
r = writemem(strt+(p*10)+9,1);
value = strt+(p*10);
return value;
endif;
p = p+1;
endwhile;
return value;
end
}
integer initializeQueue(integer strt;){
decl
integer p,r;
enddecl
begin
p = 0;
strt = 600;
while(p<100)do
r = writemem(strt+(p*3)+2,0);
p = p+1;
endwhile;
return 0;
end
}
integer allocQueue(){
decl
integer p,r,value,strt;
enddecl
begin
strt = 600;
value = 0;
p = 0;
while(p<100)do
r = readmem(strt+(p*3)+2);
if(r==0)then
r = writemem(strt+(p*3)+2,1);
value = strt+(p*3);
return value;
endif;
p = p+1;
endwhile;
return value;
end
}
integer freeQueue(integer position;){
decl
integer p,r,value;
enddecl
begin
value = 0;
r = writemem(position+2,0);
return value;
end
}
integer enque(queue &qvar;integer expr;){
decl
integer value;
queue new,temp;
enddecl
begin
new = allocQueue();
new.value = expr;
if(qvar == 0)then
qvar = new;
else
temp = qvar;
while(temp.next > 0)do
temp = temp.next;
endwhile;
temp.next = new;
endif;
return value;
end
}
integer deque(queue &qvar;){
decl
integer value;
enddecl
begin
value = qvar.value;
return value;
end
}
integer free(integer position;){
decl
integer p,r,value;
enddecl
begin
value = 0;
r = writemem(position+9,0);
return value;
end
}
end