[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cross development notes



In article <1147222981.078204.103140@e56g2000cwe.googlegroups.com>,
 "BLuRry" <brendan.robert@gmail.com> wrote:
[...]
> However, for the power and glory of m4, I don't know if I like the 
> quoting syntax.  Seems it could get a little cryptic to remember to 
> use ` and ' characters.  Good thing they included the "changequote" 
> command though.

The stock quotes `' would be more palatable if I could find a decent 
monospaced font that rendered them symmetrically:-) I went with [ and ] 
because I needed '.

> Can you write PC-aware operands in M4?  For example, in Acme
> macros can respect the program counter like so:
> 
> ; far branch, as defined in <6502/std.a>
> 		!macro bne .target {
> 			beq * + 5
> 			jmp .target
> 		}

changequote([, ])
define (bne, [
 BEQ *+5
 JMP $1])

m4 doesn't care that the symbol * refers to the program counter; it just 
replaces the token bne(target) with the defined expansion:

 BEQ *+5
 JMP target

The assembler then evaluates the expression *+5.

OTOH, your point is well taken: an integrated macro facility can often 
provide convenient features such as local labels. With m4, one must 
synthesize local labels.

-- 
John Matthews
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/