Help! Why tst.l needed in CW V7.0 not V6.3?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Help! Why tst.l needed in CW V7.0 not V6.3?

2,370 次查看
Superman_EE
Contributor I

 

There are some differences in assembles in CW V6.3 and V7.0. Why is " tst.l    d0" needed in V7.0, not in V6.3?

C code:
while (!(MCF_I2C_I2SR & MCF_I2C_I2SR_IIF));

Assemble in v6.3:
0001801A: 41F940000000    lea      0x40000000 (0x40000000),a0
00018020: 1228030C        move.b   780(a0),d1
00018024: 7000            moveq    #0,d0
00018026: 1001            move.b   d1,d0
00018028: 028000000002    andi.l   #0x2,d0
0001802E: 67EA            beq.s    I2CWriteN+0x56 (0x1801a); 0x0001801a

Assemble in v7.0:
000191B2: 12394000030C    move.b   0x4000030C (0x4000030c),d1
000191B8: 7000            moveq    #0,d0
000191BA: 1001            move.b   d1,d0
000191BC: 028000000002    andi.l   #0x2,d0
000191C2: 4A80            tst.l    d0
000191C4: 67EC            beq.s    I2CWriteN+0x56 (0x191b2); 0x000191b2


Best Regards

Superman_EE

标签 (1)
标记 (1)
0 项奖励
回复
5 回复数

464 次查看
vier_kuifjes
Senior Contributor I
I may be mistaking here too but, when compiled with CW 7.1, I get:

Code:
0x00000030  0x10394000030C           move.b   0x4000030c,d00x00000036  0x08000001               btst     #1,d00x0000003A  0x67F4                   beq.s    *-10                  ; 0x00000030

 
...for both...
Code:
while (!(MCF_I2C_I2SR & MCF_I2C_I2SR_IIF));

 
...and...
Code:
while ((MCF_I2C_I2SR & MCF_I2C_I2SR_IIF)==0);

 
I already noticed a big improvement in code efficiency with my own project when I upgraded from CW7.0 to 7.1. Upgrading from 6.4 to 7.0 resulted in larger code size. So I guess it makes sense to switch to 7.1!
0 项奖励
回复

464 次查看
RichTestardi
Senior Contributor II
Wow, that looks great, thanks!!!
 
Was the switch from 7.0 to 7.1 (relatively) painless?
 
0 项奖励
回复

464 次查看
vier_kuifjes
Senior Contributor I
I just uninstalled 7.0 first and then installed 7.1. Everything worked fine after upgrading.
0 项奖励
回复

464 次查看
RichTestardi
Senior Contributor II
Awesome, thanks, it worked for me, too, and I concur with your new assembly output!
 
0x00000006  0x103900000000           move.b   ___IPSBAR+780,d0
0x0000000C  0x08000001               btst     #1,d0
0x00000010  0x67F4                   beq.s    *-10                  ; 0x00000006

 -- Rich
0 项奖励
回复

464 次查看
RichTestardi
Senior Contributor II
I don't believe the tst.l is needed in either case (and I could not make it go away with optimization).
 
I was surprised to find that the following statement compiles into very different (shorter) code:
 
    while ((MCF_I2C_I2SR & MCF_I2C_I2SR_IIF)==0);
 
0x00000008  0x123900000000           move.b   ___IPSBAR+780,d1
0x0000000E  0x7000                   moveq    #0,d0
0x00000010  0x1001                   move.b   d1,d0
0x00000012  0x08000001               btst     #1,d0
0x00000016  0x67F0                   beq.s    *-14   
 
Or did I just make a really dumb mistake?
 
-- Rich
0 项奖励
回复