-
Notifications
You must be signed in to change notification settings - Fork 2
/
os_delete.a51
180 lines (169 loc) · 3.6 KB
/
os_delete.a51
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
;------------------------------------------------------------------------------
; This file is part of the 'RTX-51 tiny' Real-Time Operating System Package
; Copyright KEIL ELEKTRONIK GmbH and Keil Software, Inc. 1991 - 2002
;------------------------------------------------------------------------------
;
; OS_DELETE.A51: This module contains the OS_DELETE_TASK function
;
; RTX51 TINY VERSION 2
;
;------------------------------------------------------------------------------
NAME ?RTX51_TINY_OS_DELETE
$include (os_defines.inc)
PUBLIC _os_delete_task
?RTX?CODE SEGMENT CODE
RSEG ?RTX?CODE
USING 0 ; Registerbank 0 for following code
; uchar os_delete_task (uchar no) {
; uchar i;
; uchar last, first, check;
;
_os_delete_task:
;---- Variable 'first' assigned to Register 'R1' ----
;---- Variable 'last' assigned to Register 'R5' ----
;---- Variable 'check' assigned to Register 'R4' ----
;---- Variable 'no' assigned to Register 'R7' ----
; if (no > MAXTASKN) return (0xff);
MOV A,R7
SETB C
SUBB A,#?RTX_MAXTASKN
JC ?C0030
?C0032: MOV R7,#0FFH
RET
?C0030:
; if (!(STATE[no].st & K_ACTIVE)) return (0xff);
MOV A,R7
RL A
ADD A,#?RTX?TASKSTATE?S+1
MOV R0,A
MOV A,@R0
JNB ACC.B_ACTIVE,?C0032
; STATE[no].st &= ~(K_ACTIVE | K_READY | K_SIG | K_TMO | K_ROBIN);
CLR EA
MOV A,@R0
ANL A,#NOT (K_ACTIVE+K_READY+K_SIG+K_TMO+K_ROBIN)
MOV @R0,A
SETB EA
; if (current == no) {
MOV A,?RTX_CURRENTTASK
CJNE A,AR7,?C0033
; SP = STKP[no];
MOV A,#?RTX?TASKSP?S
ADD A,R7
MOV R0,A
MOV A,@R0
MOV SP,A
; switchnow ();
OS_delete_task_exit1:
LJMP OS_SWITCH_TASK
; }
?C0033:
; if (current < no) {
JNC ?C0034
; last = (no == MAXTASKN) ? STACKTOP : STKP[no+1];
MOV A,#?RTX?TASKSP?S+1
ADD A,R7
MOV R0,A
MOV A,@R0
CJNE R7,#?RTX_MAXTASKN,?C0035
MOV A,#?RTX_RAMTOP
?C0035:
MOV R5,A
; first = STKP[no];
DEC R0
MOV A,@R0
MOV R1,A
?C0039:
; do {
; check = STKP[no];
MOV A,#?RTX?TASKSP?S
ADD A,R7
MOV R0,A
MOV R3,A ; save @STKP
MOV A,@R0
MOV R4,A
; while (first != check) {
?C0040:
MOV A,R1
XRL A,R4
JZ ?C0037
; DBYTE[last] = DBYTE[first];
; SOURCE LINE # 186
MOV R0,AR5
MOV A,@R1
MOV @R0,A
; last--;
DEC R5
; first--;
DEC R1
; }
SJMP ?C0040
?C0037:
; STKP[no] = last;
MOV R0,AR3 ; restore @STKP
MOV @R0,AR5
; no--;
DEC R7
; } while (current != no);
MOV A,?RTX_CURRENTTASK
CJNE A,AR7,?C0039
; return (0);
MOV R7,#0
OS_delete_task_exit2:
RET
; }
?C0034:
; if (current > no) {
; last = STKP[no+1];
MOV A,#?RTX?TASKSP?S+1
ADD A,R7
MOV R0,A
MOV A,@R0
MOV R5,A
; first = STKP[no];
DEC R0
MOV AR1,@R0
?C0045:
; do {
; no++;
INC R7
; STKP[no] = first;
MOV A,#?RTX?TASKSP?S
ADD A,R7
MOV R0,A
MOV @R0,AR1
; check = (no == current) ? SP : STKP[no+1];
INC R0
MOV AR4,@R0
MOV A,?RTX_CURRENTTASK
CJNE A,AR7,?C0046
MOV R4,SP
?C0046:
; while (last != check) {
MOV A,R5
XRL A,R4
JZ ?C0043
; last++;
INC R5
; first++;
INC R1
; DBYTE[first] = DBYTE[last];
MOV R0,AR5
MOV A,@R0
MOV @R1,A
; }
SJMP ?C0046
; } while (current != no);
?C0043:
MOV A,?RTX_CURRENTTASK
CJNE A,AR7,?C0045
; SP = first;
MOV SP,R1
; return (0);
MOV R7,#0
; }
;}
?C0031:
OS_delete_task_exit3:
RET
END