Yahoo Groups archive

AVR-Chat

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

Thread

Re: ldi instruction failing

Re: ldi instruction failing

2007-10-02 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, enkitec@... wrote:
>But I don't think there's any mechanism to directly
>deal with a 32 bit value in the assembler.

Using the gnu assembler for 8-bit AVRs, 32-bit values are manipulated 
using hhi8 and hlo8 along with the better known hi8 and lo8 
operators.  For example,

ldi r16, lo8(256040)  ; = 0x28
ldi r17, hi8(256040)  ; = 0xE8
ldi r18, hlo8(256040) ; = 0x03
ldi r19, hhi8(256040) ; = 0x00

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

ldi instruction failing

2007-10-02 by Thomas Keller

Why would the following instruciton yield an "parameter out of range"
error in AVR-ASM?

ldi   R25,   256040

R25 is a 32 bit register, that should be a completely acceptable
instruction as I understand the instruction set manual.
any thoughts?

tom

Re: [AVR-Chat] ldi instruction failing

2007-10-02 by John Samperi

At 07:52 AM 3/10/2007, you wrote:
>R25 is a 32 bit register,

Since when? All registers are 8 bits.
You need to load R25 and then R26 with 8 bits.
Anyway 256040 is larger than 16 bits.



Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Email: john@ampertronics.com.au
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

Re: [AVR-Chat] ldi instruction failing

2007-10-02 by David VanHorn

On 10/2/07, Thomas Keller <tjkeller1@alltel.net> wrote:
>
> Why would the following instruciton yield an "parameter out of range"
> error in AVR-ASM?
>
> ldi   R25,   256040

R25 is an 8 bit register!

(as are ALL the registers..)

You need to load this in bytes.
A 16 bit value can be loaded like this:
ldi  R15,high(value)
ldi R16,low(value)

But I don't think there's any mechanism to directly deal with a 32 bit
value in the assembler.

Re: [AVR-Chat] ldi instruction failing

2007-10-02 by enkitec@gmail.com

When assembling with AVRASM32, you can write:

	ldi	r16, byte1(256040); = 0x28
	ldi	r17, byte2(256040); = 0xE8
	ldi	r18, byte3(256040); = 0x03


	Mark Jordan
Show quoted textHide quoted text
On 3 Oct 2007 at 8:00, John Samperi wrote:

> At 07:52 AM 3/10/2007, you wrote:
> >R25 is a 32 bit register,
> 
> Since when? All registers are 8 bits.
> You need to load R25 and then R26 with 8 bits.
> Anyway 256040 is larger than 16 bits.
> 
> 
> 
> Regards
> 
> John Samperi
> 
> ********************************************************
> Ampertronics Pty. Ltd.
> 11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
> Tel. (02) 9674-6495       Fax (02) 9674-8745
> Email: john@ampertronics.com.au
> Website  http://www.ampertronics.com.au
> *Electronic Design * Custom Products * Contract Assembly
> ********************************************************
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
>

Re: [AVR-Chat] ldi instruction failing

2007-10-02 by Thomas Keller

John:   ****DOH****    what the hell was I thinking?   Of  ***COURSE*** 
they're 8 bits!   
I've been spending too much time looking at AVR32 and MSC430 literature  
*heh*

I need to build a timing looop to test my firmware concepts for a new 
product, and I have to build
the timing loop manually, because Atmel hasn't got the timer/counters 
simulation in the ATtiny25 working
 yet.

  Which I find odd.   Since they have the timers/counters in the other 
ATtiny simulations, it makes little to
no sense that they can;t get them working in the ATtiny25.  Especially 
since the Timer/Counter1 in the
ATtiny25 has an ATtiny15 compatible mode.

I spent a month trying to figure out what I was doing wrong, before 
someone finally pointed out to me
that the timer/counters weren't supported in the simulator. I was 
beginning to believe I had lost my
programming and analysis skills entirely. *heh*

Thanks for yankign my head up out of the sand, John.,


tom
aka: avrFreak

Re: [AVR-Chat] ldi instruction failing

2007-10-02 by John Samperi

At 08:10 AM 3/10/2007, you wrote:

>         When assembling with AVRASM32, you can write:
>
>         ldi     r16, byte1(256040); = 0x28
>         ldi     r17, byte2(256040); = 0xE8
>         ldi     r18, byte3(256040); = 0x03

hmmm interesting, so how many registers can you fill that way?
I guess at least 4 for 32 bits. Perhaps this will carry over
to the 8 bits AVRs in the future.

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Email: john@ampertronics.com.au
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

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.