请教!关于寄存器移位的问题
在移位寄存器中,某一个比特位:
(1)一次向右移动10位(>>10)
(2)每次只向右移1位(>>1),移动了十次
现在想问(1)(2)中它们的操作过程是等效的吗?或者说两者的操作时间是否一样?
[解决办法]
main()
{
volatile unsigned int a = 0x8000;
volatile unsigned int b = 0;
int i;
for (i = 0; i < 10; i++)
{
a >>= 1;
}
b = a;
a = 0x8000;
b = a >> 10;
return 0;
}
C:0x0000 020041 LJMP STARTUP1(C:0041)
2: {
3: volatile unsigned int a = 0x8000;
C:0x0003 750880 MOV 0x08,#P0(0x80)
C:0x0006 750900 MOV 0x09,#0x00
4: volatile unsigned int b = 0;
5: int i;
6:
C:0x0009 E4 CLR A
C:0x000A F50A MOV 0x0A,A
C:0x000C F50B MOV 0x0B,A
7: for (i = 0; i < 10; i++)
C:0x000E FD MOV R5,A
C:0x000F FC MOV R4,A
8: {
9: a >>= 1;
C:0x0010 E508 MOV A,0x08
C:0x0012 C3 CLR C
C:0x0013 13 RRC A
C:0x0014 F508 MOV 0x08,A
C:0x0016 E509 MOV A,0x09
C:0x0018 13 RRC A
C:0x0019 F509 MOV 0x09,A
10: }
11:
C:0x001B 0D INC R5
C:0x001C BD0001 CJNE R5,#0x00,C:0020
C:0x001F 0C INC R4
C:0x0020 ED MOV A,R5
C:0x0021 640A XRL A,#0x0A
C:0x0023 4C ORL A,R4
C:0x0024 70EA JNZ C:0010
12: b = a;
13:
C:0x0026 85080A MOV 0x0A,0x08
C:0x0029 85090B MOV 0x0B,0x09
14: a = 0x8000;
15:
C:0x002C 750880 MOV 0x08,#P0(0x80)
C:0x002F 750900 MOV 0x09,#0x00
16: b = a >> 10;
17:
C:0x0032 E508 MOV A,0x08
C:0x0034 13 RRC A
C:0x0035 13 RRC A
C:0x0036 543F ANL A,#0x3F
C:0x0038 F50B MOV 0x0B,A
C:0x003A 750A00 MOV 0x0A,#0x00
18: return 0;
C:0x003D E4 CLR A
C:0x003E FE MOV R6,A
C:0x003F FF MOV R7,A
19: }
C:0x0040 22 RET