Save some bytes in program memory


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: Save some bytes in program memory

    I was too quick on the trigger... That last example should be;

    Code:
        if((portb ^ 15) == 0)
          nop();
    Code:
         if((portb ^ 15) == 0)
    00E8  300F      MOVLW 0x0F
    00E9  0606      XORWF gbl_portb, W
    00EA  1D03      BTFSS STATUS,Z
    00EB  28ED      GOTO    label13
    
    
           nop();
    00EC  0000      NOP
    00ED        label13

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Save some bytes in program memory

    This variation only uses four words, which is pretty much how you might code it in assembler;
    You could load portb into the temp variable, rotate it four times left, and check the value is b11110000,
    and it wouldn't matter what was happening on the high bits of portb.

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


    Did you find this post helpful? Yes | No

    Default Re: Save some bytes in program memory

    Quote Originally Posted by Art View Post
    This variation only uses four words, which is pretty much how you might code it in assembler;
    You could load portb into the temp variable, rotate it four times left, and check the value is b11110000, and it wouldn't matter what was happening on the high bits of portb.
    Is there some advantage doing it that way, Art?

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Save some bytes in program memory

    Only if there was something else going on with the 4 high bits of portb,
    Otherwise any input on the high bits breaks the condition of portb ^ 15 = 0. or am I mistaken there?

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


    Did you find this post helpful? Yes | No

    Default Re: Save some bytes in program memory

    You're correct. Sorry I misunderstood, Art...

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