avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Assembly language help


From: Erik Christiansen
Subject: Re: [avr-gcc-list] Assembly language help
Date: Tue, 31 Jul 2007 12:58:04 +1000
User-agent: Mutt/1.5.9i

On Mon, Jul 30, 2007 at 08:00:26AM -0700, Gre7g Luterman wrote:
> Oh, man!  I had no idea these even existed.  Is there
> a list somewhere of neat stuff like this?

Ah, errr ..., my local copy of the info page is outdated, but there is a
good description of the other modifiers here:

http://opensource.cqu.edu.au/cgi-bin/info/info2html.cgi?(as.info)AVR-Modifiers

> The tricks I do know seem to be cobbled from code scraps and not
> assembled in any systematic way.

Few are interested in writing complete assembler programs on the AVR, it
seems, though there is some use of gcc's "in-line" assembler.

Further to the original addressing topic, it can be a little tedious to
fiddle manually with parts of addresses, so I whacked a few elementary
macros together a few years ago, including:

; Data Pointer initialisation of a register pair.
; Usage: dptr Y,some_data
;        ld    r16,Y               ; OR lpm r16,Y if some_data is in flash.

   .macro dptr reg,addr
   ldi   \reg,lo8(\addr)
   ldi   \reg + 1,hi8(\addr)
   .endm

; Program Pointer initialisation of a register pair.
; Usage: pptr  Z,program_address
;        icall

   .macro pptr reg, addr
   ldi   \reg, pm_lo8(\addr)       ; Does byte_address/2.
   ldi   \reg + 1, pm_hi8(\addr)
   .endm

It's so much more readable when the code shows _what_ rather than _how_.

> Hell, I only learned about using labels like 1f and 1b just the other
> week! Sheesh.  Wish I had seen that one earlier too.

Local symbol names are in "info as", so perhaps you weren't really
really desperately in need of them before? ;-)

Hope some of the above is useful.

Erik




reply via email to

[Prev in Thread] Current Thread [Next in Thread]