[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] ijmp usage
From: |
Christian Ludlam |
Subject: |
Re: [avr-gcc-list] ijmp usage |
Date: |
Fri, 20 Dec 2002 13:23:47 +0000 |
User-agent: |
POPstar/2.02 |
On 20 Dec Steve Joiner wrote:
> Ok, dumb question time. I'm writing a routine in assembly for the atmega8.
> I've got some code that looks like this:
> ldi ZL,lo8(foo)
> ldi ZH,hi8(foo)
> ijmp
> Unfortunately, it doesn't seem to be doing what I want (which would be
> to jump to foo). If I replace that code, with this code:
> ldi ZL,lo8(foo)
> ldi ZH,hi8(foo)
> rjmp foo
> It works fine. (I know the two ldi's don't do anything, but I left
> them there to verify that I wasn't trashing some values in Z that I
> needed later).
> I must be interpreting something wrong -- I would think both versions
> should do the same thing. Can someone give me a clue as to what I'm
> doing wrong?
A guess: ijmp and the PC work with word addresses, whereas the label has a
byte address, so you need to divide it by 2.
ldi ZL,lo8(foo) >> 1
ldi ZH,hi8(foo) >> 1
ijmp
HTH,
--
Christian Ludlam
address@hidden
avr-gcc-list at http://avr1.org