help with asm and a global var.

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

I didn't think this was going to be as tricky as its is for me. But I just want to set a variable to zero.

I have it declared in my S files as .extern rejected

ans tried a few things but ca not set it to 0..

my last try.

ldi r25, 0;
STS rejected,R25
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What address is rejected?

RES

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

If you used the Atmel assembler things would be easier.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Quote:

ca not set it to 0

What value does it end up with? 4? 17? -3?

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

It would seem I'm missing something here.

I have a var declared in my header as
volatile char rejected;

in my C files I use it as a normal global var and access it via rejected
I set it = to 1

Then in my S file I want to change it to 0, if a condition occurs.

So I declare in my S as
.extern rejected

Now I'm guessing what I'm missing is I need to get its address, or somehow assign it to a register. This is where I must be failing.

How do I get the address of a variable?

Quote:
What value does it end up with? 4? 17? -3?
It does not change.

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

What assembly sourcecode are you trying to use in that "S" file of yours? Should be something like this:

   ldi r16, 0
   sts rejected, r16 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Levenkay wrote:
What assembly sourcecode are you trying to use in that "S" file of yours? Should be something like this:
   ldi r16, 0
   sts rejected, r16 

OH? So I did have it right?

in my case

Quote:
ldi r25, 0;
STS rejected,r25

Thx, just not seeing "rejected" changing once I'm out of the asm. Must me some other error.

Update: ok I see why(something unrelated), thx for the help.