![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Guest
|
comparing float variable with float constant problem |
Posted: Tue Apr 20, 2004 5:13 am |
|
|
I have a kind of problem when comparing float variable with float constant.
Quote: | if(time1>0.0) {
delay_cycles(1);
..............
} |
time1 is greater then 0. but instruction delay_cycles(1); have never happened?
I read the dissassembly listing:
Quote: | if(time1>0.0) {
CLRF 0x91, BANKED
CLRF 0x90, BANKED
CLRF 0x8f, BANKED
CLRF 0x8e, BANKED
MOVFF 0x74, 0x95
MOVFF 0x73, 0x94
MOVFF 0x72, 0x93
MOVFF 0x71, 0x92
CALL 0xa0c, 0
BTFSS 0xfd8, 0, ACCESS
GOTO 0xe46
delay_cycles(1);
NOP
} |
Something is wrong on address 0xa0c I have a nop instruktion, and on the next address I have a part of other subroutine. May someone tell me where is my mistake. Do I nead to include some files for comparison of two float values. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: comparing float variable with float constant problem |
Posted: Tue Apr 20, 2004 11:45 am |
|
|
Anonymous wrote: | I have a kind of problem when comparing float variable with float constant.
Quote: | if(time1>0.0) {
delay_cycles(1);
..............
} |
time1 is greater then 0. but instruction delay_cycles(1); have never happened?
I read the dissassembly listing:
Quote: | if(time1>0.0) {
CLRF 0x91, BANKED
CLRF 0x90, BANKED
CLRF 0x8f, BANKED
CLRF 0x8e, BANKED
MOVFF 0x74, 0x95
MOVFF 0x73, 0x94
MOVFF 0x72, 0x93
MOVFF 0x71, 0x92
CALL 0xa0c, 0
BTFSS 0xfd8, 0, ACCESS
GOTO 0xe46
delay_cycles(1);
NOP
} |
Something is wrong on address 0xa0c I have a nop instruktion, and on the next address I have a part of other subroutine. May someone tell me where is my mistake. Do I nead to include some files for comparison of two float values. |
The a0C code, is the 'comparison' code. The 'nop', is to get round the hardware problem with the 18Family PICs, that they can 'lose' the first instruction after a branch in some circumstances. The comparison code, returns the bit set or cleared in register fd8, 0, and then the BTFSS, will either jump round the delay (the nop instruction following the goto e46). The actual comparison code, takes far more cycles, than the delay itself (remember that to 'compare' a floating point number, including being greater, requires quite a complex test, involving the sizes of the exponent, and then the number itself). The delay is only one instruction clock (hence the nop is all that is added). If you want to 'prove' that the comparison is working, use a longer delay (1mSec), and you will then be able to detect the difference...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|