Nathan Newport

Label Addressing in HCS12

Discussion created by Nathan Newport on Mar 20, 2007
Latest reply on Mar 21, 2007 by bigmac
Hello,
I am working on an autonomous robot for a university robotics club.
I am trying to program a system that periodically interrupts and performs a different action from a sequential list of instructions. I've done this before using pure assembly with the P&E WinIDE on the same chip, so it shouldn't be too difficult in Codewarrior, but it has been. I can't seem to find a way to load a label into a variable.
I've tried using something like this:
void *address = &&Label_1

but CodeWarrior does not seem to recognize &&.
I tried using inline assembly to mark off each label using something like this:
__asm Label_1: ; // define a label
__asm LDD #Label_1; //load the address of the label into accumulator D

but Codewarrior gives me an error saying that Label Addressing mode is not supported!

So if someone knows how to make one of these methods work, that would be great. Or, if you know of a fast alternative (does not use many cpu cycles since this is a fairly short periodic timer interrupt), please let me know.

Here is an idea of the actions I want to take place:
[In init, define a label variable with the address of init]
[Interrupt occurs]
[goto/BRA to the label]

Init: // perform any initialization that only occurs on first interrupt
.
.
.
[Load Step1 address into variable] - This is where the problem occurs
[Return from Interrupt]

Step1:
.
.
.
[Load Step1 into variable] - problem again
[Return from Interrupt]

...
Step2: // Assume this is the last step
.
.
.
[Load Step1 into variable to start sequence all over] - problem again
[Return from Interrupt]

Notice that this method does not need to perform ANY checks after the interrupt,
it simply performs a goto/BRA, and starts into that stage of execution.
Thanks for any help you can provide with this!

Outcomes