I/O - From Define to code ... must be easy
Oki, so here's the question assuming the following way to define Aliases to I/O
Code:
DEFINE LowBeerLevel PORTB,1
OR
Code:
#DEFINE LowBeerLevel PORTB,1
On ASM level.
It's still easy to use them later with MOVE?CT macro, or BSF/BCF whatever floats your boat.
What if I wanted to use it with say I2CREAD, HIGH or whatever else PBP command?
Tried few variants of EXT modifier thing.. but LOL...
Re: I/O - From Define to code ... must be easy
I think the preferred way is this:
Code:
LowBeerLevel var portb.1
GoToBeerStore var portb.2
while !LowBeerLevel
:):)
while end
ASM
BSF _GoToBeerStore
ENDASM
If GoToBeerStore = 1 then
:(
Ok, silly example, but the point is create your var's or alias as usual, then to use in ASM block stick an underscore before the name.
HTH
Re: I/O - From Define to code ... must be easy
You missed the DEFINE thing, however I came up with the following
Code:
DEFINE SData PORTB,1
DEFINE SClock PORTB,2
And then in the compilation time section you use
Code:
CreateVar MACRO PortIn,BitIn, PortOut, BitOut
PortOut = PortIn
BitOut = #V(BitIn)
ENDM
;
;
; somewhere later
;
@ CreateVar SData, SerData, DataBit
@ CreateVar SClock, SerClock, ClockBit
SerData VAR BYTE EXT
DataBit CON EXT
SerClock VAR BYTE EXT
ClockBit CON EXT
just need to use 'em like
Code:
HIGH SerClock.0[ClockBit]
It has some success, ugly... and we also know this method is not going to work all the time... good example? Shiftout :D
Keep thinking...
Re: I/O - From Define to code ... must be easy
I think of some other ways, but it's damn too much coding for a so simple thing :D The asm side's still good enough though. It would have been soo easy if we could do
DEFINE LCD_EN_LINE PORTC,1
and then
LCD_EN_LINE VAR BIT EXT... BUT NOPE
OR
even easier.. have them ready to use, nothing to hack...
Why I do prefer the DEFINE way... hahaha, I have no idea :D Probably to fit with PBP LCDOUT, HSEROUT, DEBUG etc etc etc
Re: I/O - From Define to code ... must be easy
hhhhhhhhhhhhhhhhhhhhhaaaaaa! I knew it was something "easy", just never though of the #undefine twist...mmm... something else to chew on :D
Thanks Mr Tech Support ;)
Re: I/O - From Define to code ... must be easy
Hi,
So, are you saying that this is almost like conditional compilation? By almost I mean that as far as I understand it, it will alwyas compile the code but depending on if the DEFINE exists or not the compiled ASM code will or will not be assembled?
Is that correct? If not, could Steve or Darrel elaborate a bit as I'm curious?
Thanks!
/Henrik.
Re: I/O - From Define to code ... must be easy
Yup, some black magic in conditional compilation, IFDEF, IFNDEF, #DEFINE, #UNDEFINE, to name only but those. Pretty slick and so usefull once you get the concept and play with.
Lots of great feature in asm and MPASM. If you' wanted, you may have one code template and it will fit every hardware depending how you deal with the conditional compilation. Good example, Microchip Framework. One code fits all(most) of their development boards.
On the top of your code, you provide some USER configurable setting, says regular LCD or GLCD, USB to RS232, PIC model and so forth... endless possibilities.
Pretty addictive.
Re: I/O - From Define to code ... must be easy
I smell that you are cooking something here Steve, but cannot follow you.
I'll wait to see the smartie that you will show us... anxiously :)
Ioannis
Re: I/O - From Define to code ... must be easy
Always looking for convenience, but don't always use it :D
"What you smell is a fart, not much " <-- highlight with your mouse...