|
Post by christophertumber on Dec 5, 2014 10:10:01 GMT -5
Ok, but for any lurkers... The problem you're probably having is that macros simply insert their contents verbatim. So if you have branches and labels you are going to wind up with duplicate labels and an error. For example, let's take a really simple case: infinite macro here: bra here endm
Super simple macro you might use for debugging but used here for clarity. Causes the program to enter an endless loop. If you then use that macro repeatedly: infinite infinite infinite infinite
The resulting code is actually: here: bra here here: bra here here: bra here here: bra here
Which will result in errors because you have defined the label "here" four times. The solution to this is to use "local" labels. Similar to local variables in high level languages. Depending on the assembler you may have different options supported (RTFM!) but all the 6809 assemblers I've seen support the following: infinite macro here\?: bra here\? endm
The \? is the key here. It tells the assembler this is a local label. And if you look at the .lst file, you'll see something like this: here000001: bra here000001 here000002: bra here000002 here000003: bra here000003 here000004: bra here000004
|
|