-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtask_user_dispatch.asm
More file actions
44 lines (38 loc) · 876 Bytes
/
Copy pathtask_user_dispatch.asm
File metadata and controls
44 lines (38 loc) · 876 Bytes
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
.equ MIN_TS = 0
.equ MAX_TS = 6
.CSEG
; dispatch routine
; @param UCC0 command to dispatch
; @param UCC1 parameter
; @spoil GREG
; @spoil Tmp2
Task_Dispatch:
mov GREG, UCC0
subi GREG, '0' ; convert ASCII digit to byte
cpi GREG, MIN_TS ; check range
brlo DispWrong
cpi GREG, MAX_TS+1
brsh DispWrong
ldi ZH, high(JumpTable) ; Z = &JumpTable
ldi ZL, low(JumpTable)
subi GREG, MIN_TS ; shift Z to appropriate task
clr Tmp2
add ZL, GREG
adc ZH, Tmp2
mov GREG, UCC1 ; atoi()
subi GREG, '0'
mov UCC1, GREG
ijmp ; indirect jump to matched routine
; matching ret will be made from it
DispWrong: ret ; received wrong task number for dispatch
; skip it
JumpTable: rjmp Pong
rjmp Firmware
rjmp SoundAlarm
rjmp SetLedState
rjmp StatusReport
rjmp WDR_Reset
rjmp WDR_Arm
;todo
; - handle external reset\sound
; - check all commands give response