-
Notifications
You must be signed in to change notification settings - Fork 0
/
library.lib
155 lines (155 loc) · 1.53 KB
/
library.lib
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
MOV R1,SP
MOV R2,5
SUB R1,R2
MOV R2,"Write"
MOV R6,[R1]
MOV R1,R6
EQ R1,R2
JZ R1,66
MOV R1,SP
MOV R2,4
SUB R1,R2
MOV R2,[R1]
ADD R1,1
MOV R3,[R1]
ADD R1,1
MOV R4,[R1]
MOV R5,5
PUSH R5
PUSH R2
PUSH R3
PUSH R4
PUSH R5
INT 7
POP R1
POP R2
POP R2
POP R2
POP R2
MOV R2,SP
MOV R3,1
SUB R2,R3
MOV [R2],R1
RET
MOV R2,"Read"
MOV R1,R6
EQ R1,R2
JZ R1,124
MOV R1,SP
MOV R2,4
SUB R1,R2
MOV R2,[R1]
ADD R1,1
MOV R3,[R1]
ADD R1,1
MOV R4,[R1]
MOV R5,7
PUSH R5
PUSH R2
PUSH R3
PUSH R4
PUSH R5
INT 6
POP R1
POP R2
POP R2
POP R2
POP R2
MOV R2,SP
MOV R3,1
SUB R2,R3
MOV [R2],R1
RET
MOV R2,"Exit"
MOV R1,R6
EQ R1,R2
JZ R1,182
MOV R1,SP
MOV R2,4
SUB R1,R2
MOV R2,[R1]
ADD R1,1
MOV R3,[R1]
ADD R1,1
MOV R4,[R1]
MOV R5,10
PUSH R5
PUSH R2
PUSH R3
PUSH R4
PUSH R5
INT 10
POP R1
POP R2
POP R2
POP R2
POP R2
MOV R2,SP
MOV R3,1
SUB R2,R3
MOV [R2],R1
RET
MOV R2, "Heapset"
MOV R1, R6
EQ R1, R2
JZ R1, 244
MOV R0, 1024
MOV R1, 1
MOV R2, 2047
GE R2, R0
JZ R2, 208
MOV [R0], -1
ADD R0, R1
MOV R2, 2047
JMP 196
MOV R0, 1024
MOV R1, 1032
MOV R2, 8
MOV R3, 2047
GE R3, R0
JZ R3, 230
MOV [R0], R1
ADD R0, R2
ADD R1, R2
MOV R3, 2047
JMP 216
MOV [2032], -1
MOV [2040], 1024
MOV R0, SP
MOV R1, 1
SUB R0, R1
MOV [R0], 0
RET
MOV R2, "Alloc"
MOV R1, R6
EQ R1, R2
JZ R1, 278
MOV R0, [2040]
MOV R1, -1
EQ R0, R1
JNZ R0, 268
MOV R0, [2040]
MOV R1, [R0]
MOV [2040], R1
MOV R1, R0
MOV R0, SP
MOV R2, 1
SUB R0, R2
MOV [R0], R1
RET
MOV R2, "Free"
MOV R1, R6
EQ R1, R2
JZ R1, 308
MOV R0, [2040]
MOV R1, SP
MOV R2, 4
SUB R1, R2
MOV R1, [R1]
MOV [2040], R1
MOV [R1], R0
MOV R0, SP
MOV R1, 1
SUB R0, R1
MOV [R0], 0
RET