-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.a51
77 lines (65 loc) · 1.49 KB
/
console.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
$NOMOD51
#include <Reg517a.inc>
NAME processC
EXTRN CODE (processA, processB)
EXTRN DATA (processStartAdress, newBit, processTable)
EXTRN NUMBER (isNew, isDel, isNon)
PUBLIC processC
; create code segment for this process
processCSegment SEGMENT CODE
RSEG processCSegment
processC:
; set stackpointer relative to
; processTable
MOV A, #processTable
ADD A, #56D
MOV SP, A
endlessLoop:
; reset watchdog timer
SETB WDT
SETB SWDT
; wait for input on UART0
loopRec:
MOV A, S0CON
JNB RI0, loopRec
; save received input in R7
; and call the input handler
MOV R7, S0BUF
CALL handleSerial0Input
CLR RI0
JMP endlessLoop
RET
; triggers creation or deletion of a process
; according to the received input
handleSerial0Input:
; check input on R7 and set parameters accordingly
CJNE R7,#'a', afterA
; trigger creation of processA
inputA:
MOV DPTR, #processA
MOV processStartAdress + 1, DPL
MOV processStartAdress + 0, DPH
MOV newBit, #isNew
JMP afterC
afterA:
CJNE R7,#'b', afterB
; trigger deletion of processA
inputB:
MOV DPTR, #processA
MOV processStartAdress + 1, DPL
MOV processStartAdress + 0, DPH
MOV newBit, #isDel
JMP afterC
afterB:
CJNE R7,#'c', afterC
; trigger creation of processB
inputC:
MOV DPTR, #processB
MOV processStartAdress + 1, DPL
MOV processStartAdress + 0, DPH
MOV newBit, #isNew
afterC:
; reset R7
MOV R7, #0x00
RET
END