Searching \ for '3 byte decrement' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=byte+decrement
Search entire site for: '3 byte decrement'.

Truncated match.
PICList Thread
'3 byte decrement'
1998\08\12@123532 by Bob Blick

face
flavicon
face
Hi Everyone,

Usually I don't pay any attention to optimizing code, if it works I use
it, but this morning I'm feeling picky. No where in my notes do I have a
decrement for more than a 2 byte number. I want 3 bytes. This is what I
came up with. It looks stupid to me. Feel free to come up with something
better.  It's for midrange pics and does not use any temporary registers.

movlw 1
subwf low,f
movlw 0
SKPC
movlw 1
subwf mid,f
SKPC
decf hi,f

Any improvements on this?

Thanks,
Bob

1998\08\12@130853 by Andrew Warren

face
flavicon
face
Bob Blick <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> No where in my notes do I have a decrement for more than a 2 byte
> number. I want 3 bytes. This is what I came up with. It looks
> stupid to me. Feel free to come up with something better.  It's for
> midrange pics and does not use any temporary registers.
>
> movlw 1
> subwf low,f
> movlw 0
> SKPC
> movlw 1
> subwf mid,f
> SKPC
> decf hi,f
>
> Any improvements on this?

Bob:

Without having performed any testing on it, I think this one
will work... It saves a byte over yours, looks cleaner, and
works on all PICs:

   DECF    HI
   DECF    MID
   DECF    LO

   INCFSZ  LO,W
   INCF    MID

   INCFSZ  MID,W
   INCF    HI

-Andy


=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1998\08\12@132520 by Chip Weller

flavicon
face
Bob Blick wrote:

|Hi Everyone,
|
|Usually I don't pay any attention to optimizing code, if it works I use
|it, but this morning I'm feeling picky. No where in my notes do I have
a
|decrement for more than a 2 byte number. I want 3 bytes. This is what I
|came up with. It looks stupid to me. Feel free to come up with
something
|better.  It's for midrange pics and does not use any temporary
registers.
|
|movlw 1
|subwf low,f
|movlw 0
|SKPC
|movlw 1
|subwf mid,f
|SKPC
|decf hi,f
|
|Any improvements on this?
|
|Thanks,
|Bob

A simple improvement is to use the 1 which is already loaded in W to
eliminate the second "movlw 1" instruction:

movlw 1
subwf low,f
SKPNC
movlw 0
subwf mid,f
SKPC
decf hi,f

Another alternative which cost 1 more ROM word and 1 extra cycle worst
case, but saves 2 clocks 255/256 times, and does not modify W register
would be:
   movf Low,f
   bnz X
   movf Mid,f
   skpnz
       decf High,f
   decf Mid,f
X   decf Low,f

Chip Weller

1998\08\12@134158 by Jim Ham

flavicon
face
Bob,

This is how I've done it. Average time is less, but it's not consistant if
you've got it in a timing loop.

decf    low, F
incfsz  low, W
goto    end:
decf    mid, F
incfsz  mid, W
goto    end:
decf      high, F
end:

Regards, Jim Ham


At 09:26 AM 8/12/98 +0000, you wrote:
{Quote hidden}

Jim Ham, Porcine Associates
(415)326-2669 fax(415)326-1071
"http://www.porcine.com"

1998\08\12@134412 by Chip Weller

flavicon
face
Andrew Warren wrote:


Bob Blick <PICLISTspamKILLspamMITVMA.MIT.EDU> wrote:

{Quote hidden}

Bob:

Without having performed any testing on it, I think this one
will work... It saves a byte over yours, looks cleaner, and
works on all PICs:

   DECF    HI
   DECF    MID
   DECF    LO

   INCFSZ  LO,W
   INCF    MID

   INCFSZ  MID,W
   INCF    HI

-Andy


Test case 0x00FF00 appears to produce 0xFFFFFF. Problem is the test for
MID reaching 0xFF does not depend on LO underflowing first.

Chip Weller

1998\08\12@141345 by Fehrenbach, Robert J

