ASsembly Question

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi freaks, I have a simple asm routine that I am having trouble compiling.  It is as follows:

void context(void);
__attribute__((naked))void context(void){

	__asm__ __volatile__(	"MOV32   R0, OSTCBCur\n\t"
							"MOV32   R1, OSTCBHighRdy\n\t"
							"LDR     R2, [R1]\n\t"
							"STR     R2, [R0]\n\t"
							"LDR     SP, [R2]\n\t"

							"LDMFD   SP!, {R0}\n\t"
							"LDMFD   SP!, {R0-R12, LR, PC}");
}

The error message is thus:

 

C:\Users\wmjen\AppData\Local\Temp\cciolx1T.s:174: Error: bad instruction `mov32 R0,#OSTCBCur'
C:\Users\wmjen\AppData\Local\Temp\cciolx1T.s:175: Error: bad instruction `mov32 R1,OSTCBHighRdy'
 

Both are pointers.  Could someone suggest something to try?

 

 

 

 

This topic has a solution.
Last Edited: Thu. Aug 9, 2018 - 09:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you include the header where the OSTCB.....   are defined? 

 

I take this in not an 8 bit AVR your talking about?

Jim

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior wrote:
Could someone suggest something to try?

Sure.  Try telling us which processor brand/model is the target of this incantation.  And, of course, try telling us the full context including the definition of all the offending parameters.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi freaks, don't be shouting at me now but the target is the asma5d4 coolAnyways, its a comiler question and someone might know how to solve the error.  smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior wrote:
don't be shouting at me now but the target is the asma5d4

Google gives no pertinent  results for "asma5d4".  So your answer doesn't help much, does it?

 

Who is yelling? 

Fianawarrior wrote:
Anyways, its a comiler question

But this section of the site is for AVR8 and similar models.  Those compilers won't generate a MOV32 instruction.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
Did you include the header where the OSTCB..... are defined?

Still hasn't; even after the "helpful" response.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So I put "mov32 r0" into a Google search. Guess what information I got in the first two hits?  Sample:

You are using gnu assembler with arm assembler pseudo instructions.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This works!!!

 

__attribute__((naked))static void context (void){

	__asm__ __volatile__(

			"MOV   R0, %[tcb_current]\n\t"
		    "MOV   R1, %[tcb_new]\n\t"
		    "LDR     R2, [R1]\n\t"
		    "STR     R2, [R0]\n\t"

		    "LDR     SP, [R2]\n\t"

		    "LDMFD   SP!, {R0}\n\t"
		    "MSR     SPSR_cxsf, R0\n\t"

		    "LDMFD   SP!, {R0-R12, LR, PC}" :: [tcb_current] "r" (&OSTCBCur), [tcb_new] "r" (&OSTCBHighRdy));
}