BRCLR, BRSET, and TAX not working

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

BRCLR, BRSET, and TAX not working

4,174 Views
SILKS
Contributor I

Hello All,  

 

Have a problem with a short assembly language program

running on a M98S08AC32-64

CodeWarrior is killing me by throwing errors on what looks like legit code.

 

Thank you all,

Code is below.

 

Randall

 

 Doofus(void) {

 

asm { 

 

       brclr   6,cmdsave,scan_2       
        brclr   6,soundop,scan_11     

         brset   6,command,scan

 }

}

 CodeWarrior 6.2

Throwing unknown opcode 45. It does this with TAX and other instructions

Labels (1)
0 Kudos
Reply
8 Replies

1,233 Views
bigmac
Specialist III

Hello Randall,

 

The BRSET and BRCLR instructions are applicable to a page zero location only.  Therefore, your cmdsave, soundop and command variables will need to be explicitly allocated to Z_RAM segment.  Additionally, the branch addresses scan_2, scan_11 and scan require to be within range for relative addressing mode.

 

I cannot comment about your TAX problem without knowing the context.

 

Regards,

Mac

 

0 Kudos
Reply

1,233 Views
SILKS
Contributor I

MAC,

 

Worked perfectly, moving things into zero page with the #pragma worked. Thanks to you all.:smileyvery-happy:

 

Having another crazy problem, the code below is a small project that results in an error C18000

Label not set, however, as you can see the label clearly is set. Am I having another zero page error here?

 

Thanks, Randall. 

 

#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
// memvar declarations
#pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE

char  flag1 = 0x01;
char  soundop = 0xFF;
char modesave = 0x01;
char modeflag = 0x00;

 

// function prototype
int restore(void);

void main(void) {

  EnableInterrupts; /* enable interrupts */
  /* include your code here */
 
  for(;:smileywink: {
    __RESET_WATCHDOG(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}
/* function for Restore sounds in operation */

#pragma DATA_SEG DEFAULT

restore(void){

asm (

              brclr   7,flag1,rstor1;         //for the special case of interrupting !error C:smileysad:18000
              rts;
rstor1:
              lda     modesave;               //find mode when interrupted
              sta     modeflag;               //restore the flag
              lda     soundop;
              and     #$07f;                  //if these all off, nothing was operating
              bne     rstor2;                 //b/ something on, go figure it out
              rts:smileywink:;
            
rstor2:

return 0;
}

0 Kudos
Reply

1,233 Views
peg
Senior Contributor IV

Hello Randall,

 

Seems you have to pretty much figure your inline assembly problems out for yourself, the compiler is not much help.

What about the TAX problem? It went away too? This was leading me to think the problem was something else.

I've never used inline assembly so don't know much about it. I can see you don't have a closing parenthesis for the asm( or maybe it's the stupid smilies. Use a code box inyour post to stop this happening.

 

 

0 Kudos
Reply

1,233 Views
SILKS
Contributor I

Peg,

 

Thanks for the help, Umm code box, gotta figure that out on the forum.

I put the stupid smilies in there because I wanted to kill small woodland creatures when legit code did not run. (sorry). Talk to you Monday.

 

Regards

 

Randall

0 Kudos
Reply

1,233 Views
CompilerGuru
NXP Employee
NXP Employee

Try to use

__asm {

   nop

}

(and not "asm(")

Also there must be a correspoding closing brace, of course.

 

The restore function should also have a return type, otherwise it defaults to int and the HLI code only returns a char.

 

Daniel

0 Kudos
Reply

1,233 Views
bigmac
Specialist III

Hello Randall,

 

I can also see another issue with your function.  You have used two intermediate RTS instructions. This is probably not a good idea when you need to return a value, since the actual value returned could be quite confusing if one of the RTS exits occurs.

 

Regards,

Mac

 

0 Kudos
Reply

1,233 Views
peg
Senior Contributor IV

Hi,

 

Surely Codewarrior would issue a more relevant error than this for such simple things as " not in page zero" and " too big a relative branch" if these where the only problems???

There should be no limitation whatsoever on TAX

0 Kudos
Reply

1,233 Views
bigmac
Specialist III

Hello,

 

The OP is a little unclear about the specifics of the error messages.  However, since inline assembly code is used, I presume that the error messages are generated by the compiler, rather than the assembler.  Therefore I guess the messages are likely to be more C orientated, and less specific for the assembly code content.

 

The error message that refers to opcode 45 (not sure whether hex or decimal) does not make sense.  The opcode for TAX instruction is 0x97.

 

Regards,

Mac

 

0 Kudos
Reply