flavicon
face
Yet another way:

  decf    lo, f
  incf    lo, w
  bnz     exit
  decf    mid f
  incf    mid, w
  bnz     exit
  decf    hi, f
exit:

1998\08\12@141811 by Andrew Warren

face
flavicon
face
I wrote:

>     DECF    HI
>     DECF    MID
>     DECF    LO
>
>     INCFSZ  LO,W
>     INCF    MID
>
>     INCFSZ  MID,W
>     INCF    HI

and Chip Weller <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU> replied:

> Test case 0x00FF00 appears to produce 0xFFFFFF. Problem is the test for
> MID reaching 0xFF does not depend on LO underflowing first.

   I think it works correctly in that case, Chip:

                       ;HI MD LO
                       ;
                       ;00 FF 00
       DECF    HI      ;FF FF 00
       DECF    MID     ;FF FE 00
       DECF    LO      ;FF FE FF

       INCFSZ  LO,W    ;FF FE FF    W = 0
       INCF    MID     ;FF FE FF    -- SKIPPED --

       INCFSZ  MID,W   ;FF FE FF    W = FF
       INCF    HI      ;00 FE FF

   Of course, I could always be wrong... Do you see an error in the
   comments I've added?

   -Andy


=== Andrew Warren - EraseMEfastfwdspam_OUTspamTakeThisOuTix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1998\08\12@151133 by Chip Weller

flavicon
face
Andy:

Opps. I should have said a test case of 0x00FFxx where xx is anything
but 00. Using 0x00FF01 and your outline:

                       ;HI MD LO
                       ;
                       ;00 FF 01
       DECF    HI      ;FF FF 01
       DECF    MID     ;FF FE 01
       DECF    LO      ;FF FE 00

       INCFSZ  LO,W    ;FF FE 00    W = 01
       INCF    MID     ;FF FF FF    MID = 0xFF, so far so good.

       INCFSZ  MID,W   ;FF FF FF    W = 00, thinks overflow occured.
       INCF    HI      ;01 FF FF    result off by 0x010000 now.

Chip

1998\08\12@152810 by Andrew Warren

face
flavicon
face
Chip Weller <PICLISTspamspam_OUTMITVMA.MIT.EDU> wrote:

> I should have said a test case of 0x00FFxx where xx is anything but
> 00. Using 0x00FF01 and your outline:
> ....
> result off by 0x010000

   You're correct, Chip... Thanks for catching the error.

   Bob:  Please ignore my "solution".

   -Andy


=== Andrew Warren - @spam@fastfwdKILLspamspamix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1998\08\12@153829 by Chip Weller

flavicon
face
I wrote:


>Andy:
>
>Opps. I should have said a test case of 0x00FFxx where xx is anything
>but 00. Using 0x00FF01 and your outline:
>
>                        ;HI MD LO
>                        ;
>                        ;00 FF 01
>        DECF    HI      ;FF FF 01
>        DECF    MID     ;FF FE 01
>        DECF    LO      ;FF FE 00
>
>        INCFSZ  LO,W    ;FF FE 00    W = 01
>        INCF    MID     ;FF FF FF    MID = 0xFF, so far so good.
>
>        INCFSZ  MID,W   ;FF FF FF    W = 00, thinks overflow occured.
>        INCF    HI      ;01 FF FF    result off by 0x010000 now.
>
>Chip

I messed up the last few lines, I seem to be a bit tired today:
       INCFSZ LO,W    ; FF FE 00    W = 01
       INCF   MID     ; FF FF 00    (I mess-up last byte.)
       INCFSZ MID,W   ; FF FF 00    W = 00, so thinks overflow
occurred.
       INCF   HI      ; FF FF 00    This instruction is skipped.
The results are off by 0x010000, but in the other direction. Sorry about
any confusion.

Chip.

1998\08\12@160144 by Dmitry Kiryashov

flavicon
face
Hello Bob.

