AnsweredAssumed Answered

In Line Assembly

Question asked by Patrick Boswell on Jan 17, 2010
Latest reply on Jan 18, 2010 by CompilerGuru

I think I am missing something easy here. I made a function to wait a variable amount of time. My problem is that the D accumulator starts at zero after I tell it to load the ClockCycles variable. I believe the problem is that I need to do direct addressing. To do that I would perform LDD #ClockCycles, but Codewarrior doesn't accept that, and instead loads the address, which puts 0000 in the D accumulator.

 

The code is below:

 

// ---------------------------------------------
// VariableWaitAmount -- Pass in the amount of ns to delay, 40 ns min
// ---------------------------------------------  
void VarWait(long int nsToWait) {
 
  long int ClockCycles;
 
  ClockCycles = nsToWait / 40;
 
  asm START: LDD ClockCycles
  asm LOOP1: DBNE D, LOOP1
  return;
 
}

 

Thanks!

Outcomes