PDA

View Full Version : automatic macro selection?



mpanetta
- 19th August 2008, 16:30
I am trying to create an extension to HSERIN/HSEROUT that does STX/ETX string handling and I am wondering how I can get it to work. I have seen that you can call ASM macros from PBP using @, but how do I get it to automatically select which one to use like the built in PBP statements do?

For example, by looking through the generated ASM code it seems that when you call hserout ["test"] it calls the HSEROUT?C macro 4 times, one for each letter in the word "test". What I want to do is something similar, so when I call my function/macro like so: @stxtx type, "Test" it will automatically 'do the right thing' and expand the macro I create to send a constant string...

I'm kind of new to PBP (actually quite new) but I have an extensive C background with a bit of ASM, so I think my issue is just trying to figure out how to do things the 'PBP Way (TM)'

So is what I want to do possible, or am I out of luck? If someone has done something like this already, can they point me to an example? I guess a detailed PBP + MPASM + macros guide would be a good pointer too, if something exists.

Thanks,
Mike

skimask
- 19th August 2008, 17:07
If this is what you're going for:

[STX][status][type][length][user data...][checksum][ETX]

then this may work for HSERIN without the macro's...



HSERIN [Wait [ $02 ] , status , type , length ] 'gets everything up to 'length'
HSERIN [ array\length , chksum ] 'gets 'length' characters, grabs the checksum
HSERIN [ Wait [ $03 ] ] 'waits for ETX, if this doesn't time out, then you got a valid array of data


For the HSEROUT,