> Hi Everyone,
>
> Usually I don't pay any attention to optimizing code, if it works I use
> it, but this morning I'm feeling picky. No where in my notes do I have a
> decrement for more than a 2 byte number. I want 3 bytes. This is what I
> came up with. It looks stupid to me. Feel free to come up with something
> better.  It's for midrange pics and does not use any temporary registers.
>
> movlw 1
> subwf low,f
> movlw 0
> SKPC
> movlw 1
> subwf mid,f
> SKPC
> decf hi,f
>
> Any improvements on this?


       movlw   1
       subwf   low,f
       skpc
       subwf   mid,f
       skpc
       subwf   hi,f

WBR Dmitry.

1998\08\12@175208 by Bob Blick

face
flavicon
face
Thanks to Andy, Chip, Jim, Bob and Dimitry!

It is amazing how many ways there are to skin a cat, some of them more
obvious than others. I wonder why Microchip didn't make the decf
instruction set/clear the carry flag? That would have saved a bit of time.

Cheers,

Bob

1998\08\12@175625 by Mike Keitz

picon face
On Wed, 12 Aug 1998 09:26:43 +0000 Bob Blick <KILLspambobKILLspamspamted.net> writes:
> Feel free to come up with something better.

What's wrong with just:
       movlw   -1
       addwf   low,f
       skpc
       addwf   mid,f
       skpc
       addwf   high,f

If a byte was zero before decrementing, adding -1 (0xFF) will leave the
byte at FF and produce no carry, indicating a decrement of the next
higher byte is required.  If the C flag is clear at the end of this
routine, that indicates that the 3-byte value has just rolled under to
FF...FF.  Of course the technique can be expanded to any number of bytes
just by adding more skpc/add instructions.



_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

1998\08\13@042528 by Ivan Cenov

flavicon
face
hi,
this macro is 8 instructions long as yours, so
no improvements in it; another way to do same

variable sbl=0

; decrement three-byte value (low byte at low address)
decf3 macro var
   decf var,F
   incf var,W
   btfss STATUS,Z
   goto _sbl#v(sbl)
   decf var+1,F
   incf var+1,W
   btfsc STATUS,Z
   decf var+2,F
_sbl#v(sbl):
sbl = sbl+1
endm


i tried to extend it to 4-byte decrement and here is it:

; decrement four-byte value
decf4 macro var
decf var,F
incf var,W
btfss STATUS,Z
goto _sbl#v(sbl)
decf var+1,F
incf var+1,W
btfss STATUS,Z
goto _sbl#v(sbl)
decf var+2,F
incf var+2,W
btfsc STATUS,Z
decf var+3,F
_sbl#v(sbl):
sbl = sbl+1
endm

so, four instructions per byte should be added.

Ivan Cenov
RemoveMEokto7TakeThisOuTspambotev.ttm.bg
www.geocities.com/SiliconValley/Network/9276/
Do what have to do, let happens what it wants.

{Original Message removed}

1998\08\13@043842 by Stuart Allen

flavicon
face
Ivan Cenov wrote:
> hi,
> this macro is 8 instructions long as yours, so
> no improvements in it; another way to do same
>
> variable sbl=0
>
> ; decrement three-byte value (low byte at low address)
> decf3 macro var
>     decf var,F
>     incf var,W
>     btfss STATUS,Z
>     goto _sbl#v(sbl)
>     decf var+1,F
>     incf var+1,W
>     btfsc STATUS,Z
>     decf var+2,F
> _sbl#v(sbl):
> sbl = sbl+1
> endm

As a side note:

I thought that you could declare a macro label as local thus avoiding the
above #v complications? I have never tried this:

decf3 macro var

       local   enddecf3

       decf    var,F
       incf    var,W
       btfss STATUS,Z
       goto    enddecf3
       decf    var+1,F
       incf    var+1,W
       btfsc STATUS,Z
       decf    var+2,F

enddecf3:

endm

Is this right?


Stuart.

1998\08\13@061820 by Ivan Cenov

flavicon
face
{Quote hidden}

i just tried this and it works.
i thought that the local is for valiable and not for label
but it really works.
btw, it is possible to change
   incf    var,W
   btfss    status,z
   goto     enddecf3
to
   incfsz    var,W
   goto    enddecf3
and save one instruction.

