📄 main.lst
字号:
__start:
__text_start:
005D E5CF LDI R28,0x5F
005E E0D4 LDI R29,4
005F BFCD OUT 0x3D,R28
0060 BFDE OUT 0x3E,R29
0061 51C0 SUBI R28,0x10
0062 40D0 SBCI R29,0
0063 EA0A LDI R16,0xAA
0064 8308 STD Y+0,R16
0065 2400 CLR R0
0066 EAEA LDI R30,0xAA
0067 E0F0 LDI R31,0
0068 E010 LDI R17,0
0069 3CE8 CPI R30,0xC8
006A 07F1 CPC R31,R17
006B F011 BEQ 0x006E
006C 9201 ST R0,Z+
006D CFFB RJMP 0x0069
006E 8300 STD Z+0,R16
006F E7E0 LDI R30,0x70
0070 E0F0 LDI R31,0
0071 E6A0 LDI R26,0x60
0072 E0B0 LDI R27,0
0073 E010 LDI R17,0
0074 3BEA CPI R30,0xBA
0075 07F1 CPC R31,R17
0076 F021 BEQ 0x007B
0077 95C8 LPM
0078 9631 ADIW R30,1
0079 920D ST R0,X+
007A CFF9 RJMP 0x0074
007B 940E058E CALL _main
_exit:
007D CFFF RJMP _exit
FILE: D:\liliang\can-232\CAN-232\delay.c
(0001) /*-----------------------------------------------------------------------
(0002) 延时函数
(0003) 系统时钟:16M
(0004) -----------------------------------------------------------------------*/
(0005) /*======================================
(0006) 微秒级精确延时函数,晶振16M:
(0007) Delay = 0.0625 *((tt*4-1)+9)微秒
(0008) 其中9包括了调用方的 r16 赋值 1t
(0009) rcall 3t nop 1t ret 4t
(0010) brne指令在当判断条件不成立时是单周期
(0011) 最后一次判断只有1个周期,补一个nop
(0012) 简化计算 = 0.5tt + 1 (us)
(0013) ======================================*/
(0014) void shortdelay(unsigned char tt)
(0015) {
(0016) asm("_L2: subi R16,1"); // 1t
_shortdelay:
tt --> R16
007E 5001 SUBI R16,1
(0017) asm(" nop") ; // 1t
007F 0000 NOP
(0018) asm(" brne _L2"); // 2t/1t
0080 F7E9 BNE 0x007E
(0019) asm(" nop"); // 1t
0081 0000 NOP
(0020) asm(" ret"); // 4t
0082 9508 RET
0083 9508 RET
(0021) }
(0022)
(0023) //#define delay_us() shortdelay(2)
(0024) void delay_us(void) //1us延时函数
(0025) {
(0026) shortdelay(2);
_delay_us:
0084 E002 LDI R16,2
0085 DFF8 RCALL _shortdelay
0086 9508 RET
_delay_nus:
i --> R10
n --> R12
0087 940E06C6 CALL push_gset4x
0089 0168 MOVW R12,R16
(0027) }
(0028)
(0029) void delay_nus(unsigned int n) //N us延时函数
(0030) {
(0031) unsigned int i=0;
008A 24AA CLR R10
008B 24BB CLR R11
(0032) for (i=0;i<n;i++)
008C C004 RJMP 0x0091
(0033) delay_us();
008D DFF6 RCALL _delay_us
008E 01C5 MOVW R24,R10
008F 9601 ADIW R24,1
0090 015C MOVW R10,R24
0091 14AC CP R10,R12
0092 04BD CPC R11,R13
0093 F3C8 BCS 0x008D
0094 940E06BD CALL pop_gset4x
0096 9508 RET
(0034) }
(0035)
(0036) void delay_ms(void) //1ms延时函数
(0037) {
(0038) unsigned int i;
(0039) for (i=0;i<1140;i++);
_delay_ms:
i --> R16
0097 2700 CLR R16
0098 2711 CLR R17
0099 C002 RJMP 0x009C
009A 5F0F SUBI R16,0xFF
009B 4F1F SBCI R17,0xFF
009C 3704 CPI R16,0x74
009D E0E4 LDI R30,4
009E 071E CPC R17,R30
009F F3D0 BCS 0x009A
00A0 9508 RET
_delay_nms:
i --> R10
n --> R12
00A1 940E06C6 CALL push_gset4x
00A3 0168 MOVW R12,R16
(0040) }
(0041)
(0042) void delay_nms(unsigned int n) //N ms延时函数
(0043) {
(0044) unsigned int i=0;
00A4 24AA CLR R10
00A5 24BB CLR R11
(0045) for (i=0;i<n;i++)
00A6 C004 RJMP 0x00AB
(0046) delay_ms();
00A7 DFEF RCALL _delay_ms
00A8 01C5 MOVW R24,R10
00A9 9601 ADIW R24,1
00AA 015C MOVW R10,R24
00AB 14AC CP R10,R12
00AC 04BD CPC R11,R13
00AD F3C8 BCS 0x00A7
00AE 940E06BD CALL pop_gset4x
00B0 9508 RET
FILE: D:\liliang\can-232\CAN-232\rprint.c
(0001) /********************************************************************
(0002) * 版本说明:1.0 *
(0003) * 作者: andylee *
(0004) * 日期: 2006年10月 *
(0005) * 平台: mega16 16M *
(0006) * 说明: 通用的显示驱动功能函数库 *
(0007) ********************************************************************/
(0008) #include "rprint.h"
(0009) #define RPRINTF_FLOAT
(0010) //-----------------------------------------------------------------------------
(0011) #ifdef RPRINTF_COMPLEX
(0012) static unsigned char buf[128];
(0013) #endif
(0014) //-----------------------------------------------------------------------------
(0015) #define pgm_read_byte(char_ptr) *(const char *) char_ptr
(0016) #define READMEMBYTE(a,char_ptr) ((a)?(pgm_read_byte(char_ptr)):(*char_ptr))
(0017) //-----------------------------------------------------------------------------
(0018) static char HexChars[] = "0123456789ABCDEF";
(0019) //const static char HexChars[]="123456789ABCDEF";
(0020)
(0021) // function pointer to single character output routine
(0022) static void (*rputchar)(unsigned char c);
(0023) //-----------------------------------------------------------------------------
(0024)
(0025) //******************************************************************************
(0026) // *** rprintf initialization ***
(0027) //*****************************************************************************
(0028) //=============================================================================
(0029) void rprintfInit(void (*putchar_func)(unsigned char c))
(0030) //=============================================================================
(0031) {
(0032) rputchar = putchar_func;
_rprintfInit:
putchar_func --> R16
00B1 931000C7 STS rputchar+1,R17
00B3 930000C6 STS rputchar,R16
00B5 9508 RET
_rprintfChar:
c --> R10
00B6 940E06C3 CALL push_gset3x
00B8 2EA0 MOV R10,R16
(0033) }
(0034)
(0035) //==============================================================================
(0036) void rprintfChar(unsigned char c)
(0037) //==============================================================================
(0038) {
(0039) // send character
(0040) rputchar(c);
00B9 2D0A MOV R16,R10
00BA 91E000C6 LDS R30,rputchar
00BC 91F000C7 LDS R31,rputchar+1
00BE 940E06CE CALL xicall
00C0 940E06B1 CALL pop_gset3x
00C2 9508 RET
_rprintfStr:
str --> R10
00C3 940E06C3 CALL push_gset3x
00C5 0158 MOVW R10,R16
(0041) }
(0042)
(0043) //=============================================================================
(0044) void rprintfStr(char str[])
(0045) //=============================================================================
(0046) {
(0047) // send a string stored in RAM
(0048) // check to make sure we have a good pointer
(0049) if (!str) return;
00C6 20AA TST R10
00C7 F439 BNE 0x00CF
00C8 20BB TST R11
00C9 F429 BNE 0x00CF
00CA C008 RJMP 0x00D3
(0050)
(0051) // print the string until a null-terminator
(0052) while (*str)
(0053) rprintfChar(*str++);
00CB 01F5 MOVW R30,R10
00CC 9101 LD R16,Z+
00CD 015F MOVW R10,R30
00CE DFE7 RCALL _rprintfChar
00CF 01F5 MOVW R30,R10
00D0 8020 LDD R2,Z+0
00D1 2022 TST R2
00D2 F7C1 BNE 0x00CB
00D3 940E06B1 CALL pop_gset3x
00D5 9508 RET
_rprintfStrLen:
i --> R10
len --> R12
start --> Y+6
str --> R14
00D6 933A ST R19,-Y
00D7 932A ST R18,-Y
00D8 940E06CA CALL push_gset5x
00DA 0178 MOVW R14,R16
00DB 84C8 LDD R12,Y+8
00DC 84D9 LDD R13,Y+9
(0054) }
(0055)
(0056) //=============================================================================
(0057) void rprintfStrLen(char str[], unsigned int start, unsigned int len)
(0058) //=============================================================================
(0059) {
(0060) register int i=0;
00DD 24AA CLR R10
00DE 24BB CLR R11
(0061)
(0062) // check to make sure we have a good pointer
(0063) if (!str) return;
00DF 20EE TST R14
00E0 F419 BNE 0x00E4
00E1 20FF TST R15
00E2 F409 BNE 0x00E4
00E3 C021 RJMP 0x0105
(0064) // spin through characters up to requested start
(0065) // keep going as long as there's no null
(0066) while((i++<start) && (*str++));
00E4 0115 MOVW R2,R10
00E5 01C1 MOVW R24,R2
00E6 9601 ADIW R24,1
00E7 015C MOVW R10,R24
00E8 800E LDD R0,Y+6
00E9 801F LDD R1,Y+7
00EA 1420 CP R2,R0
00EB 0431 CPC R3,R1
00EC F428 BCC 0x00F2
00ED 01F7 MOVW R30,R14
00EE 9021 LD R2,Z+
00EF 017F MOVW R14,R30
00F0 2022 TST R2
00F1 F791 BNE 0x00E4
(0067)
(0068) // then print exactly len characters
(0069) for(i=0; i<len; i++)
00F2 24AA CLR R10
00F3 24BB CLR R11
00F4 C00D RJMP 0x0102
(0070) {
(0071) // print data out of the string as long as we haven't reached a null yet
(0072) // at the null, start printing spaces
(0073) if(*str)
00F5 01F7 MOVW R30,R14
00F6 8020 LDD R2,Z+0
00F7 2022 TST R2
00F8 F021 BEQ 0x00FD
(0074) rprintfChar(*str++);
00F9 9101 LD R16,Z+
00FA 017F MOVW R14,R30
00FB DFBA RCALL _rprintfChar
00FC C002 RJMP 0x00FF
(0075) else
(0076) rprintfChar(' ');
00FD E200 LDI R16,0x20
00FE DFB7 RCALL _rprintfChar
00FF 01C5 MOVW R24,R10
0100 9601 ADIW R24,1
0101 015C MOVW R10,R24
0102 14AC CP R10,R12
0103 04BD CPC R11,R13
0104 F380 BCS 0x00F5
0105 940E06C0 CALL pop_gset5x
0107 9622 ADIW R28,2
0108 9508 RET
_rprintfProgStr:
c --> R10
str --> R12
0109 940E06C6 CALL push_gset4x
010B 0168 MOVW R12,R16
(0077) }
(0078)
(0079) }
(0080)
(0081) //*****************************************************************************
(0082) // *** rprintfProgStr ***
(0083) // prints a null-terminated string stored in program ROM
(0084) //*****************************************************************************
(0085) //=============================================================================
(0086) void rprintfProgStr(const char *str)
(0087) //=============================================================================
(0088) {
(0089) // print a string stored in program memory
(0090) register char c;
(0091)
(0092) // check to make sure we have a good pointer
(0093) if (!str) return;
010C 20CC TST R12
010D F429 BNE 0x0113
010E 20DD TST R13
010F F419 BNE 0x0113
0110 C00B RJMP 0x011C
(0094)
(0095) // print the string until the null-terminator
(0096) while((c =*str++))
(0097) rprintfChar(c);
0111 2D0A MOV R16,R10
0112 DFA3 RCALL _rprintfChar
0113 0116 MOVW R2,R12
0114 01C1 MOVW R24,R2
0115 9601 ADIW R24,1
0116 016C MOVW R12,R24
0117 01F1 MOVW R30,R2
0118 9024 LPM R2,0(Z)
0119 2CA2 MOV R10,R2
011A 20AA TST R10
011B F7A9 BNE 0x0111
011C 940E06BD CALL pop_gset4x
011E 9508 RET
(0098) }
(0099)
(0100) //******************************************************************************
(0101) // *** rprintfCRLF ***
(0102) // prints carriage return and line feed
(0103) //******************************************************************************
(0104) //==============================================================================
(0105) void rprintfCRLF(void)
(0106) //==============================================================================
(0107) {
(0108) // print CR/LF
(0109) rprintfChar('\r');
_rprintfCRLF:
011F E00D LDI R16,0xD
0120 DF95 RCALL _rprintfChar
(0110) rprintfChar('\n');
0121 E00A LDI R16,0xA
0122 DF93 RCALL _rprintfChar
0123 9508 RET
_rprintfu04:
data --> R10
0124 940E06C3 CALL push_gset3x
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -