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
|
CMDLOOP:
; Receive command safely, EXCEPT zero word
CALL REC_BYTE
CMP R14,#0
JMPR CC_NE,CMDLOOP_ERROR
CMP R15,#CMD_PING
JMPR CC_NE,CMDLOOP_NO_PING
; Respond to ping
MOV R15,#SHELL_ACK
CALL SEND_BYTE
JMP CMDLOOP
CMDLOOP_NO_PING:
MOV R13,#SEND_BYTE
MOV R12,#REC_BYTE
CALL ACK_DATA
CMP R14,#0
JMPR CC_EQ,CMDLOOP_OK
CMDLOOP_ERROR:
MOV R15,R14
CALL SEND_BYTE
JMP CMDLOOP
CMDLOOP_OK:
PUSH R15
MOV R15,#0
CALL SEND_BYTE ; Send zero byte
POP R15 ; Restore command number
CMP R15,#CMD_ERASE_BLOCKS
JMPR CC_NE,CMDLOOP_1
CALL ERASE_BLOCKS
JMP CMDLOOP
CMDLOOP_1:
CMP R15,#CMD_READ
JMPR CC_NE,CMDLOOP_2
CALL READ
JMP CMDLOOP
CMDLOOP_2:
CMP R15,#CMD_WRITE
JMPR CC_NE,CMDLOOP_3
CALL WRITE
JMP CMDLOOP
CMDLOOP_3:
CMP R15,#CMD_IDENTIFY
JMPR CC_NE,CMDLOOP_4
CALL IDENTIFY
JMP CMDLOOP
CMDLOOP_4:
CMP R15,#CMD_ERASE_CHIP
JMPR CC_NE,CMDLOOP
CALL ERASE_CHIP
JMP CMDLOOP
|