Minimizing code....


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    No, but this might work for you..
    Code:
    ' print message a
    GOSUB messagea
    
    ' print messageb
    GOSUB messageb
    
    etc...
    
    messagea:
    Lookup y,["Message A"],ascii
    GOSUB LCD_THINGY
    Return
    
    messageb:
    Lookup y,["Message B"],ascii
    GOSUB LCD_THINGY
    Return
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Feb 2009
    Posts
    41


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,

    Thanks again for your help.

    I have considered your idea but I can't figure out how to implement it because the GOSUB LCD_THINGY routine makes 64 lookups of the table in question.

    TR

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Might be a good time to post your code as it is right now, I am sure there is something I am missing.
    From the manual :
    An unlimited number of subroutines may be used in a program. Subroutines may also be nested. In other words, it is possible for a subroutine to call another subroutine. Such subroutine nesting should be restricted to no more than four levels deep (12 levels for 17Cxxx and 27 levels for 18Cxxx)
    So as long as the look up table block does not call a sub of a sub then you shoulde OK with 64 GOSUBS to the lookup block and back.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    969


    Did you find this post helpful? Yes | No

    Default

    Hi Terd

    This is how I do it when I have a number of messages to either print or put out to a 7 segment display.

    Code:
    ' Thank DT for this Macro
    ASM
    GetAddress macro Label, Wout       ; Returns the Address of a Label as a Word
        CHK?RP Wout
        movlw low Label
        movwf Wout
        movlw High Label
        movwf Wout + 1
        endm
    ENDASM
    Address         var     word
    gr[0]             var     byte
    
    ' Examples of how to put your strings in memory
    prn_SetDate:       PokeCode "Date changed",0
    prn_SetTime:       PokeCode "Time changed",0
    prn_LogPrinted:    PokeCode "Log printed",0
    
    ' And this is how to use it
      @ GetAddress _prn_SetDate, _Address
      gosub Prt_puts   ' This is my routine to put the string to Printer.  
                             ' You could change this to your LCDout routine.
      return
    
    ' And this is My Prt_puts function
    ' Print an ASCIIZ string
    ' Input - Address points to the string
    Prt_puts:
      repeat
        peekcode Address, gr[0]             ' read a byte to GR[0] (general register 0)
        if gr[0] then                             ' if end of message (0) not found, 
          gosub Prt_putc                       ' print this character
          Address = Address+1               ' advance to the next position of input string
        endif
      until gr[0]=0                              ' go back if the message end is found
      return
    This is not adapted to your requirement, but, I think you can do that yourself.

Similar Threads

  1. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  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