我想测试下在任务切换时 保存现场的操作我初始的想法很简单 分为两种模式
一种是子程序调用 一种是直接中断里进行切换
于是我写了一个代码
void main(void)
{
Timer0_Init_Config();
while(1)
{
cnt++;
if(cnt==100)
cnt=0;
}
}
void Timer0_Init_Config(void)
{
AUXR |= 0x80;
TMOD = 0x00;
TL0 = T1MS;
TH0 = T1MS >> 8;
TR0 = 1;
ET0 = 1;
EA = 1;
}
void Timr0_ISR() interrupt 1 using 1
{
icnt++;
}
很简单 大家多能看明白
接下来是他的汇编代码 让我有些不明白 怎么没有保存pc psw sp等寄存器呢
C:0x0000 020030 LJMP C:0030
36: void Timr0_ISR() interrupt 1 using 1
37: {
38: icnt++;
C:0x0003 0508 INC icnt(0x08)
39: }
C:0x0005 32 RETI
C:0x0006 00 NOP
C:0x0007 00 NOP
C:0x0008 00 NOP
C:0x0009 00 NOP
C:0x000A 00 NOP
C:0x000B 020003 LJMP Timr0_ISR(C:0003)
24: void Timer0_Init_Config(void)
25: {
26: AUXR |= 0x80;
C:0x000E 438E80 ORL AUXR(0x8E),#P0(0x80)
27: TMOD = 0x00;
C:0x0011 E4 CLR A
C:0x0012 F589 MOV TMOD(0x89),A
28: TL0 = T1MS;
C:0x0014 758A40 MOV TL0(0x8A),#0x40
29: TH0 = T1MS >> 8;
C:0x0017 758CA2 MOV TH0(0x8C),#0xA2
30: TR0 = 1;
C:0x001A D28C SETB TR0(0x88.4)
31: ET0 = 1;
C:0x001C D2A9 SETB ET0(0xA8.1)
32: EA = 1;
C:0x001E D2AF SETB EA(0xA8.7)
33: }
C:0x0020 22 RET
11: void main(void)
12: {
13: Timer0_Init_Config();
14:
C:0x0021 12000E LCALL Timer0_Init_Config(C:000E)
15: while(1)
16: {
17: cnt++;
C:0x0024 0509 INC cnt(0x09)
18: if(cnt==100)
C:0x0026 E509 MOV A,cnt(0x09)
C:0x0028 B464F9 CJNE A,#0x64,C:0024
19: cnt=0;
C:0x002B E4 CLR A
C:0x002C F509 MOV cnt(0x09),A
20: }
C:0x002E 80F4 SJMP C:0024
C:0x0030 787F MOV R0,#0x7F
C:0x0032 E4 CLR A
C:0x0033 F6 MOV @R0,A
C:0x0034 D8FD DJNZ R0,C:0033
C:0x0036 758109 MOV SP(0x81),#cnt(0x09)
C:0x0039 020021 LJMP main(C:0021)
C:0x003C 00 NOP
照例进入中断就会保存现场阿 可从代码上来看 没有看出这些操作
以上 还请各位大牛指点下
|