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


Closed Thread
Results 1 to 32 of 32

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Well, as far as i'm aware of, MPASM don't provide any features like that. If you don't fill all arguments, it will prompt you. That's one downside.

    So you'll probably need to build some different version of you macro, one calling the other or variant of.
    Steve

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

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Well, as far as i'm aware of, MPASM don't provide any features like that. If you don't fill all arguments, it will prompt you. That's one downside.
    It'll prompt me all-right...prompt me with an error message!

    So you'll probably need to build some different version of you macro, one calling the other or variant of.
    I've been pouring over the MPASM documentation looking for some insight into 'overloading' macros like I want to do and not finding anything interesting. I guess it's back to multiple versions of the same thing, but different. It's either that or I'm going to try a version with a 'mode number' in the front, sort like that multiple LCD mod on another thread...
    @ printstr 1 , 5 , 5 , "works here" - mode 1 - no color modify
    @ printstr 2 , 5 , 5 , 1 , "works here" - mode 2 - foreground color change...
    ...and so on...
    Let the code in the macro do the choosing based on the mode number.
    But if I go that way, I may as well have different versions.
    More thought required...

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


    Did you find this post helpful? Yes | No

    Default

    That's one of only 2 circumstances in which I would prefer PM.EXE

    With PM, you are not limited to a specific number of parameters supplied to a macro.

    If paramaters are ommited, they show up as "undefined".
    Then you can just do a IFNDEF to see if a parameter was included or not.

    The second circumstance is IRPC, which can split up each character of a string and repeat the macro for each one.

    However, since PM can't "Nest" macro's. It doesn't help a bit.
    Not to mention the 18F problem.

    And like you've both already pointed out...
    MPASM can't do either one of them.
    <br>
    DT

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    If paramaters are ommited, they show up as "undefined".
    Then you can just do a IFNDEF to see if a parameter was included or not.
    However, since PM can't "Nest" macro's. It doesn't help a bit.
    Not to mention the 18F problem.
    And like you've both already pointed out...
    MPASM can't do either one of them.
    <br>
    I've come up with a half-way solution to what I want.
    I just take the standard @printstr macro, keep all of my parameters inside of the quotes, and count the number of comma's inside the quotes and act accordingly:
    4 comma's, all parameters, x, y, string, forecolor, backcolor
    3 comma's, all but backcolor
    2 comma's, all but colors.
    Only limitation is that I can't use a comma (or double-quote, or single-quote) in the string.
    Basic string parsing code at work...
    Not the optimal solution, not my preferred solution, but it'll work.

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


    Did you find this post helpful? Yes | No

    Default

    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 would just prefer to use a macro for the color stuff, and one for the print... or filling the whole thing with all parameter in. but, yeah, that's me
    Steve

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

  6. #6
    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...

  7. #7
    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                  ;

  8. #8
    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

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