; decrement three-byte value
decf3 macro var
decf var,F
incfsz var,W
goto _sbl#v(sbl)
decf var+1,F
incf var+1,W
btfsc STATUS,Z
decf var+2,F
_sbl#v(sbl):
sbl = sbl+1
endm

; decrement four-byte value
decf4 macro var
decf var,F
incfsz var,W
goto _sbl#v(sbl)
decf var+1,F
incfsz var+1,W
goto _sbl#v(sbl)
decf var+2,F
incf var+2,W
btfsc STATUS,Z
decf var+3,F
_sbl#v(sbl):
sbl = sbl+1
endm


Ivan Cenov
spamBeGoneokto7spamBeGonespambotev.ttm.bg
www.geocities.com/SiliconValley/Network/9276/
Do what have to do, let happens what it wants.

1998\08\13@121809 by Peter L. Peres

picon face
> better

decf    mid, F
decf    mid, F
decfsz  low, F
 incf  mid, F
incfsz  mid, F
 decf  high, F

6 T cycles, 6 words run time (constant), and no changes in W ;). I think
it's optimal.

Peter

1998\08\13@124509 by Bob Blick

face
flavicon
face
Hi Peter,

I think you win all around!

Thanks,
Bob


On Thu, 13 Aug 1998, Peter L. Peres wrote:>
> decf    mid, F
> decf    mid, F
> decfsz  low, F
>   incf  mid, F
> incfsz  mid, F
>   decf  high, F
>
> 6 T cycles, 6 words run time (constant), and no changes in W ;). I think
> it's optimal.

1998\08\13@132201 by Claudio Rachiele IW0DZG

flavicon
face
                  Status Distribution August 12, 1998 16:54:47

The message regarding "3 byte decrement" sent on August 12, 1998 16:54:47 was sent by

Status Recipient
         Type                To
         Native Name         TakeThisOuTPICLISTEraseMEspamspam_OUTMITVMA.MIT.EDU
         Foreign Native Name RemoveMEPICLISTspamTakeThisOuTMITVMA.MIT.EDU\n\n\nINTERNET



Recipients

Status Reporters
         Type                From
         Initials            CR
         Name Domain         NOTES
         Native Name         CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM@IBMIT
         Foreign Native Name CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM\nIBMIT\n\n
         Organization        IBM
         Org Unit 1          Italy
         Last Name           IW0DZG
         First Name          Claudio



Status          769
Explanation     Invalid recipient

X.400 Status    769
Explanation     Router: Unable to open mailbox file D14HUBM1/14/H/IBM mail.box: Remote system no longer responding

1998\08\13@132206 by Claudio Rachiele IW0DZG

flavicon
face
                  Status Distribution August 12, 1998 17:04:30

The message regarding "Re: 3 byte decrement" sent on August 12, 1998 17:04:30 was sent by

Status Recipient
         Type                To
         Native Name         PICLISTEraseMEspam.....MITVMA.MIT.EDU
         Foreign Native Name EraseMEPICLISTspamMITVMA.MIT.EDU\n\n\nINTERNET



Recipients

Status Reporters
         Type                From
         Initials            CR
         Name Domain         NOTES
         Native Name         CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM@IBMIT
         Foreign Native Name CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM\nIBMIT\n\n
         Organization        IBM
         Org Unit 1          Italy
         Last Name           IW0DZG
         First Name          Claudio



Status          769
Explanation     Invalid recipient

X.400 Status    769
Explanation     Router: Unable to open mailbox file D14HUBM1/14/H/IBM mail.box: Remote system no longer responding

1998\08\13@133107 by Fehrenbach, Robert J

flavicon
face
From:
        "Peter L. Peres" <RemoveMEplpEraseMEspamEraseMEACTCOM.CO.IL>

                                  high  mid  low
                                      ff    ff      01  - 1  =  ff  ff
00

  decf    mid, F               ff    fe     01
  decf    mid, F               ff    fd     01
  decfsz  low, F              ff    fd    00
  incf    mid, F                    skip
  incfsz  mid, F               ff    fe    00
  decf    high, F              fe    fe    00  !

Am I missing something here?

