📄 shell.s
字号:
ldd R17,z+1
rcall _serial_send
.dbline 107
; serial_send(":\t");
ldi R16,<L61
ldi R17,>L61
rcall _serial_send
.dbline 108
; serial_send(InnerCmd[i].help);
ldi R16,6
mov R17,R20
muls R16,R17
movw R30,R0
ldi R24,<_InnerCmd+2
ldi R25,>_InnerCmd+2
add R30,R24
adc R31,R25
ldd R16,z+0
ldd R17,z+1
rcall _serial_send
.dbline 109
; i++;
inc R20
.dbline 110
; }
L59:
.dbline 105
ldi R16,6
mov R17,R20
muls R16,R17
movw R30,R0
ldi R24,<_InnerCmd
ldi R25,>_InnerCmd
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
tst R2
brne L58
tst R3
brne L58
X14:
.dbline 111
; }else{
rjmp L57
L56:
.dbline 111
.dbline 112
; i=GetCmdMatch(argv[1]);
movw R30,R22
ldd R16,z+2
ldd R17,z+3
rcall _GetCmdMatch
mov R20,R16
.dbline 113
; if (i<0)
cpi R16,0
brge L63
X15:
.dbline 114
; serial_send("Haven't this command.\n");
ldi R16,<L65
ldi R17,>L65
rcall _serial_send
rjmp L64
L63:
.dbline 116
; else
; serial_send(InnerCmd[i].help);
ldi R16,6
mov R17,R20
muls R16,R17
movw R30,R0
ldi R24,<_InnerCmd+2
ldi R25,>_InnerCmd+2
add R30,R24
adc R31,R25
ldd R16,z+0
ldd R17,z+1
rcall _serial_send
L64:
.dbline 117
; }
L57:
.dbline 118
; return 0;
clr R16
clr R17
.dbline -2
L55:
.dbline 0 ; func end
rjmp pop_xgsetF00C
.dbsym r i 20 C
.dbsym r argv 22 ppc
.dbsym r argc 10 c
.dbend
.dbfunc e ParseArgs _ParseArgs fV
; i -> R10
; state -> R22
; c -> R20,R21
; argv -> y+8
; argc -> R12,R13
; cmdline -> R10,R11
.even
_ParseArgs::
rcall push_xgsetF03C
movw R12,R18
movw R10,R16
.dbline -1
.dbline 121
; }
; void ParseArgs(char *cmdline,signed char *argc,char** argv)
; {
.dbline 126
; #define STATE_WHITESPACE 0
; #define STATE_WORD 1
;
; char *c;
; char state = STATE_WHITESPACE;
clr R22
.dbline 129
; char i;
;
; *argc = 0;
clr R2
movw R30,R12
std z+0,R2
.dbline 131
;
; if(strlen(cmdline) == 0)
movw R16,R10
rcall _strlen
cpi R16,0
cpc R16,R17
brne L68
X16:
.dbline 132
; return;
rjmp L67
L68:
.dbline 135
;
; /* convert all tabs into single spaces */
; c = cmdline;
movw R20,R10
rjmp L71
L70:
.dbline 137
; while(*c != '\0')
; {
.dbline 138
; if(*c == '\t')
movw R30,R20
ldd R24,z+0
cpi R24,9
brne L73
X17:
.dbline 139
; *c = ' ';
ldi R24,32
std z+0,R24
L73:
.dbline 140
; c++;
subi R20,255 ; offset = 1
sbci R21,255
.dbline 141
; }
L71:
.dbline 136
movw R30,R20
ldd R2,z+0
tst R2
brne L70
X18:
.dbline 143
;
; c = cmdline;
movw R20,R10
.dbline 144
; i = 0;
clr R10
rjmp L76
L75:
.dbline 148
;
; /* now find all words on the command line */
; while(*c != '\0')
; {
.dbline 149
; if(state == STATE_WHITESPACE)
tst R22
brne L78
X19:
.dbline 150
; {
.dbline 151
; if(*c != ' ')
movw R30,R20
ldd R24,z+0
cpi R24,32
breq L79
X20:
.dbline 152
; {
.dbline 153
; argv[i] = c; //将argv[i]指向c
mov R30,R10
clr R31
lsl R30
rol R31
ldd R0,y+8
ldd R1,y+9
add R30,R0
adc R31,R1
std z+1,R21
std z+0,R20
.dbline 154
; i++;
inc R10
.dbline 155
; state = STATE_WORD;
ldi R22,1
.dbline 156
; }
.dbline 157
; }
rjmp L79
L78:
.dbline 159
; else
; { /* state == STATE_WORD */
.dbline 160
; if(*c == ' ')
movw R30,R20
ldd R24,z+0
cpi R24,32
brne L82
X21:
.dbline 161
; {
.dbline 162
; *c = '\0';
clr R2
std z+0,R2
.dbline 163
; state = STATE_WHITESPACE;
clr R22
.dbline 164
; }
L82:
.dbline 165
; }
L79:
.dbline 166
; c++;
subi R20,255 ; offset = 1
sbci R21,255
.dbline 167
; }
L76:
.dbline 147
movw R30,R20
ldd R2,z+0
tst R2
brne L75
X22:
.dbline 169
;
; *argc = i;
movw R30,R12
std z+0,R10
.dbline -2
L67:
.dbline 0 ; func end
rjmp pop_xgsetF03C
.dbsym r i 10 c
.dbsym r state 22 c
.dbsym r c 20 pc
.dbsym l argv 8 ppc
.dbsym r argc 12 pC
.dbsym r cmdline 10 pc
.dbend
.dbfunc e GetCmdMatch _GetCmdMatch fC
; i -> R10
; cmd -> R12,R13
.even
_GetCmdMatch::
rcall push_xgset003C
movw R12,R16
.dbline -1
.dbline 174
; #undef STATE_WHITESPACE
; #undef STATE_WORD
; }
; signed char GetCmdMatch(char * cmd)
; {
.dbline 175
; char i=0;
clr R10
rjmp L86
L85:
.dbline 176
; while(InnerCmd[i].cmd){
.dbline 177
; if (strcmp(InnerCmd[i].cmd,cmd)==0) return i;
movw R18,R12
ldi R24,6
mul R24,R10
movw R30,R0
ldi R24,<_InnerCmd
ldi R25,>_InnerCmd
add R30,R24
adc R31,R25
ldd R16,z+0
ldd R17,z+1
rcall _strcmp
cpi R16,0
cpc R16,R17
brne L88
X23:
.dbline 177
mov R16,R10
rjmp L84
L88:
.dbline 178
; i++;
inc R10
.dbline 179
; }
L86:
.dbline 176
ldi R24,6
mul R24,R10
movw R30,R0
ldi R24,<_InnerCmd
ldi R25,>_InnerCmd
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
tst R2
brne L85
tst R3
brne L85
X24:
.dbline 180
; return -1;
ldi R16,255
.dbline -2
L84:
.dbline 0 ; func end
rjmp pop_xgset003C
.dbsym r i 10 c
.dbsym r cmd 12 pc
.dbend
.dbfunc e ParseCmd _ParseCmd fV
; argv -> y+3
; argc -> y+2
; Cmd_Index -> R20
; cmdline -> R10,R11
.even
_ParseCmd::
rcall push_xgset300C
movw R10,R16
sbiw R28,13
.dbline -1
.dbline 183
; }
; void ParseCmd(char *cmdline)
; {
.dbline 186
; signed char argc,Cmd_Index;
; char *argv[5];
; ParseArgs(cmdline,&argc,argv);
movw R24,R28
adiw R24,3
std y+1,R25
std y+0,R24
movw R18,R28
subi R18,254 ; offset = 2
sbci R19,255
movw R16,R10
rcall _ParseArgs
.dbline 187
; if (argc==0) return;
ldd R2,y+2
tst R2
brne L91
X25:
.dbline 187
rjmp L90
L91:
.dbline 188
; Cmd_Index=GetCmdMatch(argv[0]);
ldd R16,y+3
ldd R17,y+4
rcall _GetCmdMatch
mov R20,R16
.dbline 189
; if (Cmd_Index<0){
cpi R16,0
brge L93
X26:
.dbline 189
.dbline 190
; serial_send("unknow command\n");
ldi R16,<L95
ldi R17,>L95
rcall _serial_send
.dbline 191
; return;
rjmp L90
L93:
.dbline 193
; }
; if (InnerCmd[Cmd_Index].proc)
ldi R16,6
mov R17,R20
muls R16,R17
movw R30,R0
ldi R24,<_InnerCmd+4
ldi R25,>_InnerCmd+4
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
tst R2
brne X27
tst R3
breq L96
X27:
.dbline 194
; InnerCmd[Cmd_Index].proc(argc,argv);
movw R18,R28
subi R18,253 ; offset = 3
sbci R19,255
ldd R16,y+2
ldi R24,6
push R16
push R17
mov R16,R24
muls R16,R17
movw R30,R0
pop R17
pop R16
ldi R24,<_InnerCmd+4
ldi R25,>_InnerCmd+4
add R30,R24
adc R31,R25
ldd R26,z+0
ldd R27,z+1
movw R30,R26
rcall xicall
L96:
.dbline -2
L90:
.dbline 0 ; func end
adiw R28,13
rjmp pop_xgset300C
.dbsym l argv 3 A[10:5]pc
.dbsym l argc 2 C
.dbsym r Cmd_Index 20 C
.dbsym r cmdline 10 pc
.dbend
.dbfunc e shellin _shellin fV
; buf -> y+0
.even
_shellin::
sbiw R28,51
.dbline -1
.dbline 197
; }
; void shellin(void)
; {
.dbline 199
; char buf[51];
; if (serial_recv(buf,50)>0){
ldi R18,50
ldi R19,0
movw R16,R28
rcall _serial_recv
cpi R16,0
cpc R16,R17
breq L101
X28:
.dbline 199
.dbline 200
; ParseCmd(buf);
movw R16,R28
rcall _ParseCmd
.dbline 201
; };
L101:
.dbline 201
.dbline -2
L100:
.dbline 0 ; func end
adiw R28,51
ret
.dbsym l buf 0 A[51:51]c
.dbend
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L95:
.blkb 16
.area idata
.byte 'u,'n,'k,'n,'o,'w,32,'c,'o,'m,'m,'a,'n,'d,10,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L65:
.blkb 23
.area idata
.byte 'H,'a,'v,'e,'n,39,'t,32,'t,'h,'i,'s,32,'c,'o,'m
.byte 'm,'a,'n,'d,46,10,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L61:
.blkb 3
.area idata
.byte 58,9,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L23:
.blkb 3
.area idata
.byte 'o,'n,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L12:
.blkb 30
.area idata
.byte 'a,'u,'t,'o,32,'a,'n,'s,'w,'e,'r,32,'t,'h,'e,32
.byte 'r,'e,'m,'o,'t,'e,32,'c,'a,'l,'l,46,10,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L11:
.blkb 11
.area idata
.byte 'a,'u,'t,'o,'a,'n,'s,'w,'e,'r,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L10:
.blkb 28
.area idata
.byte 'r,'e,'a,'d,32,'a,32,'n,'u,'m,'b,'e,'r,32,'f,'r
.byte 'o,'m,32,'r,'e,'m,'o,'t,'e,46,10,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L9:
.blkb 5
.area idata
.byte 'r,'e,'a,'d,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L8:
.blkb 27
.area idata
.byte 'e,'n,'a,'b,'l,'e,32,'o,'r,32,'d,'i,'s,'e,'n,'a
.byte 'b,'l,'e,32,'e,'c,'h,'o,46,10,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L7:
.blkb 5
.area idata
.byte 'e,'c,'h,'o,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L6:
.blkb 24
.area idata
.byte 'c,'a,'n,'c,'e,'l,32,'a,32,'c,'a,'l,'l,32,'p,'r
.byte 'o,'c,'e,'s,'s,46,10,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L5:
.blkb 7
.area idata
.byte 'c,'a,'n,'c,'e,'l,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L4:
.blkb 37
.area idata
.byte 'c,'a,'l,'l,32,'a,32,'t,'e,'l,'p,'h,'o,'n,32,'n
.byte 'u,'m,'b,'e,'r,44,'u,'s,'e,'s,58,'c,'a,'l,'l,32
.byte 49,49,48,10,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L3:
.blkb 5
.area idata
.byte 'c,'a,'l,'l,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L2:
.blkb 27
.area idata
.byte 'D,'e,'s,'p,'l,'a,'y,32,'t,'h,'i,'s,32,'i,'n,'f
.byte 'o,'r,'m,'a,'t,'i,'o,'n,46,10,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
L1:
.blkb 5
.area idata
.byte 'h,'e,'l,'p,0
.area data(ram, con, rel)
.dbfile E:\Shuaihu\AVR\8880\shell.c
; }
.area func_lit
PL_autoanswer: .word `_autoanswer
PL_read: .word `_read
PL_echo: .word `_echo
PL_cancel: .word `_cancel
PL_call: .word `_call
PL_help: .word `_help
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -