AN3496

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

AN3496

727件の閲覧回数
roberto_m
Contributor III

Looking for another an, I've found on Freescale's site
AN3496 - « A Software Approach to Using Nested Interrupts in HCS08 ».
I think it is very interesting.
I'm trying to insert it in a project, but I've some trouble.
First: could be a "c" project (with a .asm file & .h file to interface it)?
Second: how could I declare  INT_OBJ in C? more general: how colud I
insert/transform a "MACRO" (written in asm) in "something else" written in C?
I don't know how implement LMBD macro...

ラベル(1)
0 件の賞賛
返信
1 返信

336件の閲覧回数
bigmac
Specialist III

Hello Roberto,

 

Keep in mind that more powerful macros can be written with CW assembler (not the inline version), than are available in C.  The LMBD macro would appear sufficiently complex that a function may need to be used in lieu of a macro.  Of course this will be somewhat slower than the assembly code macro, as will most code written in C.

 

It would appear that the LMBD macro takes the form it does so that the same number of execution cycles are required, independent of the return value.  This may have to be foregone, as the C compiler will likely generate different assembly code than the macro.  The equivalent C function would probably have the following form -

 

byte LMBD( byte val){  if (val >= 0x10) {    if (val >= 0x40) {      if (val >= 0x80)  return 7;      else              return 6;    }    else {      if (val >= 0x20)  return 5;      else              return 4;    }  }  else {    if (val >= 0x04) {      if (val >= 0x08)  return 3;      else              return 2;    }    else {      if (val >= 0x02)  return 1;      else              return 0;    }  }}

If you can tolerate significant variation in the execution cycles, depending on the output value, the following inline assembly code should produce a similar output to the macro.

 

byte LMBD( byte val){  __asm {        LDA  val;        LDX  #8;LOOP1:  DECX;        LSLA;        BCC  LOOP1;        STX  val;  }  return val;}

After cursory examination, it would appear that the equivalent of INT_OBJ should be setup as a C structure for each interrupt source.  INT_objtab would then become an array of structures.

 

Regards,

Mac

 

0 件の賞賛
返信