Divide symbol address by two at assembly time?

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

How do I accomplish this without having to do the lsr/ror at run-time?

    ldi r26,lo8(here)
    ldi r27,hi8(here)
    lsr r27
    ror r26
    push r26
    push r27
    ret
here:

I've tried dividing the symbol by two but neither divide-by-two approach works:

    ldi r26,lo8(here>>1) ; error
    ldi r27,hi8(here/2) ; error
    push r26
    push r27
    ret
here:

(and what's up with the return address being big-endian on the stack? It's inconsistent with how the X/Y/Z addresses are stored little-endian in memory)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
    ldi r26,lo8(pm(here))
    ldi r27,hi8(pm(here)) 

Stefan Ernst

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

Quote:
(and what's up with the return address being big-endian on the stack? It's inconsistent with how the X/Y/Z addresses are stored little-endian in memory)
Probably because stack is top down being pushed one byte at a time.

Regards,
Steve A.

The Board helps those that help themselves.

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

sternst wrote:

    ldi r26,lo8(pm(here))
    ldi r27,hi8(pm(here)) 


Also as

    
    ldi r26,pm_lo8(here)
    ldi r27,pm_hi8(here) 

http://sourceware.org/binutils/d...

(There is also a related - and in the linked gas manual still undocumented - gs() operator, meaning "generate stubs", which is used by the compiler instead of pm() when compiling for >128kB devices)

JW