macro's


Closed Thread
Results 1 to 3 of 3

Thread: macro's

  1. #1
    Join Date
    Jan 2005
    Posts
    15

    Default macro's

    hello,

    after reading the board for string handling, again the solution is DT fantastic examples..
    but trying to combine interuptmodule ( macro) and the getaddress module ( for string handling) the compiler generates errors.

    duplicate macro name ( getaddress)

    is it not possible to use more than one macro ?
    the Hserout is not needed - just copy - paste to try ...


    used pic is 18F4525

    '*****************************************
    '* Name : STRINGS-16.PBP *
    '* Author : Darrel Taylor *
    '* Date : 6/12/2005 *
    '* Note: Strings must be NULL Terminated *
    '****************************************
    DEFINE LOADER_USED 1 ' If using bootloader
    DEFINE OSC 4
    DEFINE HSER_TXSTA 24h ' Use this for Higher Baud Rates
    DEFINE HSER_SPBRG 25 ' 9600 Baud at 4mhz

    Addr var word
    Char var byte
    Clear
    '************************************************* ********
    ' include special interupts
    INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts
    INCLUDE "Elapsed_INT-18.bas" ; Elapsed Timer Routines

    goto StartLoop ' Required
    String1:
    @ da "This is a string",0

    AnotherString:
    @ da "Here is another string",0

    '------------GetAddress Macro - Location insensitive -------------------------
    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


    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
    INT_Handler TMR1_INT, _ClockCount, PBP, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM


    StartLoop ' This loop repeats continuously just as a test.
    @ GetAddress _String1, _Addr ' Get address of String
    gosub StringOut ' Send the String
    hserout [13,10] ' New Line

    @ GetAddress _AnotherString, _Addr ' Get address of String
    gosub StringOut ' Send the String
    hserout [13,10] ' New Line
    pause 500
    goto StartLoop ' Repeat


    StringOut: ' Send the string out via Hserout
    Readcode Addr, Char ' Get a character
    if Char = 0 then StringDone ' Look for Null char, Stop if found
    hserout [Char] ' Send char
    Addr = Addr + 1 ' Point to next character
    goto StringOut ' Continue with rest of the string
    StringDone:
    return

    end



    rgds
    harry

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    It's possible to use as many macros as you want, but you can't have two with the same
    name.

    GetAddress is already included in DT_INTS-18.bas. Just use this one.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Jan 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    many thanks Bruce,
    i will try it out !.

    and it works --- fast reply !!! very helpfull


    rgds
    Harry
    Last edited by tiger_bel; - 9th October 2007 at 22:42.

Similar Threads

  1. Embedded Strings in your Code Space
    By mytekcontrols in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 9th March 2008, 07:50
  2. Schematic Drawing Programs
    By fowardbias in forum Off Topic
    Replies: 4
    Last Post: - 3rd April 2007, 15:38
  3. Assembly Macros
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th March 2006, 21:02
  4. Making PBP code more modular
    By forgie in forum General
    Replies: 30
    Last Post: - 25th October 2005, 16:24
  5. macros tutoria
    By asterix in forum mel PIC BASIC
    Replies: 1
    Last Post: - 4th May 2005, 09:09

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