Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Re: Saving PRR in assembler

Re: Saving PRR in assembler

2013-02-27 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, Philippe Habib <phabib@...> wrote:
> The mov instruction only seems to like "real" registers
> and the command mov r17,PRR does not work.
The PRR register is in the I/O space.  If the address is 0x31 or less, you can use the IN and OUT instructions; otherwise, you must use LDS and STS to read/write the register.  It is useful to use one of the macros that yields IN/OUT or LDS/STS depending on the port referenced - especially so if you're writing code to run on several different devices where a particular register is in the IN/OUT range on some devices but not so on others.

Often, it is instructive to write some C code for some particular functionality and then examine the code the compiler generates.  How one does that depends on which C compiler is being used.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

Re: Saving PRR in assembler

2013-02-27 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, Philippe Habib <phabib@...> wrote:
>PRR is at 0x64 according to the datasheet.
I should have mentioned that the LDS/STS method will work for any I/O address - those are 4-byte instructions.  In contrast, IN/OUT instructions are 2-byte so that's the motivation for using IN/OUT when possible.

You should be able to find a number of AVR assembly language tutorials in the Internet.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

Saving PRR in assembler

2013-02-27 by Philippe Habib

I've got some free time so I'm playing with the assembler.  I want to write an assembly function that will read the ADC and return the value.

The first thing I want to do is save the contents of the PRR so that I can restore it to where it was on exit.

The mov instruction only seems to like "real" registers and the command mov r17,PRR does not work.  I haven't found the right way to do this.  Can anyone offer a suggestion?

Thanks.

Re: [AVR-Chat] Re: Saving PRR in assembler

2013-02-27 by Philippe Habib

Thank you.  That's good to know about the address range.  PRR is at 0x64 according to the datasheet.
Show quoted textHide quoted text
----- Original Message -----
From: "Don Kinzer" <dkinzer@gmail.com>
To: AVR-Chat@yahoogroups.com
Sent: Wednesday, February 27, 2013 3:48:11 PM
Subject: [AVR-Chat] Re: Saving PRR in assembler

--- In AVR-Chat@yahoogroups.com, Philippe Habib <phabib@...> wrote:
> The mov instruction only seems to like "real" registers
> and the command mov r17,PRR does not work.
The PRR register is in the I/O space.  If the address is 0x31 or less, you can use the IN and OUT instructions; otherwise, you must use LDS and STS to read/write the register.  It is useful to use one of the macros that yields IN/OUT or LDS/STS depending on the port referenced - especially so if you're writing code to run on several different devices where a particular register is in the IN/OUT range on some devices but not so on others.

Often, it is instructive to write some C code for some particular functionality and then examine the code the compiler generates.  How one does that depends on which C compiler is being used.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net





------------------------------------

Yahoo! Groups Links

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.