1998\08\13@141618 by AES_SULL-VISITA2

flavicon
face
Why don«t we go back to elementary math:

Starting with HIGH MID LOW, we would have:

LOW = LOW - 1
IF LOW < 0 THEN LOW = &HFF   MID=MID - 1
IF MID < 0 THEN HIGH = HIGH - 1

I«m just starting with PIC programming but it seems easy to convert this to
PIC commands.

Felipe Kwiecinski Fernandez
IBM Brasil - Filial Porto Alegre

{Quote hidden}

1998\08\13@142854 by ray

flavicon
face
;
; 24 bit decrement
;                               ; test 1     test2
;                               ;            underflow from zero
;
       MOVF    HIGH,W          ; FF FF 01   00 00 00
       SKPNZ                   ;
       DECF    HIGH,F          ; skip       FF 00 00
       MOVF    MID,W           ;
       SKPNZ                   ;
       DECF    MID,F           ; skip       FF FF 00
       DECF    LOW,F           ; FF FF 00   FF FF FF

;       7 cycles, uses W,
;

Sorry if this solution has already been posted, I have been
otherwise occupied!

--
Ray Gardiner RemoveMErayKILLspamspamhdc.com.au

1998\08\13@143645 by Claudio Rachiele IW0DZG

flavicon
face
                  Status Distribution August 12, 1998 18:13:42

The message regarding "Re: 3 byte decrement" sent on August 12, 1998 18:13:42 was sent by

Status Recipient
         Type                To
         Native Name         PICLISTSTOPspamspamspam_OUTMITVMA.MIT.EDU
         Foreign Native Name spamBeGonePICLISTSTOPspamspamEraseMEMITVMA.MIT.EDU\n\n\nINTERNET



Recipients

Status Reporters
         Type                From
         Initials            CR
         Name Domain         NOTES
         Native Name         CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM@IBMIT
         Foreign Native Name CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM\nIBMIT\n\n
         Organization        IBM
         Org Unit 1          Italy
         Last Name           IW0DZG
         First Name          Claudio



Status          769
Explanation     Invalid recipient

X.400 Status    769
Explanation     Router: Unable to open mailbox file D14HUBM1/14/H/IBM mail.box: Remote system no longer responding

1998\08\13@144655 by ray

flavicon
face
Whoops!, forgot about testing for 00 XX XX before
decrementing HIGH....

;
; 24 bit decrement Version 2
;
;                               ; test 1     test2
;                               ;            underflow from zero
;
       MOVF    HIGH,W          ; FF FF 01   00 00 00
       IORWF   MID,W           ; *** added ***
       SKPNZ                   ;
       DECF    HIGH,F          ; skip       FF 00 00
       MOVF    MID,W           ;
       SKPNZ                   ;
       DECF    MID,F           ; skip       FF FF 00
       DECF    LOW,F           ; FF FF 00   FF FF FF

;       8 cycles, uses W,
;

Ray Gardiner KILLspamrayspamBeGonespamhdc.com.au

1998\08\13@150141 by Chip Weller

flavicon
face
Hi,

Peter L. Peres wrote:


>> better
>
>decf    mid, F
>decf    mid, F
>decfsz  low, F
>  incf  mid, F
>incfsz  mid, F
>  decf  high, F
>
>6 T cycles, 6 words run time (constant), and no changes in W ;). I
think
>it's optimal.
>
>Peter

I like the pair of "decf" followed by an "incfsz", however this takes
the same time/space as a "movf X,f / skpz" combination.

This has several problem where it returns incorrect values. One problem
is the decfsz low,F will skip when low transfer from 1 to 0 not from 0
to FF. If access is well controlled this can be "fixed" by loading
values with 1 greater than target and reading the values with a "decf
X,w" instead of a "movf X,w". However this makes the value only useful
as a down counter.

Another problem is handling the borrow out of the mid byte. To be
sucessful  you must decrement high only if (low WAS 0 or BECOMES FF) AND
(mid WAS 0 or BECOMES FF). Any implementation which only tests mid to
determine if high should be decremented will fail when mid is FF and low
did not underflow.

