Searching \ for ' [PIC] Subtract 16-bit number by 1' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Subtract 16-bit number by 1'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] [PIC] Subtract 16-bit number by 1'
2002\06\01@150653 by Thomas N

picon face
Hi all

Is there an easy way to subtract 16-bit number by 1?  How?
Thanks!
Thomas

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\06\01@154814 by mike

flavicon
face
movlw -1
addwf lobyte
skpc
decf hibyte

On Sat, 1 Jun 2002 10:12:51 -0700, you wrote:

>Hi all
>
>Is there an easy way to subtract 16-bit number by 1?  How?
>Thanks!
>Thomas

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\06\01@155024 by M. Adam Davis

flavicon
face
Four instructions:

MOVF lowbyte, W
BTFSC zeroflag
DECF highbyte, F
DECF lowbyte, F

-Adam

Thomas N wrote:

{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\06\01@164414 by mike

flavicon
face
On Sat, 1 Jun 2002 15:18:35 -0400, you wrote:

>Four instructions:
>
>MOVF lowbyte, W
..should be MOVF lowbyte,F - that way you don't overwrite W
{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\06\01@171437 by M. Adam Davis

flavicon
face
This can be reduced by one instruction if you're using an 18 series
processor:

TSTFSZ lowbyte
DECF highbyte, F
DECF lowbyte, F

-Adam

Mike Harrison wrote:

{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...