Yahoo Groups archive

AVR-Chat

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

Message

Re: ASM 32-bit division routine?

2008-07-29 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "Enki" <enkitec@...> wrote:
>I just deleted the mod2 and mod3 lines to transform your routine to 
> 32bit/16bit.
Presumably, you adjusted the PC-relative addresses given with the
branch instructions, too.  A less error-prone method is to introduce
labels to use for the branch destinations thus letting the assembler
figure out the branch distance.  I've been bitten more than once when
using PC-relative addresses by adding instructions between the branch
and destination and forgetting to adjust the offset.  The downside, of
course, is that you have to invent a label name.

The Atmel AVR Assembler documentation seems to suggest that a label
must be on a line preceding a directive, instruction, etc.  However,
it does accept a label on a line by itself which is, I think, the
preferable alternative.

As a side note, the gcc assembler supports the use of numeric labels
(like 2:) and then allows you to refer to them using, for example, 2f
and 2b to refer to the first 2: forward and the first 2: backward. 
This precludes the need to invent a label name and it is also useful
in macros that are used multiple times, avoiding problems with
duplicate label names.

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

Attachments

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.