用了iccavr 和 atmel studio 写了同样的代码编译..
// 595 opera
tion
#define PORT_595_CLK PORTB
#define PORT_595_DAT PORTA
#define DAT_595 0
#define SHCLK 0
#define STCLK 1
#define CLR_595_ST() PORT_595_CLK &= ~(1<<STCLK)
#define SET_595_ST() PORT_595_CLK |= (1<<STCLK)
#define CLR_595_DAT() PORT_595_DAT &= ~(1<<DAT_595)
#define SET_595_DAT() PORT_595_DAT |= (1<<DAT_595)
#define CLR_595_SH() PORT_595_CLK &= ~(1<<SHCLK)
#define SET_595_SH() PORT_595_CLK |= (1<<SHCLK)
#define SEND_TO_595(word) do
{
CLR_595_ST();
for(char i=0 ; i<8 ; i++)
{
CLR_595_SH();
if ((word) & (1<<(7-i)))
{
SET_595_DAT();
}
else
{
CLR_595_DAT();
}
SET_595_SH();
}
SET_595_ST();
} while (0)
//segment LED operation
#define SEGLED_CLR() PORTD |= 0xf0
#define SEGLED_SET(i) PORTD &= ~(1<<(7-i))
#define SEGLED_CODE(word) SEND_TO_595(word)
//display data
unsigned char led_code[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71} ;
unsigned char dis_buff[] = {0,0,0,0};
unsigned char clock[] = {0,0};
ISR(TIMER0_COMP_vect)
{
static unsigned char disIndex = 0;
unsigned char dis_data;
dis_data = led_code[dis_buff[disIndex]];
SEGLED_CLR();
SEGLED_CODE(dis_data);
SEGLED_SET(disIndex);
++disIndex;
if (disIndex >4)
{
disIndex = 0;
}
}
在iccavr上面只是把那个ISR改了..
结果iccavr是对的..
as确实错的.. iccavr
附图是as编译结果的运行..
iccavr是实现动态扫描
二楼附上as编译出来的汇编
-
as编译结果运行..
00000002 JMP 0x00000047 Jump
00000004 JMP 0x00000047 Jump
00000006 JMP 0x00000047 Jump
00000008 JMP 0x00000047 Jump
0000000A JMP 0x00000047 Jump
0000000C JMP 0x00000047 Jump
0000000E JMP 0x00000047 Jump
00000010 JMP 0x00000047 Jump
00000012 JMP 0x00000047 Jump
00000014 JMP 0x00000047 Jump
00000016 JMP 0x00000047 Jump
00000018 JMP 0x00000047 Jump
0000001A JMP 0x00000047 Jump
0000001C JMP 0x00000047 Jump
0000001E JMP 0x00000047 Jump
00000020 JMP 0x00000047 Jump
00000022 JMP 0x00000047 Jump
00000024 JMP 0x00000047 Jump
00000026 JMP 0x00000049 Jump
00000028 JMP 0x00000047 Jump
0000002A CLR R1 Clear Register
0000002B OUT 0x3F,R1 Out to I/O location
0000002C LDI R28,0x5F Load immediate
0000002D LDI R29,0x04 Load immediate
0000002E OUT 0x3E,R29 Out to I/O location
0000002F OUT 0x3D,R28 Out to I/O location
00000030 LDI R17,0x00 Load immediate
00000031 LDI R26,0x60 Load immediate
00000032 LDI R27,0x00 Load immediate
--- No source file -------------------------------------------------------------
00000033 LDI R30,0x68 Load immediate
00000034 LDI R31,0x01 Load immediate
00000035 RJMP PC+0x0003 Relative jump
00000036 LPM R0,Z+ Load program memory and postincrement
00000037 ST X+,R0 Store indirect and postincrement
00000038 CPI R26,0x70 Compare with immediate
00000039 CPC R27,R17 Compare with carry
0000003A BRNE PC-0x04 Branch if not equal
0000003B LDI R18,0x00 Load immediate
0000003C LDI R26,0x70 Load immediate
0000003D LDI R27,0x00 Load immediate
0000003E RJMP PC+0x0002 Relative jump
0000003F ST X+,R1 Store indirect and postincrement
00000040 CPI R26,0x77 Compare with immediate
00000041 CPC R27,R18 Compare with carry
00000042 BRNE PC-0x03 Branch if not equal
00000043 CALL 0x0000009F Call subroutine
00000045 JMP 0x000000B2 Jump
00000047 JMP 0x00000000 Jump
00000049 PUSH R1 Push register on stack
0000004A PUSH R0 Push register on stack
0000004B IN R0,0x3F In from I/O location
0000004C PUSH R0 Push register on stack
0000004D CLR R1 Clear Register
0000004E PUSH R18 Push register on stack
0000004F PUSH R19 Push register on stack
00000050 PUSH R20 Push register on stack
00000051 PUSH R21 Push register on stack
00000052 PUSH R24 Push register on stack
00000053 PUSH R25 Push register on stack
--- No source file -------------------------------------------------------------
00000054 PUSH R30 Push register on stack
00000055 PUSH R31 Push register on stack
00000056 LDS R30,0x0076 Load direct from data space
00000058 LDI R31,0x00 Load immediate
00000059 SUBI R30,0x8E Subtract immediate
0000005A SBCI R31,0xFF Subtract immediate with carry
0000005B LDD R30,Z+0 Load indirect with displacement
0000005C LDI R31,0x00 Load immediate
0000005D SUBI R30,0xA0 Subtract immediate
0000005E SBCI R31,0xFF Subtract immediate with carry
0000005F LDD R18,Z+0 Load indirect with displacement
00000060 IN R24,0x12 In from I/O location
00000061 ORI R24,0xF0 Logical OR with immediate
00000062 OUT 0x12,R24 Out to I/O location
00000063 CBI 0x18,1 Clear bit in I/O register
00000064 LDI R24,0x07 Load immediate
00000065 LDI R25,0x00 Load immediate
00000066 LDI R19,0x00 Load immediate
00000067 CBI 0x18,0 Clear bit in I/O register
00000068 MOVW R20,R18 Copy register pair
00000069 MOV R0,R24 Copy register
0000006A RJMP PC+0x0003 Relative jump
0000006B ASR R21 Arithmetic shift right
0000006C ROR R20 Rotate right through carry
0000006D DEC R0 Decrement
0000006E BRPL PC-0x03 Branch if plus
0000006F SBRS R20,0 Skip if bit in register set
00000070 RJMP PC+0x0003 Relative jump
00000071 SBI 0x1B,0 Set bit in I/O register
00000072 RJMP PC+0x0002 Relative jump
--- No source file -------------------------------------------------------------
00000073 CBI 0x1B,0 Clear bit in I/O register
00000074 SBI 0x18,0 Set bit in I/O register
00000075 SBIW R24,0x01 Subtract immediate from word
00000076 BRCC PC-0x0F Branch if carry cleared
00000077 SBI 0x18,1 Set bit in I/O register
00000078 IN R21,0x12 In from I/O location
00000079 LDS R20,0x0076 Load direct from data space
0000007B LDI R18,0x07 Load immediate
0000007C LDI R19,0x00 Load immediate
0000007D SUB R18,R20 Subtract without carry
0000007E SBC R19,R1 Subtract with carry
0000007F LDI R24,0x01 Load immediate
00000080 LDI R25,0x00 Load immediate
00000081 MOV R0,R18 Copy register
00000082 RJMP PC+0x0002 Relative jump
00000083 LSL R24 Logical Shift Left
00000084 DEC R0 Decrement
00000085 BRPL PC-0x02 Branch if plus
--- No source file -------------------------------------------------------------
00000086 COM R24 One's complement
00000087 AND R24,R21 Logical AND
00000088 OUT 0x12,R24 Out to I/O location
00000089 MOV R24,R20 Copy register
0000008A SUBI R24,0xFF Subtract immediate
0000008B CPI R24,0x05 Compare with immediate
0000008C BRCC PC+0x04 Branch if carry cleared
0000008D STS 0x0076,R24 Store direct to data space
0000008F RJMP PC+0x0003 Relative jump
00000090 STS 0x0076,R1 Store direct to data space
00000092 POP R31 Pop register from stack
00000093 POP R30 Pop register from stack
00000094 POP R25 Pop register from stack
00000095 POP R24 Pop register from stack
00000096 POP R21 Pop register from stack
00000097 POP R20 Pop register from stack
00000098 POP R19 Pop register from stack
00000099 POP R18 Pop register from stack
--- No source file -------------------------------------------------------------
0000009A POP R0 Pop register from stack
0000009B OUT 0x3F,R0 Out to I/O location
0000009C POP R0 Pop register from stack
0000009D POP R1 Pop register from stack
0000009E RETI Interrupt return
0000009F SBI 0x1A,0 Set bit in I/O register
000000A0 CBI 0x1A,7 Clear bit in I/O register
000000A1 IN R24,0x17 In from I/O location
000000A2 ORI R24,0x03 Logical OR with immediate
000000A3 OUT 0x17,R24 Out to I/O location
000000A4 IN R24,0x11 In from I/O location
000000A5 ORI R24,0xF0 Logical OR with immediate
000000A6 OUT 0x11,R24 Out to I/O location
000000A7 CBI 0x11,3 Clear bit in I/O register
000000A8 SBI 0x12,3 Set bit in I/O register
000000A9 LDI R24,0x73 Load immediate
000000AA OUT 0x3C,R24 Out to I/O location
000000AB LDI R24,0x0B Load immediate
--- No source file -------------------------------------------------------------
000000AC OUT 0x33,R24 Out to I/O location
000000AD IN R24,0x39 In from I/O location
000000AE ORI R24,0x02 Logical OR with immediate
000000AF OUT 0x39,R24 Out to I/O location
000000B0 SEI Global Interrupt Enable
000000B1 RJMP PC-0x0000 Relative jump
000000B2 CLI Global Interrupt Disable
000000B3 RJMP PC-0x0000 Relative jump
000000B4 CPC R3,R31 Compare with carry
000000B5 SBCI R21,0xFB Subtract immediate with carry
000000B6 ORI R22,0xD6 Logical OR with immediate
000000B7 CPC R23,R29 Compare with carry
000000B8 ORI R23,0xFF Logical OR with immediate
000000B9 ANDI R23,0xC7 Logical AND with immediate
000000BA SUBI R19,0xE9 Subtract immediate
000000BB ANDI R23,0x19 Logical AND with immediate
一周热门 更多>