There are some good ideas in this approach, I fiddled with it a bit but
did not come up with a low cost and correct version.

Chip Weller

1998\08\13@150601 by Peter L. Peres

picon face
> missing

Yes, I goofed. I have redone it, this time filling in all the details, and
it is 7 cycles (like other's), destroys W, and not optimal. It is still
untested:

       decf    M
       decf    L
       incfsz  L, W
         incf  M
       decf    H
       incfsz  M, W
         incf  H

But the method using subwfs is better and clearer, imho, they win 8) :

       movlw   1
       subwf   L, F
       btfss   PSW, CY
         subwf M, F
       btfss   PSW, CY
         subwf H, F
       ...

Peter

1998\08\13@151356 by er

flavicon
face
I wonder if each of us would take about a minute to send
10 copies of this directly back to Claudio Rachiele (directly)
and overload his machine, he might get the message?

-----Original Message-----
From:   Claudio Rachiele IW0DZG [SMTP:EraseME75805312spamEraseMEIT.IBM.COM]
Sent:   Thursday, August 13, 1998 2:21 PM
To:     @spam@PICLIST@spam@spamspam_OUTMITVMA.MIT.EDU
Subject:        Re: 3 byte decrement


                  Status Distribution August 12, 1998 18:13:42

The message regarding "Re: 3 byte decrement" sent on August 12, 1998 18:13:42 wa
s sent by
[snip]

1998\08\13@153835 by Claudio Rachiele IW0DZG

flavicon
face
                  Status Distribution August 12, 1998 19:07:10

The message regarding "Re: 3 byte decrement" sent on August 12, 1998 19:07:10 was sent by

Status Recipient
         Type                To
         Native Name         spamBeGonePICLISTspamKILLspamMITVMA.MIT.EDU
         Foreign Native Name .....PICLISTspam_OUTspamMITVMA.MIT.EDU\n\n\nINTERNET



Recipients

Status Reporters
         Type                From
         Initials            CR
         Name Domain         NOTES
         Native Name         CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM@IBMIT
         Foreign Native Name CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM\nIBMIT\n\n
         Organization        IBM
         Org Unit 1          Italy
         Last Name           IW0DZG
         First Name          Claudio



Status          769
Explanation     Invalid recipient

X.400 Status    769
Explanation     Router: Unable to open mailbox file D14HUBM1/14/H/IBM mail.box: Remote system no longer responding

1998\08\13@155925 by Alan King

picon face
Peter L. Peres wrote:
>
> > better
>
> decf    mid, F
> decf    mid, F
> decfsz  low, F   This test happens on LOW= 1 to 0, not 0 to FF.
>   incf  mid, F
> incfsz  mid, F
>   decf  high, F
>
> 6 T cycles, 6 words run time (constant), and no changes in W ;). I think
> it's optimal.
>
> Peter

 It should break there.  Also the mid test is it going back
up to zero, not ending on FF.  But giving me other ideas..

decf   low,f
incfsz low,f
decf   mid,f
decf   low,f
decf   mid,f
incfsz mid,f
decf   high,f
decf   mid,f

 Should work.  Move each down then up to test for zero and
modify next up before actual dec.  Still 8 cycles though..

1998\08\13@172920 by Mike Keitz

picon face
On Thu, 13 Aug 1998 13:20:00 -0400 "Fehrenbach, Robert J"
<TakeThisOuTFehreRJ.....spamTakeThisOuTCH.ETN.COM> writes:
>From:
>         "Peter L. Peres" <TakeThisOuTplpKILLspamspamspamACTCOM.CO.IL>
[...]
>   decf    high, F              fe    fe    00  !
>
>Am I missing something here?

No, you're not, Peter's routine doesn't work.  The 'decfsz' instruction
skips if the value is zero *after* decrementing.  To do a multi-byte
decrement, you need to test if the value is zero *before* decrementing,
or if its FF after.


_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

1998\08\13@182257 by Claudio Rachiele IW0DZG

flavicon
face
                  Status Distribution August 12, 1998 21:52:29

