better coding methods to freeing active ram in small pics


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: better coding methods to freeing active ram in small pics

    Quote Originally Posted by pedja089 View Post
    I notice that nested IF's use less code space than one if with multiple AND's.
    Probably it use less ram.
    For more complex condition instead of
    IF (x<8 OR X>2) AND y=1 THEN your stuff...(77words used)
    I use this:
    Code:
    IfVar=0
    IF x<8 THEN IfVar=1
    IF x>2 THEN IfVar=1
    IF y<>1 THEN IfVar=0
    
    IF IfVar=1 THEN
        IfVar=0
        your stuff...
    ENDIF
    31 words used.
    IfVar is unused bit of byte. For example IfVar var seconds.7
    But wouldn't that be the same as;

    Code:
        if y = 1 then
            your stuff...
        endif
    ????

  2. #2
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: better coding methods to freeing active ram in small pics

    Hehe... it's just example...
    I wrote first thing that came on my mind...
    Ok...

    IF (X<8 OR Z>2) AND Y=1 THEN your stuff...(77words used)

    Code:
    IfVar=0
    IF X<8 THEN IfVar=1
    IF Z>2 THEN IfVar=1
    IF y<>1 THEN IfVar=0
    
    IF IfVar=1 THEN
        IfVar=0
        your stuff...
    ENDIF
    31 words used.
    Better???

Similar Threads

  1. amount of ram
    By vicce67 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th November 2012, 17:15
  2. Re-programming SM PICS on small PCBs
    By tekart in forum General
    Replies: 0
    Last Post: - 11th April 2011, 17:07
  3. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  4. Alternative Methods ...
    By T.Jackson in forum Off Topic
    Replies: 3
    Last Post: - 9th June 2008, 13:13

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts