Code: Why is this code greater than 2000 words?


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink Nice flight stabilizer...

    just missing ref. to a twin axis gyroscope sensor ... IDG 300 ???



    << if Ratio < 100 And Ratio > 0 then ... >>

    other room to save : Ratio is ALWAYS > 0 ( Coz. PbP only works with POSITIVE INTEGERS !!! ) ...

    << Alpha = Ratio*11 + 732*10 >>

    Why not directly write " Alpha = Ratio*11 + 7320 "

    saves one 16x16 multiplication !!!


    Was just some examples ...


    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Here the multiple used math is more revealant than Pulsout Itself. Yeah i still refer to the same method to measure the code size... let's see

    Code:
    <font color="#000080">@ __CONFIG  _INTRC_OSC_NOCLKOUT &amp; _MCLRE_ON  &amp;  _LVP_OFF &amp; _WDT_OFF &amp; _PWRTE_ON  &amp; _BODEN_ON  
        </font>PORTB=0
        TRISB=0
        Led1    <font color="#000080">VAR </font>PORTB.0
        Led2    <font color="#000080">VAR </font>PORTB.1
        Led3    <font color="#000080">VAR </font>PORTB.2
        Led4    <font color="#000080">VAR </font>PORTB.3
        Led5    <font color="#000080">VAR </font>PORTB.4
        Led6    <font color="#000080">VAR </font>PORTB.5
        Led7    <font color="#000080">VAR </font>PORTB.6
        Led8    <font color="#000080">VAR </font>PORTB.7
        ByteA   <font color="#000080">VAR BYTE
        </font>ByteB   <font color="#000080">VAR BYTE
        </font>Worda   <font color="#000080">VAR WORD
        
        </font>PORT    <font color="#000080">VAR BYTE
        </font>DURATION <font color="#000080">VAR WORD
        GOTO </font>Start
        <font color="#000080">ASM
    HOGSTART MACRO
    BLOCKSTART=$
        ENDM
        
    HOGEND  MACRO BLOCKNAME
    BLOCKNAME = $-BLOCKSTART
        ENDM
    
    CUSTOM_PULSOUT MACRO PORT, PIN, DURATION, BYTEA
        PULSOUT?TC PORT,PIN,DURATION
        MOVE?CB BYTEA,_ByteA
        L?CALL _DO_CALC
        ENDM
    ENDASM
    
    </font>DO_CALC:
        ByteB=50+ByteA
        Worda=(ByteA+ByteB)*100
        <font color="#000080">RETURN
    
    </font>Start:
        @   HOGSTART            
        <font color="#000080">PULSOUT  </font>Led1,10000
        ByteA=10
        ByteB=50 + ByteA
        Worda=(ByteA+ByteB)*100
        
        <font color="#000080">PULSOUT  </font>Led2,10000
        ByteA=20
        ByteB=50 + ByteA
        Worda=(ByteA+ByteB)*100
    
        <font color="#000080">PULSOUT  </font>Led3,10000
        ByteA=30
        ByteB=50 + ByteA
        Worda=(ByteA+ByteB)*100
    
        <font color="#000080">PULSOUT  </font>Led4,10000
        ByteA=40
        ByteB=50 + ByteA
        Worda=(ByteA+ByteB)*100
        @   HOGEND ____MULTIPLEPULSOUT
        
        <font color="#000080">ASM
            HOGSTART
            CUSTOM_PULSOUT _Led1,10000,10
            CUSTOM_PULSOUT _Led2,10000,20
            CUSTOM_PULSOUT _Led3,10000,30
            CUSTOM_PULSOUT _Led4,10000,40
            HOGEND ____MACRO_CUSTOM_PULSOUT
        ENDASM   
        
    </font>SPIN: <font color="#000080">GOTO </font>SPIN
    Compile this with MPASM, and open the according .LST file... and discover that...
    Quote Originally Posted by ...LST file
    SYMBOL TABLE
    LABEL VALUE

    ____MACRO_CUSTOM_PULSOUT 0000002C
    ____MULTIPLEPULSOUT 00000074
    2c=44 decimal
    74=116 Decimal

    here the simple macro and sub call will use 116/44=~2.6 time less code and make the code MUCH MORE readable... at least to me.. case not.. hum, hum, just fart in Darrel's direction

    How handy they are
    Last edited by mister_e; - 1st June 2007 at 17:40.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    How handy they are
    The farts or the macros?

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    mmm, hard to tell
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Manchester coding/decoding Code help
    By financecatalyst in forum Code Examples
    Replies: 0
    Last Post: - 25th August 2009, 19:05
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  4. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  5. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26

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