📄 main.s
字号:
.dbline -2
L24:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r status 20 c
.dbsym r i 22 c
.dbsym r j 10 c
.dbsym r len 10 c
.dbsym r cmd 20 c
.dbend
.dbfunc e mStopIfError _mStopIfError fV
; led -> R20
; iError -> R20
.even
_mStopIfError::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 199
; }
;
;
;
; /* 检查操作状态,如果错误则显示错误代码并停机 */
; void mStopIfError( unsigned char iError )
; {
.dbline 201
; unsigned char led;
; if ( iError == ERR_SUCCESS ) return; /* 操作成功 */
tst R20
brne L47
.dbline 201
xjmp L46
L47:
.dbline 202
; led=0;
clr R20
xjmp L50
L49:
.dbline 203
.dbline 205
ldi R16,100
xcall _mDelaymS
.dbline 207
L50:
.dbline 203
xjmp L49
X1:
.dbline -2
L46:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r led 20 c
.dbsym r iError 20 c
.dbend
.dbfunc e main _main fV
; oprCode -> R20
; i -> R20
.even
_main::
.dbline -1
.dbline 216
; while ( 1 ) {
; //LED_OUT = led&1; /* LED闪烁 */
; mDelaymS( 100 );
; //led^=1;
; }
; }
;
;
; /*
; 主程序
;
; */
; void main( )
; {
.dbline 220
; unsigned char i;
; unsigned char oprCode; // opr code
;
; initPort();
xcall _initPort
.dbline 221
; mDelaymS( 500 ); /* 延时500毫秒,PB375模块上电后需要500毫秒左右的复位时间 */
ldi R16,244
xcall _mDelaymS
.dbline 222
clr R20
xjmp L56
L53:
.dbline 222
; for ( i = 0; i < 5; i ++ ) {
.dbline 223
; mDelaymS( 100 );
ldi R16,100
xcall _mDelaymS
.dbline 224
; if ( ExecCommand( CMD_DiskReady, 0 ) == ERR_SUCCESS )
clr R18
ldi R16,113
xcall _ExecCommand
tst R16
brne L57
.dbline 225
; break; /* 查询磁盘是否准备好 */
xjmp L55
L57:
.dbline 226
L54:
.dbline 222
inc R20
L56:
.dbline 222
cpi R20,5
brlo L53
L55:
.dbline 229
; }
;
; //各种操作的代码
; oprCode = 5;
ldi R20,5
.dbline 230
; switch(oprCode)
clr R21
cpi R20,1
ldi R30,0
cpc R21,R30
breq L62
cpi R20,2
ldi R30,0
cpc R21,R30
breq L67
cpi R20,3
ldi R30,0
cpc R21,R30
brne X4
xjmp L80
X4:
cpi R20,5
ldi R30,0
cpc R21,R30
brne X5
xjmp L86
X5:
cpi R20,6
ldi R30,0
cpc R21,R30
brne X6
xjmp L95
X6:
xjmp L100
X2:
.dbline 231
; {
L62:
.dbline 233
; case 1: //删除文件
; sendBuff[0] = 92;
ldi R24,92
sts _sendBuff,R24
.dbline 234
; strcpy(sendBuff+1,"1.DAT");
ldi R18,<L64
ldi R19,>L64
ldi R16,<_sendBuff+1
ldi R17,>_sendBuff+1
xcall _strcpy
.dbline 235
; if ( ExecCommand( CMD_FileErase, 7 ) == ERR_SUCCESS )
ldi R18,7
ldi R16,102
xcall _ExecCommand
tst R16
breq X7
xjmp L100
X7:
.dbline 236
; {
.dbline 238
; //操作成功
; }
.dbline 240
; else
; {
.dbline 242
; //操作失败
; }
.dbline 243
; break;
xjmp L100
L67:
.dbline 245
; case 2://写入数据到文件
; sendBuff[0] = 92;
ldi R24,92
sts _sendBuff,R24
.dbline 246
; strcpy(sendBuff+1,"1.DAT");
ldi R18,<L64
ldi R19,>L64
ldi R16,<_sendBuff+1
ldi R17,>_sendBuff+1
xcall _strcpy
.dbline 247
; if ( ExecCommand( CMD_FileOpen, 7 ) == ERR_SUCCESS )
ldi R18,7
ldi R16,100
xcall _ExecCommand
tst R16
breq X8
xjmp L100
X8:
.dbline 248
; {
.dbline 250
; //加一个字节定位
; sendBuff[0] = 0;
clr R2
sts _sendBuff,R2
.dbline 251
; sendBuff[1] = 0;
sts _sendBuff+1,R2
.dbline 252
; sendBuff[2] = 0;
sts _sendBuff+2,R2
.dbline 253
; sendBuff[3] = 0;
sts _sendBuff+3,R2
.dbline 255
;
; if ( ExecCommand( CMD_ByteLocate, 4 ) == ERR_SUCCESS )
ldi R18,4
ldi R16,122
xcall _ExecCommand
tst R16
breq X9
xjmp L100
X9:
.dbline 256
; {
.dbline 257
; sendBuff[0] = 19;//写入文件字节大小
ldi R24,19
sts _sendBuff,R24
.dbline 258
; strcpy(sendBuff+1,"111111111111111111111111111111111111");
ldi R18,<L77
ldi R19,>L77
ldi R16,<_sendBuff+1
ldi R17,>_sendBuff+1
xcall _strcpy
.dbline 259
; if ( ExecCommand( CMD_ByteWrite, 20 ) == ERR_SUCCESS )
ldi R18,20
ldi R16,124
xcall _ExecCommand
tst R16
breq X10
xjmp L100
X10:
.dbline 260
; ExecCommand( CMD_FileClose, 1 );
ldi R18,1
ldi R16,103
xcall _ExecCommand
.dbline 261
; }
.dbline 263
;
; }
.dbline 265
; else
; {
.dbline 267
; //操作失败
; }
.dbline 268
; break;
xjmp L100
L80:
.dbline 270
; case 3://读取文件
; sendBuff[0] = 92;
ldi R24,92
sts _sendBuff,R24
.dbline 271
; strcpy(sendBuff+1,"1.DAT");
ldi R18,<L64
ldi R19,>L64
ldi R16,<_sendBuff+1
ldi R17,>_sendBuff+1
xcall _strcpy
.dbline 272
; if ( ExecCommand( CMD_FileOpen, 11 ) == ERR_SUCCESS )
ldi R18,11
ldi R16,100
xcall _ExecCommand
tst R16
breq X11
xjmp L100
X11:
.dbline 273
; {
.dbline 274
; sendBuff[0] = 11;//读取的字节数量
ldi R24,11
sts _sendBuff,R24
.dbline 275
; if (ExecCommand( CMD_ByteRead, 1 ) == ERR_SUCCESS )
ldi R18,1
ldi R16,123
xcall _ExecCommand
tst R16
brne L100
.dbline 276
; ExecCommand( CMD_FileClose, 1 );//读取数据保持在recBuf[]
ldi R18,1
ldi R16,103
xcall _ExecCommand
.dbline 278
;
; }
.dbline 280
; else
; {
.dbline 282
; //操作失败
; }
.dbline 283
; break;
xjmp L100
L86:
.dbline 285
; case 5://创建文件
; sendBuff[0] = 92;
ldi R24,92
sts _sendBuff,R24
.dbline 286
; strcpy(sendBuff+1,"12345.DAT");
ldi R18,<L88
ldi R19,>L88
ldi R16,<_sendBuff+1
ldi R17,>_sendBuff+1
xcall _strcpy
.dbline 287
; if ( ExecCommand( CMD_FileCreate, 11 ) == ERR_SUCCESS )
ldi R18,11
ldi R16,101
xcall _ExecCommand
tst R16
brne L100
.dbline 288
; {
.dbline 289
; sendBuff[0] = 19;//写入文件字节大小
ldi R24,19
sts _sendBuff,R24
.dbline 290
; strcpy(sendBuff+1,"shenzhen diwuyuansu ");
ldi R18,<L92
ldi R19,>L92
ldi R16,<_sendBuff+1
ldi R17,>_sendBuff+1
xcall _strcpy
.dbline 291
; if ( ExecCommand( CMD_ByteWrite, 20 ) == ERR_SUCCESS )
ldi R18,20
ldi R16,124
xcall _ExecCommand
tst R16
brne L100
.dbline 292
; ExecCommand( CMD_FileClose, 1 ); //操作成功
ldi R18,1
ldi R16,103
xcall _ExecCommand
.dbline 293
; }
.dbline 295
; else
; {
.dbline 297
; //操作失败
; }
.dbline 298
; break;
xjmp L100
L95:
.dbline 300
; case 6://写入文件
; sendBuff[0] = 92;
ldi R24,92
sts _sendBuff,R24
.dbline 301
; strcpy(sendBuff+1,"1.DAT");
ldi R18,<L64
ldi R19,>L64
ldi R16,<_sendBuff+1
ldi R17,>_sendBuff+1
xcall _strcpy
.dbline 302
; if ( ExecCommand( CMD_FileErase, 7 ) == ERR_SUCCESS )
ldi R18,7
ldi R16,102
xcall _ExecCommand
tst R16
brne L100
.dbline 303
; {
.dbline 305
; //操作成功
; }
.dbline 307
; else
; {
.dbline 309
; //操作失败
; }
.dbline 310
; break;
.dbline 311
; default :break;
L99:
.dbline 314
.dbline 316
L100:
.dbline 313
xjmp L99
X3:
.dbline -2
L52:
.dbline 0 ; func end
ret
.dbsym r oprCode 20 c
.dbsym r i 20 c
.dbend
.area bss(ram, con, rel)
.dbfile E:\电子项目\北极熊模块\例程\AVR\main.c
_recBuff::
.blkb 128
.dbsym e recBuff _recBuff A[128:128]c
_sendBuff::
.blkb 128
.dbsym e sendBuff _sendBuff A[128:128]c
.area data(ram, con, rel)
.dbfile E:\电子项目\北极熊模块\例程\AVR\main.c
L92:
.blkb 21
.area idata
.byte 's,'h,'e,'n,'z,'h,'e,'n,32,'d,'i,'w,'u,'y,'u,'a
.byte 'n,'s,'u,32,0
.area data(ram, con, rel)
.dbfile E:\电子项目\北极熊模块\例程\AVR\main.c
L88:
.blkb 10
.area idata
.byte 49,50,51,52,53,46,'D,'A,'T,0
.area data(ram, con, rel)
.dbfile E:\电子项目\北极熊模块\例程\AVR\main.c
L77:
.blkb 37
.area idata
.byte 49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49
.byte 49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49
.byte 49,49,49,49,0
.area data(ram, con, rel)
.dbfile E:\电子项目\北极熊模块\例程\AVR\main.c
L64:
.blkb 6
.area idata
.byte 49,46,'D,'A,'T,0
.area data(ram, con, rel)
.dbfile E:\电子项目\北极熊模块\例程\AVR\main.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -