Searching \ for 'PCL related puzzle ;-)' 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/index.htm?key=pcl+related+puzzle
Search entire site for: 'PCL related puzzle ;-)'.

Truncated match.
PICList Thread
'PCL related puzzle ;-)'
1998\08\25@062821 by Dmitry Kiryashov

flavicon
face
Greetings All.

What will happen after the following set of commands will be executed ?
;-)

       org     xx0

       decfsz  pcl,f
       cmd_1                   ;next cmd
       cmd_2                   ;etc.

pclath is properly set to xx0 page.

WBR Dmitry.

1998\08\25@104615 by Mike Keitz

picon face
On Tue, 25 Aug 1998 14:23:58 +0400 Dmitry Kiryashov <spam_OUTzewsTakeThisOuTspamAHA.RU> writes:

>What will happen after the following set of commands will be executed ?
>
>        org     xx0
>
>        decfsz  pcl,f
>        cmd_1                   ;next cmd
>        cmd_2                   ;etc.
>

I doubt the PIC's skip logic is complex enough to "properly" handle the
situation of a modify PCL also causing a skip.  The modify PCL would
trigger a skip (of cmd_1) by itself, then the decfsz instruction would be
fetched again.  The decfsz instruction will repeatedly execute in an
infinite loop.

If the logic is designed to skip the re-fetched decfsz instruction, then
cmd_1 would be executed.  But that's a long shot, such "delayed skip"
logic would only act in this case so it wouldn't make much sense to build
it into every PIC.

_____________________________________________________________________
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\25@104806 by Ray Gardiner

flavicon
face
At 02:23 PM 8/25/98 +0400, you wrote:
>Greetings All.
>
>What will happen after the following set of commands will be executed ?
>;-)
>
>        org     xx0
>
>        decfsz  pcl,f
>        cmd_1                   ;next cmd
>        cmd_2                   ;etc.
>
>pclath is properly set to xx0 page.
>
>WBR Dmitry.
>

       Nice!... The program counter decrements and then skips, forcing nop
       and you are back where you started!.... Weird Stuff.


Ray Gardiner .....rayKILLspamspam@spam@hdc.com.au

To UnSubscribe: Send an email (from the account you used to subscribe)
To: LISTSERVspamKILLspamMITVMA.MIT.EDU with SIGNOFF PICLIST in the BODY of the message.

1998\08\25@110927 by Ray Gardiner

flavicon
face
At 10:31 AM 8/25/98 -0400, Mike Keitz wrote:
<snip>
>I doubt the PIC's skip logic is complex enough to "properly" handle the
>situation of a modify PCL also causing a skip.  The modify PCL would
>trigger a skip (of cmd_1) by itself, then the decfsz instruction would be
>fetched again.  The decfsz instruction will repeatedly execute in an
>infinite loop.
>
>If the logic is designed to skip the re-fetched decfsz instruction, then
>cmd_1 would be executed.  But that's a long shot, such "delayed skip"
>logic would only act in this case so it wouldn't make much sense to build
>it into every PIC.
>

You are correct, here is the code and emulator trace, it's 16C57, but that's
what is in the emulator at present, I suspect other pics would be the same.

list P = 16C57
include "c:\mplab\p16c5x.inc"

;
;  Dmitry's Puzzle
;

Reset   org     0

       decfsz  PCL,f
       cmd_1   nop             ;next cmd
       cmd_2   nop             ;etc.

       org  0x7FF
goto    Reset
end

Here is the trace output.

0000  02E2  Reset   decfsz 0x2                            (00000000)
0001  0000  (Extra Cycle: Forced NOP)
0000  02E2  Reset   decfsz 0x2                            (00000000)
0001  0000  (Extra Cycle: Forced NOP)
0000  02E2  Reset   decfsz 0x2                            (00000000)
0001  0000  (Extra Cycle: Forced NOP)
0000  02E2  Reset   decfsz 0x2                            (00000000)
0001  0000  (Extra Cycle: Forced NOP)
0000  02E2  Reset   decfsz 0x2                            (00000000)
0001  0000  (Extra Cycle: Forced NOP)
0000  02E2  Reset   decfsz 0x2                            (00000000)
0001  0000  (Extra Cycle: Forced NOP)
0000  02E2  Reset   decfsz 0x2

What is happening, is the program counter has pre-incremented but
forces a NOP to execute since the skip is taken, and then re-executes the
same instruction.

Ray Gardiner .....rayKILLspamspam.....hdc.com.au

To UnSubscribe: Send an email (from the account you used to subscribe)
To: EraseMELISTSERVspam_OUTspamTakeThisOuTMITVMA.MIT.EDU with SIGNOFF PICLIST in the BODY of the message.

1998\08\26@003612 by Dmitry Kiryashov

flavicon
face
Hello Mike.

Seems to be skip_if_Zero logic is fault in case of decfsz PCL,f
command in example I was offer to discussion.

WBR Dmitry.

{Quote hidden}

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