Discussion Forum

F0 flag use by Keil libraries

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
javier de pedro
Posted
22-Feb-2007 08:10 GMT
Toolset
C51
New! F0 flag use by Keil libraries

Hello.

I have a bootloader that use F0 flag to indicate if the bootloader is executing (F0 = 1) or if the application is executing (F0 = 0).

But some Keil library functions modify this flag (float division, 32-bits signed long division, etc).

Somebody can help me with the full list of functions that modify this flag?

I cannnot modify the bootloader because the product is just in production (and sold out).

Read-Only
Author
Andy Neil
Posted
22-Feb-2007 09:27 GMT
Toolset
C51
New! Undocumented

You definitely need to contact Keil support direct for this to get a definitive answer!

Anything else is just hearsay, including: http://www.8052.com/forum/read.phtml?id=67514

Read-Only
Author
Reinhard Keil
Posted
22-Feb-2007 09:44 GMT
Toolset
C51
New! RE: Undocumented

http://www.keil.com/support/docs/2893.htm

Read-Only
Author
Reinhard Keil
Posted
22-Feb-2007 09:51 GMT
Toolset
C51
New! RE: Undocumented

The routines that are using F0 are:

  • signed char/int/float division
  • all floating point operations
  • printf, scanf, and derivatives
Read-Only
Author
Andy Neil
Posted
22-Feb-2007 10:09 GMT
Toolset
C51
New! RE: Undocumented

This should be clearly stated in the Manual - it should not be left to users to "stumble" across this information in the knowledgebase or the forum!

Read-Only
Author
Reinhard Keil
Posted
22-Feb-2007 14:34 GMT
Toolset
C51
New! RE: Undocumented

http://www.keil.com/support/man/docs/c51/c51_ap_regusage.htm

PSW includes F0 and it clearly states that this is used.

Read-Only
Author
Andy Neil
Posted
22-Feb-2007 17:23 GMT
Toolset
C51
New! RE: Undocumented

"PSW includes F0 and it clearly states that this is used."

Yes, but PSW also includes F1.
The knowledgebase article suggests that user programs may use F1, but the experience cited here suggests otherwise...

Read-Only
Author
javier de pedro
Posted
22-Feb-2007 13:42 GMT
Toolset
C51
New! RE: Undocumented

Thanks. This can help me!

I use this flag (F0) to execute the ISR of the bootloader or the ISR of the application. I think that if I disable interrupts (with EA = 0) before executing these functions and then restore F0 flag and EA, it will work.

Also, I notice that flag F1 is forced to 0 in the entry-code of the ISRs.

I also think that this must be documented in the C compiler manual.

Read-Only
Author
erik malund
Posted
22-Feb-2007 14:24 GMT
Toolset
C51
New! RE: Undocumented

while this is raised in a Keil forum, I think this should be mentioned.

The F0 flag is, for every '51 toolset I know (and I know quite a few) "reserved for compiler use".

I have often suggested that F0 be used to indicate overflow on the return from arithmetic routines since this would not in any way upset current use that does not 'know' if overflow occurred and, at the same time, allow those using the revised versions to test this flag.

Erik

Read-Only
Author
Viktor Bucher
Posted
22-Feb-2007 17:39 GMT
Toolset
C51
New! RE: Undocumented

Many 51 devices have also a F1 (PSW.1) flag. You may use it instead of F0.

Read-Only
Author
javier de pedro
Posted
22-Feb-2007 22:09 GMT
Toolset
C51
New! RE: Undocumented

Viktor

The problem is that I cannot change the bootloader.

Read-Only
Author
javier de pedro
Posted
22-Feb-2007 22:07 GMT
Toolset
C51
New! RE: Undocumented

erik

I have downloaded the last version of sdcc compiler. I have checked the source code of the libraries and, yes, they also use the FO flag in some math functions.

Oh! And I thank that use F0 was a good idea!

Javier

Read-Only
Author
erik malund
Posted
23-Feb-2007 13:21 GMT
Toolset
C51
New! RE: Undocumented

I posted : "The F0 flag is, for every '51 toolset I know (and I know quite a few) "reserved for compiler use"."
sdcc compiler .... they also use the FO
not one of those I know, this just confirms the generality of "F0 is a compiler flag"

Erik

Read-Only
Author
Jonny Doin
Posted
23-Feb-2007 00:47 GMT
Toolset
C51
New! RE: Undocumented

"Also, I notice that flag F1 is forced to 0 in the entry-code of the ISRs."

Standard ISR entry will clear the entire PSW, to guarantee BANK0 selection for the ISR handler. You may alter this by declaring different policies for banking. You may also circumvent this by declaring a ASM entry/exit handler that does the context saving/restore, preserving the user flags of PSW on entry for the ISR to check on them. Another, more dangerous approach, is to check the value of PSW pushed into the stack, but this is very sensitive.

Next Thread | Thread List | Previous Thread Start a Thread | Settings