Inline assembly for Codewarrior

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Inline assembly for Codewarrior

跳至解决方案
2,283 次查看
clayhowell
Contributor I

Hi,

This may be a real stupid question but I can’t figure it out. I’m using Special Edition Codewarrior Eclipse for MCUV10.3 and programming the 9S08PA4. I started a new bareboard project and want to add some inline assembly to the code. This simple code won’t compile, I get “Unknown Opcode C18701” for both MOV and DBZN. This is the only code in the main file:

 

#include <hidef.h> /* for EnableInterrupts macro */

#include "derivative.h" /* include peripheral declarations */

 

int delaycomm;

 

void main(void) {

  EnableInterrupts;

  /* include your code here */

         asm

        {

              MOV #$FF,delaycomm;       

              LoopHere:                 

              NOP;                        

              DBNZ delaycomm,LoopHere;  

        }

 

  for(;;) {

    __RESET_WATCHDOG();    /* feeds the dog */

  } /* loop forever */

  /* please make sure that you never leave main */

}

 

标签 (1)
0 项奖励
回复
1 解答
636 次查看
kef
Specialist I

Message is probably caused by using other than Tiny memory model, in which static storage variables are placed at address >= 0x100, and as a result MOV can't be used.

Error message is misleading. I tried to compile the same snippet in CW 6.3. It produced

Error   : C18700: Unknown Opcode Operand Combination: Opc.:MOV/Dest.:Ext/Source:Imm8.

, which makes sense.

To place variables in zero page use DATA_SEG pragma like this:

#pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE

int delaycomm;

#pragma DATA_SEG DEFAULT // restore memory model default placement

在原帖中查看解决方案

0 项奖励
回复
2 回复数
637 次查看
kef
Specialist I

Message is probably caused by using other than Tiny memory model, in which static storage variables are placed at address >= 0x100, and as a result MOV can't be used.

Error message is misleading. I tried to compile the same snippet in CW 6.3. It produced

Error   : C18700: Unknown Opcode Operand Combination: Opc.:MOV/Dest.:Ext/Source:Imm8.

, which makes sense.

To place variables in zero page use DATA_SEG pragma like this:

#pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE

int delaycomm;

#pragma DATA_SEG DEFAULT // restore memory model default placement

0 项奖励
回复
636 次查看
clayhowell
Contributor I

Hey thanks. Adding the pragma's does the trick. Thanks so much for the insight.

0 项奖励
回复