The message regarding "Re: 3 byte decrement" sent on August 12, 1998 21:52:29 was sent by

Status Recipient
         Type                To
         Native Name         .....PICLISTspamRemoveMEMITVMA.MIT.EDU
         Foreign Native Name RemoveMEPICLISTspamspamBeGoneMITVMA.MIT.EDU\n\n\nINTERNET



Recipients

Status Reporters
         Type                From
         Initials            CR
         Name Domain         NOTES
         Native Name         CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM@IBMIT
         Foreign Native Name CN=Claudio Rachiele IW0DZG/OU=Italy/O=IBM\nIBMIT\n\n
         Organization        IBM
         Org Unit 1          Italy
         Last Name           IW0DZG
         First Name          Claudio



Status          769
Explanation     Invalid recipient

X.400 Status    769
Explanation     Router: Unable to open mailbox file D14HUBM1/14/H/IBM mail.box: Server not responding

1998\08\13@183909 by Marc Heuler

flavicon
face
Hi Andrew (Andrew Warren), in <spamBeGone199808121817.NAA18650@spam@spamspam_OUTdfw-ix5.ix.netcom.com> on A
ug 12 you wrote:

>                         ;HI MD LO
>                         ;
>                         ;00 FF 00
>         DECF    HI      ;FF FF 00
>         DECF    MID     ;FF FE 00
>         DECF    LO      ;FF FE FF
>
>         INCFSZ  LO,W    ;FF FE FF    W = 0
>         INCF    MID     ;FF FE FF    -- SKIPPED --
>
>         INCFSZ  MID,W   ;FF FE FF    W = FF
>         INCF    HI      ;00 FE FF
>
>     Of course, I could always be wrong... Do you see an error in the
>     comments I've added?

No, but you've taken the wrong starting point.  The problem case is
0x00FF01:

                        ;HI MD LO
                        ;
                        ;00 FF 01
        DECF    HI      ;FF FF 01
        DECF    MID     ;FF FE 01
        DECF    LO      ;FF FE 00

        INCFSZ  LO,W    ;FF FE 00    W = 1
        INCF    MID     ;FF FF 00    not skipped

        INCFSZ  MID,W   ;FF FF 00    W = 00 <-- propagation problem
        INCF    HI      ;FF FF 00    skipped

1998\08\14@141158 by Dmitry Kiryashov

flavicon
face
Hello Chip. I think Andy was going to offer following:


       DECF    LOW,F
       INCFSZ  LOW,W
       INCF    MID,F

       DECF    MID,F
       INCFSZ  MID,W
       INCF    HI,F

       DECF    HI,F

;       ..etc... Carry was not chenged

WBR Dmitry.


Chip Weller wrote:
{Quote hidden}

1998\08\14@192634 by ray

flavicon
face
Whilst having lunch. (the 3 bite decrementing sandwich), and
pondering what in the world was I thinking when I reversed
the byte (bite) order for the 24 bit decrement code I posted
yesterday... here is the third bite..

;
; The starting point. 16 bit decrement
; 4 cycles doesn't use W and is isochronous
; thanks to Chip Weller for pointing out the TSTF macro
; which just does MOVF XXX,F, thus preserving W
;
       TSTF    LB16
       SKPNZ
       DECF    HB16,F
       DECF    LB16,F

Now how can this be extended to 24 bits cleanly?
;
; The straight forward extension to 24 bits would be
; something like this.. 5 cycles when LOW is non zero
; and 8 cycles when LOW is zero, and doesn't use W
;
       TSTF    LOW
       BNZ     lbnz
       TSTF  MID
       SKPNZ
       DECF    HIGH,F
       DECF    MID,F
lbnz    DECF    LOW,F

If you were just counting stuff, then 255 times out of 256 it
will take just 5 cycles. So I claim an average execution time of
   (5*255+8)/256 = 5.0117 cycles.... (just kidding)

Testing, the above code decrements monotonically for all the
case I have checked, however comments and bug reports are
always welcome.

And yes, I too think Dmitry's solution is the best!

Ray Gardiner TakeThisOuTrayspamspamhdc.com.a

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