[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Align Data and RAM Gaps
From: |
Erik Christiansen |
Subject: |
Re: [avr-gcc-list] Align Data and RAM Gaps |
Date: |
Sat, 9 Aug 2014 18:39:26 +1000 |
User-agent: |
Mutt/1.5.21+145 (2a1c5d3dd72e) (2012-12-30) |
On 09.08.14 18:18, Erik Christiansen wrote:
>
> ldiw Z,buf
What, that's not an avr mnemonic? It is if you have this in a header
file:
; Data Pointer (or any word value) initialisation of a register pair.
; Usage: ldiw Y,some_data
; ld r16,Y ; OR lpm r16,Y if some_data is in flash.
; Avoids need for manual endianness perfection.
.macro ldiw reg,addr
ldi \reg,lo8(\addr)
ldi (\reg + 1),hi8(\addr)
.endm
And for completeness:
; Program Pointer (word address) initialisation of a register pair.
; Usage: pptr Z,program_address
; icall
.macro pptr reg, addr
ldi \reg, pm_lo8(\addr) ; Word addressed program memory.
ldi (\reg + 1), pm_hi8(\addr)
.endm
There's no reason why we should do word operations by hand, especially
with that lo8/pm_lo8 guff to increase the likelihood of human error.
Erik
--
Programs must be written for people to read, and only incidentally for
machines to execute. - Abelson and Sussman