Yahoo Groups archive

AVR-Chat

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

Message

newbie absolute value

2005-01-02 by Geert De Pecker

Hi,

I have a question about abtaining the absolute value. I want to 
substract a 1 16bit values from eachother, but when the result is 
negative, set a bit and get the absolute value of the difference.

I thought of the following, but that doesn't seem to work:

...
   ldi direction, 0
; Substract values
   sub moveL, curPosL
   sbc moveH, curPosH
; If result positive, ok
   brcc PM1
; Result negative, take absolute value and set flag
   neg moveL
   neg moveH
   ldi direction, 1
PM1:

Any hints?

Regards and best wishes for 2005 to all,

Geert

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.