Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Per Westermark
01/17/12 09:40
Read: 396 times

#185536 - Hw variants or debugging are big users of conditionals
Responding to: ???'s previous message
It is very common to have the same code base used for a family of products.

Some models are premium editions with extra hardware capabilities, while some are lite editions with only the bare minimum.

Conditional compilation/assembly then allows you to build the same source multiple times.
One time to produce a big binary with lots of menu options, but only working with a product with much hardware.
One time to produce a small binary with fewer menu options, but (probably) working on all hardware. But intended for the lite hardware that doesn't have a temp sensor, ...

Also, you may have the same product but produce with one processor for the first 2 years. Then you need to switch to a different processor because of support (or capability) issues. So you select conditionaly if building for the old or new processor. Might be a different UART initialization in the newer processor.

Another thing is that you may want to conditionally turn off some of the product features, to release code/RAM space for conditional addition of special debug test code. So when testing GPS functionality, you turn off temperature sensor processing but adds extra debug output for the GPS. When testing temperature sensors, you remove support for the GPS but instead stores lots of temperature samples allowing you to emit noise and response-time information from the temp sensor.

Compile/assembly time conditionals are very very useful. Note that in most situations, it's possible to skip these features and instead use a standard C preprocessor and feed the already preprocessed files to the assembler. The advantage with that is that you can make use of a common C header file to control both assembler and C/C++.

But a compiler/assembler that does not come with any built-in support for conditional processing is really a quite poor and lite product.

List of 17 messages in thread
Conditional Statements      Donagh Choghlan      01/17/12 02:57      
   Hex constants?      Oliver Sedlacek      01/17/12 03:18      
      0x00, 0x01, 0x02??      Donagh Choghlan      01/17/12 03:28      
   What is the octothorpe?      David Prentice      01/17/12 03:31      
      #      Donagh Choghlan      01/17/12 03:40      
         Immediate or not      Per Westermark      01/17/12 07:31      
      what is an octothorpe?      Andy Peters      01/17/12 10:49      
         Previously, on      Andy Neil      01/17/12 15:02      
   Problem solved, query still remains      Donagh Choghlan      01/17/12 03:54      
      Do some trial and error      David Prentice      01/17/12 04:14      
      Check the CJNE instruction...      Robert Revens      01/17/12 06:31      
         Handy that!      Donagh Choghlan      01/17/12 07:18      
      run time vs compile time      Maarten Brock      01/17/12 07:14      
         IF only at assemble      Donagh Choghlan      01/17/12 07:23      
            Not Really!!      Michael Karas      01/17/12 08:47      
               I second that      Erik Malund      01/17/12 08:58      
            Hw variants or debugging are big users of conditionals      Per Westermark      01/17/12 09:40      

Back to Subject List