-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathos_wait.A51
132 lines (119 loc) · 2.86 KB
/
os_wait.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
;------------------------------------------------------------------------------
; 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_WAIT.A51: This module contains the OS_WAIT function call.
;
; RTX51 TINY VERSION 2
;
;------------------------------------------------------------------------------
NAME ?RTX51_TINY_OS_WAIT
$include (os_defines.inc)
PUBLIC _os_wait, _os_wait1, _os_wait2
?RTX?CODE SEGMENT CODE
RSEG ?RTX?CODE
USING 0 ; Registerbank 0 for following code
;
;------------------------------------------------
; os_wait function
;
; os_wait (uchar typ, uchar timeout) {
_os_wait:
_os_wait1: ; entry point for 1 parameter
_os_wait2: ; entry point for 2 parameters
;---- Variable 'typ' assigned to Register 'B' ----
;---- Variable 'timeout' assigned to Register 'R5' ----
;---- Variable 'st' assigned to Register 'R7' ----
;---- Variable 'twait' assigned to Register 'R6' ----
MOV B,R7
CLR A
; st = 0;
MOV R7,A
; twait = 0;
MOV R6,A
;
MOV A,?RTX_CURRENTTASK
RL A
ADD A,#?RTX?TASKSTATE?S
MOV R0,A
CLR ET0
; if (typ & K_IVL) {
JNB B.B_IVL,??C0005
; st = TMO_EVENT;
MOV R7,#TMO_EVENT
; STATE[current].timer += timeout;
MOV A,@R0
JZ SetTimeout
ADD A,R5
MOV @R0,A
; if (!CY) {
JZ no_wait1 ; zero means no wait
JNC no_wait1 ; no overflow (6.12.2002)
SJMP wait ; overflow (6.12.2002)
??C0005: JNB B.B_WAITTIM,??C0007
SetTimeout: MOV A,R5
MOV @R0,A
JZ no_wait1
wait:
; twait = K_TMO;
MOV R6,#K_TMO
??C0007: INC R0
; }
; if (typ & K_SIG) {
JNB B.B_WAITSIG,??C0003
; if (STATE[current].st & K_RDY) {
; STATE[current].st &= ~K_RDY;
; goto RunTask;
; }
CLR EA
MOV A,@R0
JBC ACC.B_RDY,RunTask
; if (STATE[current].st & SIG_EVENT) {
INC R6 ; replaces ORL AR6,#K_SIG
JNB ACC.B_SIGNAL,??C0003A
SETB EA
; st = SIG_EVENT;
MOV R7,#SIG_EVENT ; correction 9.8.2002
; goto no_wait;
SJMP no_wait
; }
; }
??C0003:
; switchnow (); /* Select Another Task */
CLR EA
MOV A,@R0
; if (STATE[current].st & K_RDY) {
; STATE[current].st &= ~K_RDY;
; goto RunTask;
; }
JBC ACC.B_RDY,RunTask
??C0003A:
ANL A,#NOT (K_READY + K_TMO + K_SIG) ; 6.12.2002
ORL A,R6
MOV @R0,A
SETB EA
SETB ET0
JMP OS_SWITCH_TASK
no_wait1:
; st = TMO_EVENT;
MOV R7,#TMO_EVENT
INC R0
no_wait:
; STATE[current].st &= ~ (st | K_SIG | K_TMO);
; return (st);
MOV A,R7
ORL A,#K_SIG + K_TMO + K_RDY
CPL A
CLR EA
ANL A,@R0
RunTask: XCH A,@R0
SETB EA
SETB ET0
; st |= (previous STATE[current] & K_RDY);
ANL A,#K_RDY ; 6.12.2002
ORL A,R7
MOV R7,A
RET
; }
END