If this is assembly language (which it looks to be), then you have the wrong idea about these directives. They are for conditional assembly. They are equivalent to this in C:
#if adresh > 0x2d compile this #else compile this #endif
The directives don't generate code to read registers and decide which way to go.
As Gary correctly pointed out, the code you posted implements "conditional assembly". I.E. the code is parsed and acted upon only at assembly time (never at run time). And, of course, at assembly time your register, ADRESH, exists only as an *address*; since the location doesn't actually exist at assembly time, its contents cannot be tested then.
What is a macro? It's just a set of one or more instructions that the assembler inserts into your code. And those instructions get executed only at run time. No, I think a macro won't do what you want.
But I'm beginning to suspect that I don't understand what you want to do.
Maybe you want to define a CONSTANT and then, depending on that value, have either GOTO LOOP or GOTO LOOP1 assembled into your code??
It really would depend on the macro capabilities of the assembler. The problem is automatically generating the labels needed. You could have the macro use some assembler symbol (an EQU) and have your macro increment the symbol when called. One problem is that some assemblers only allow a symbol to be defined once, so: XX EQU 1
XX EQU XX + 1
will cause an error. If your assembler takes it, then you still have the problem of creating the symbol.
Ideally, you'd want to concatenate the symbol with a string:
LABEL+XX
I don't know how many assemblers are this sophisticated. I seem to recall that the old PDP-11 MACRO-11 assembler could do this.
Of course, one could always write a separate macro processor then feed its output to the assembler.
Hawkmoo wrote: : : my question was is there some kind of efficient way to macro-ize this : so as not to bother with two labels, as well as make the code more : readable. : :
Take a look at the 'structured assembly' stuff on this page:
formatting link
(get SASM2002.09.28). You'll also need MP_SASM if you don't have MPLAB installed.
An example of using it: IF_ .z. MOVLF 250,ALIVECNT bcf PORTA,RA4 ENDIF_
This generate runtime code that's what you are wanting.
ttyl,
--buddy
--
Remove '.spaminator' and '.invalid' from email address
when replying.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.