Inline assembly for Codewarrior

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inline assembly for Codewarrior

Jump to solution
2,282 Views
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 */

}

 

Labels (1)
0 Kudos
Reply
1 Solution
635 Views
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

View solution in original post

0 Kudos
Reply
2 Replies
636 Views
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 Kudos
Reply
635 Views
clayhowell
Contributor I

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

0 Kudos
Reply