Error in .lss file?

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

Hi,
I use Winavr + Avrstudio
My program compiled without warning and works well.
But in .lss file I found line "brne .+92".
Relative branch should be max +64. What is wrong?

    394a:	5c 01       	movw	r10, r24
    394c:	6a 01       	movw	r12, r20
    394e:	65 34       	cpi	r22, 0x45	; 69
    3950:	71 f5       	brne	.+92     	; 0x39ae 
    3952:	00 e0       	ldi	r16, 0x00	; 0
    3954:	10 e0       	ldi	r17, 0x00	; 0
    3956:	08 c0       	rjmp	.+16     	; 0x3968 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The opcode manual says the bit pattern for BRNE is

1111 01kk kkkk k001

So the 71 F5 in there is really F5 71 and the bits are

1111 0101 0111 0001

so k is 0101110. So the offset is actually 46. Which just happens to be 96 divided by 2.

So surely this is just a question of byte/word interpretation. Remember that in the code space Atmel always talk in terms of words. So in that opcode an offset of 46 means 46 words.

Meanwhile GCC (because it's architecture agnostic and must be as generic as possible) does everything in terms of bytes. 46 words ARE 96 bytes.

Notice also the address labels in that, for example 394a:, 394c:, 394e: - for each one word opcode location they are increasing by 2 each time as this is byte addressing.

So there's nothing to worry about here.

Cliff

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

Hi Cliff,
Now it is clear.
Thanks for explanation.

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

Quote:

46 words ARE 96 bytes.

Quote:

Now it is clear.

(Must be British units of measurement that I am not familiar with.)

Lee

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 Lee,
I think all in the world need not be american.
Allow us a little Euromath.

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

Quote:

Allow us a little Euromath.

???

Quote:

So the offset is actually 46. Which just happens to be 96 divided by 2.

:twisted:

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

Visovian,

The point Lee is making is my typo where I mistyped 96 rather than 92

Cliff

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

Hi,
Of course I noticed the little mistake. My post about Euromath should have been only a joke. Sorry if it was wrong understood.

Visovian