⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.s

📁 u-blox的GPS模块LEA-5x,三本例子为ATMEGA1280对他的操作的程序
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module debug.c
	.area text(rom, con, rel)
	.dbfile E:\item\GPS-1280\debug.c
	.area lit(rom, con, rel)
_char_buf::
	.byte 48,49
	.byte 50,51
	.byte 52,53
	.byte 54,55
	.byte 56,57
	.byte 'A,'B
	.byte 'C,'D
	.byte 'E,'F
	.dbsym e char_buf _char_buf A[16:16]kc
	.area text(rom, con, rel)
	.dbfile E:\item\GPS-1280\debug.c
	.dbfunc e debug_init _debug_init fV
	.even
_debug_init::
	.dbline -1
	.dbline 14
; #include <string.h>
; #include "uart3.h"
; 
; #define DEBUG
; 
; const unsigned char char_buf[]=
; {
;   '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
; };
; /*************************************************
; 
; *************************************************/
; void debug_init(void)
; {
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e debug_send_char _debug_send_char fV
;             ch -> R10
	.even
_debug_send_char::
	st -y,R10
	mov R10,R16
	.dbline -1
	.dbline 21
; 
; }
; /*************************************************
; 
; *************************************************/
; void debug_send_char(unsigned char ch)
; {
	.dbline 22
;   uart3_send_char(ch);
	mov R16,R10
	xcall _uart3_send_char
	.dbline -2
L2:
	.dbline 0 ; func end
	ld R10,y+
	ret
	.dbsym r ch 10 c
	.dbend
	.dbfunc e debug_send_chars _debug_send_chars fV
;              i -> R20,R21
;            len -> R10,R11
;             ch -> R12,R13
	.even
_debug_send_chars::
	xcall push_xgset303C
	movw R10,R18
	movw R12,R16
	.dbline -1
	.dbline 28
; }
; /*************************************************
; 
; *************************************************/
; void debug_send_chars(unsigned char *ch,unsigned int len)
; {
	.dbline 30
;   unsigned int i;
;   for(i=0;i<len;i++)
	clr R20
	clr R21
	xjmp L7
L4:
	.dbline 31
;   {
	.dbline 32
;     uart3_send_char(*(ch+i));
	movw R30,R20
	add R30,R12
	adc R31,R13
	ldd R16,z+0
	xcall _uart3_send_char
	.dbline 33
;   }
L5:
	.dbline 30
	subi R20,255  ; offset = 1
	sbci R21,255
L7:
	.dbline 30
	cp R20,R10
	cpc R21,R11
	brlo L4
X0:
	.dbline -2
L3:
	.dbline 0 ; func end
	xjmp pop_xgset303C
	.dbsym r i 20 i
	.dbsym r len 10 i
	.dbsym r ch 12 pc
	.dbend
	.dbfunc e debug_send_string _debug_send_string fV
;            len -> R12,R13
;            str -> R10,R11
	.even
_debug_send_string::
	xcall push_xgset003C
	movw R12,R18
	movw R10,R16
	.dbline -1
	.dbline 39
; }
; /*************************************************
; 
; *************************************************/
; void debug_send_string(char *str,unsigned int len)
; {
	.dbline 40
;   uart3_data_send(str,len);
	movw R18,R12
	movw R16,R10
	xcall _uart3_data_send
	.dbline -2
L8:
	.dbline 0 ; func end
	xjmp pop_xgset003C
	.dbsym r len 12 i
	.dbsym r str 10 pc
	.dbend
	.dbfunc e debug_str_without_n _debug_str_without_n fV
;       debugstr -> R10,R11
	.even
_debug_str_without_n::
	st -y,R10
	st -y,R11
	movw R10,R16
	.dbline -1
	.dbline 46
; }
; /*************************************************
; *输完字符串后不自动换行
; *************************************************/
; void debug_str_without_n(char *debugstr)
; {
	.dbline 48
; #ifdef DEBUG
;    debug_send_string(debugstr,strlen(debugstr));
	movw R16,R10
	xcall _strlen
	movw R18,R16
	movw R16,R10
	xcall _debug_send_string
	.dbline -2
L9:
	.dbline 0 ; func end
	ld R11,y+
	ld R10,y+
	ret
	.dbsym r debugstr 10 pc
	.dbend
	.dbfunc e debug_str _debug_str fV
;       debugstr -> R10,R11
	.even
_debug_str::
	st -y,R10
	st -y,R11
	movw R10,R16
	.dbline -1
	.dbline 57
; #else
; 
; #endif
; }
; /*************************************************
; *输完字符串后自动换行
; *************************************************/
; void debug_str(char *debugstr)
; {
	.dbline 59
; #ifdef DEBUG
;    debug_send_string(debugstr,strlen(debugstr));
	movw R16,R10
	xcall _strlen
	movw R18,R16
	movw R16,R10
	xcall _debug_send_string
	.dbline 60
;    debug_send_string("\n",1);
	ldi R18,1
	ldi R19,0
	ldi R16,<L11
	ldi R17,>L11
	xcall _debug_send_string
	.dbline -2
L10:
	.dbline 0 ; func end
	ld R11,y+
	ld R10,y+
	ret
	.dbsym r debugstr 10 pc
	.dbend
	.dbfunc e debug_uchars _debug_uchars fV
;            len -> R12,R13
;       debugstr -> R10,R11
	.even
_debug_uchars::
	xcall push_xgset003C
	movw R12,R18
	movw R10,R16
	.dbline -1
	.dbline 69
; #else
; 
; #endif
; }
; /*************************************************
; 
; *************************************************/
; void debug_uchars(unsigned char* debugstr,unsigned int len)
; {
	.dbline 71
; #ifdef DEBUG
;    debug_send_chars(debugstr,len);
	movw R18,R12
	movw R16,R10
	xcall _debug_send_chars
	.dbline 72
;    debug_send_string("\n",1);
	ldi R18,1
	ldi R19,0
	ldi R16,<L11
	ldi R17,>L11
	xcall _debug_send_string
	.dbline -2
L12:
	.dbline 0 ; func end
	xjmp pop_xgset003C
	.dbsym r len 12 i
	.dbsym r debugstr 10 pc
	.dbend
	.dbfunc e debug_uchars_without_n _debug_uchars_without_n fV
;            len -> R12,R13
;       debugstr -> R10,R11
	.even
_debug_uchars_without_n::
	xcall push_xgset003C
	movw R12,R18
	movw R10,R16
	.dbline -1
	.dbline 81
; #else
; 
; #endif
; }
; /*************************************************
; 
; *************************************************/
; void debug_uchars_without_n(unsigned char* debugstr,unsigned int len)
; {
	.dbline 83
; #ifdef DEBUG
;    debug_send_chars(debugstr,len);
	movw R18,R12
	movw R16,R10
	xcall _debug_send_chars
	.dbline -2
L13:
	.dbline 0 ; func end
	xjmp pop_xgset003C
	.dbsym r len 12 i
	.dbsym r debugstr 10 pc
	.dbend
	.dbfunc s dtoc _dtoc fc
;              d -> R16
	.even
_dtoc:
	.dbline -1
	.dbline 92
; #else
; 
; #endif
; }
; /*************************************************
; 
; *************************************************/
; static unsigned char dtoc(unsigned char d)
; {
	.dbline 94
; #ifdef DEBUG
;     if(d<=9)
	ldi R24,9
	cp R24,R16
	brlo L15
X1:
	.dbline 95
;             return(d+0x30);
	subi R16,208    ; addi 48
	xjmp L14
L15:
	.dbline 97
;     else
;             return(d+0x37);
	subi R16,201    ; addi 55
	.dbline -2
L14:
	.dbline 0 ; func end
	ret
	.dbsym r d 16 c
	.dbend
	.dbfunc e debug_num_uchar _debug_num_uchar fV
;   debug_string -> y+0
;              i -> R20,R21
;           cBuf -> R10
;              c -> R12
	.even
_debug_num_uchar::
	xcall push_xgsetF0FC
	mov R12,R16
	sbiw R28,5
	.dbline -1
	.dbline 104
; #endif
; }
; /*************************************************
; 
; *************************************************/
; void debug_num_uchar(unsigned char c)
; {
	.dbline 108
; #ifdef DEBUG
;   unsigned char debug_string[5];
;   unsigned char cBuf;
;   unsigned int i=0;
	clr R20
	clr R21
	.dbline 110
; 
;   cBuf=(c%1000)/100;
	ldi R18,1000
	ldi R19,3
	mov R16,R12
	clr R17
	xcall mod16s
	ldi R18,100
	ldi R19,0
	xcall div16s
	.dbline 111
;   debug_string[i++]=dtoc(cBuf);
	movw R2,R20
	subi R20,255  ; offset = 1
	sbci R21,255
	push R2
	push R3
	xcall _dtoc
	pop R3
	pop R2
	movw R24,R28
	movw R30,R2
	add R30,R24
	adc R31,R25
	std z+0,R16
	.dbline 112
;   cBuf=(c%100)/10;
	ldi R17,100
	mov R16,R12
	xcall mod8u
	ldi R17,10
	xcall div8u
	.dbline 113
;   debug_string[i++]=dtoc(cBuf);
	movw R22,R20
	subi R20,255  ; offset = 1
	sbci R21,255
	xcall _dtoc
	mov R14,R16
	movw R24,R28
	movw R30,R22
	add R30,R24
	adc R31,R25
	std z+0,R14
	.dbline 114
;   cBuf=c%10;
	ldi R17,10
	mov R16,R12
	xcall mod8u
	.dbline 115
;   debug_string[i++]=dtoc(cBuf);
	movw R22,R20
	subi R20,255  ; offset = 1
	sbci R21,255
	xcall _dtoc
	mov R10,R16
	movw R24,R28
	movw R30,R22
	add R30,R24
	adc R31,R25
	std z+0,R10
	.dbline 117
; 
;   debug_send_chars(debug_string,i);
	movw R18,R20
	movw R16,R28
	xcall _debug_send_chars
	.dbline 118
;   debug_send_string("\n",1);
	ldi R18,1
	ldi R19,0
	ldi R16,<L11
	ldi R17,>L11
	xcall _debug_send_string
	.dbline -2
L17:
	.dbline 0 ; func end
	adiw R28,5
	xjmp pop_xgsetF0FC
	.dbsym l debug_string 0 A[5:5]c
	.dbsym r i 20 i
	.dbsym r cBuf 10 c
	.dbsym r c 12 c
	.dbend
	.dbfunc e debug_num_uint _debug_num_uint fV
;   debug_string -> y+0
;              i -> R20,R21
;           cBuf -> R10
;           lBuf -> R12,R13
	.even
_debug_num_uint::
	xcall push_xgsetF0FC
	movw R12,R16
	sbiw R28,10
	.dbline -1
	.dbline 127
; #else
;     c=0;
; #endif
; }
; /*************************************************
; 
; *************************************************/
; void debug_num_uint(unsigned int lBuf)
; {
	.dbline 131
; #ifdef DEBUG
;   unsigned char debug_string[10];
;   unsigned char cBuf;
;   unsigned int i=0;
	clr R20
	clr R21
	.dbline 133
; 
;   cBuf=(lBuf%100000)/10000;
	ldi R24,160
	ldi R25,134
	ldi R26,1
	ldi R27,0
	movw R16,R12
	movw R18,R14
	clr R18
	clr R19
	st -y,R27
	st -y,R26
	st -y,R25
	st -y,R24
	xcall mod32s
	ldi R24,16
	ldi R25,39
	ldi R26,0
	ldi R27,0
	st -y,R27
	st -y,R26
	st -y,R25
	st -y,R24
	xcall div32s
	.dbline 134
;   debug_string[i++]=dtoc(cBuf);
	movw R2,R20
	subi R20,255  ; offset = 1
	sbci R21,255
	push R2
	push R3
	xcall _dtoc
	pop R3
	pop R2
	movw R24,R28
	movw R30,R2
	add R30,R24
	adc R31,R25
	std z+0,R16
	.dbline 135
;   cBuf=(lBuf%10000)/1000;
	ldi R18,10000
	ldi R19,39
	movw R16,R12
	xcall mod16u
	ldi R18,1000
	ldi R19,3
	xcall div16u
	.dbline 136
;   debug_string[i++]=dtoc(cBuf);
	movw R22,R20
	subi R20,255  ; offset = 1
	sbci R21,255
	xcall _dtoc
	mov R14,R16
	movw R24,R28
	movw R30,R22
	add R30,R24
	adc R31,R25
	std z+0,R14
	.dbline 137
;   cBuf=(lBuf%1000)/100;
	ldi R18,1000

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -