While we're on the subject of optimization...


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    mmpff, to me it doesn't make sense at all to do so, this will just suck juice where it shouldn't need to.
    I guess my main thing is that I can put the whole thing into one command.
    Instead of this:
    lcdpx = 10
    lcdpy = 10
    string = "assuming PBP could handle strings anyways"
    forecolor = 5
    backcolor = 0

    I get this:
    @ printstr "10,10,printstr can handle this string after all,5,0"

    Might not save any code space, but I can see it saving some sanity...

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


    Did you find this post helpful? Yes | No

    Default

    I've used the following method in assembly language programs to reduce LCD string "overhead" by pulling the string address from the stack but I'm not sure how you might implement it in PBP (or if it might save memory compared to how you're doin' it now).

    Food for thought. Regards, Mike

    Code:
    ;
    ;  example macro usage
    ;
            PutStr  "Azimuth:\n\r "
            PutStr  "Elevation:\n\r"
    ;
    Code:
    ;
    ;  PutStr macro
    ;
    PutStr  macro   str             ; print in-line string
            call    PutString       ;
            db      str,0
            ENDM
    ;
    Code:
    ;******************************************************************
    ;
    ;  PutString - print in-line string via Stack and TBLPTR
    ;
    ;  string must be terminated with a 00 byte and does not need
    ;  to be word aligned
    ;
    PutString
            movff   TOSL,TBLPTRL    ; copy return address into TBLPTR
            movff   TOSH,TBLPTRH    ;
            clrf	TBLPTRU		; assume PIC with < 64-KB
    PutNext
            tblrd   *+              ; get in-line string character
            movf    TABLAT,W        ; last character (00)?
            bz      PutExit         ; yes, exit, else
            rcall   PutLCD          ; print character to LCD
            bra     PutNext         ; and do another
    PutExit
            btfsc   TBLPTRL,0       ; odd address?
            tblrd   *+              ; yes, make it even (fix PC)
            movf    TBLPTRH,W       ; setup new return address
            movwf   TOSH            ; 
            movf    TBLPTRL,W       ;
            movwf   TOSL            ;
            return                  ;

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Might not save any code space, but I can see it saving some sanity...
    How's this for losing some sanity?
    Attached Files Attached Files

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    In case someone opens that file, and is running a little short...
    Here's an extra roll for ya.

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2403&stc=1&d=120519801 7" />
    <br>
    Attached Images Attached Images  
    DT

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel. I sure needed the extra roll!

    Hey Skimask, are you really able to follow the program? I got dizzy... Congrats anyway!

    Ioannis

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    Thanks Darrel. I sure needed the extra roll!
    Hey Skimask, are you really able to follow the program? I got dizzy... Congrats anyway!
    Ioannis
    I suppose it's like anything else when programming...the guy that wrote it can follow it, practically nobody else can...

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. code size VS speed optimization setting?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2008, 14:38
  3. Multiple if then optimization
    By Mugelpower in forum mel PIC BASIC Pro
    Replies: 35
    Last Post: - 5th March 2008, 12:15
  4. Replies: 2
    Last Post: - 1st May 2006, 13:45

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