Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Last Time NOP Brain Teaser
I'm sure we've all seen a "First Time NOP", typically:

NOP  SOMEWHER
OI      *-3,X'F0'

On first execution, the NOP falls through to the OI, which changes the NOP t
o a
B. On subsequent executions, it branches to SOMEWHER. Note that the code
doesn't test any condition or storage external to itself to "know" it's the
first time, nor is it modified by anything outside of itself. This code can 
be
used in any program, regardless of the specific application. (Let's ignore R
ENT
considerations for purposes of this discussion).

There's also the  FIRST TIME BRANCH:

NOP  *+12
OI      *-3,X'F0'
B       SOMEWHER

Where the branch to SOMEWHER occurs only the first time.


I want to see someone design a LAST TIME NOP (or branch). The rules are that
you can't "cheat" by testing any condition or storage external to the actual
code itself, nor can the code be modified by anything outside of itself. It
should be useable in any application (again, forget RENT stuff). The action
(NOP or BRANCH) can only be taken the LAST TIME the code is executed.




Report this thread to moderator Post Follow-up to this message
Old Post
RFCOMMSYS
03-20-04 01:28 AM


Re: Last Time NOP Brain Teaser
On 23 Nov 2003 18:50:33 GMT rfcommsys@aol.com (RFCOMMSYS) wrote:

:>I want to see someone design a LAST TIME NOP (or branch). The rules are th
at
:>you can't "cheat" by testing any condition or storage external to the actu
al
:>code itself, nor can the code be modified by anything outside of itself. I
t
:>should be useable in any application (again, forget RENT stuff). The actio
n
:>(NOP or BRANCH) can only be taken the LAST TIME the code is executed.

Other than the trivial cases of clearing storage or loading a wait state PSW
,
i.e., the routine setting conditions that it can never be re-executed, it is
impossible without knowledge of what causes the routine to be executed.

--
Binyamin Dissen <bdissen@dissensoftware.com>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel

Report this thread to moderator Post Follow-up to this message
Old Post
Binyamin Dissen
03-20-04 01:28 AM


Re: Last Time NOP Brain Teaser
Exactly. You cannot predict the future. The examples listed show knowledge o
f
the past, not the future.

"Binyamin Dissen" <postingid@dissensoftware.com> wrote in message
 news:0v02svce1ortusdpds4iivvtq9qsl3kj8t@
4ax.com...
> On 23 Nov 2003 18:50:33 GMT rfcommsys@aol.com (RFCOMMSYS) wrote:
>
> :>I want to see someone design a LAST TIME NOP (or branch). The rules are 
that
> :>you can't "cheat" by testing any condition or storage external to the ac
tual
> :>code itself, nor can the code be modified by anything outside of itself.
 It
> :>should be useable in any application (again, forget RENT stuff). The act
ion
> :>(NOP or BRANCH) can only be taken the LAST TIME the code is executed.
>
> Other than the trivial cases of clearing storage or loading a wait state P
SW,
> i.e., the routine setting conditions that it can never be re-executed, it 
is
> impossible without knowledge of what causes the routine to be executed.
>
> --
> Binyamin Dissen <bdissen@dissensoftware.com>
> http://www.dissensoftware.com
>
> Director, Dissen Software, Bar & Grill - Israel



Report this thread to moderator Post Follow-up to this message
Old Post
xarax
03-20-04 01:28 AM


Re: Last Time NOP Brain Teaser
xarax wrote:

> Exactly. You cannot predict the future. The examples listed show knowledge
 of
> the past, not the future.

Consider phase conjugate optics, where given an optical signal a device
will create the time reversed version of the signal.

Also, consider compilers with a COME FROM statement, that does the
opposite of the GO TO statement.

-- glen


Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
03-20-04 01:28 AM


Re: Last Time NOP Brain Teaser
"RFCOMMSYS" <rfcommsys@aol.com> wrote in message
news:20031123135033.02030.00000736@mb-m16.aol.com...
> I'm sure we've all seen a "First Time NOP", typically:
>
>           NOP  SOMEWHER
>           OI      *-3,X'F0'
>
> On first execution, the NOP falls through to the OI, which changes the NOP
to a
> B. On subsequent executions, it branches to SOMEWHER. Note that the code
> doesn't test any condition or storage external to itself to "know" it's
the
> first time, nor is it modified by anything outside of itself. This code
can be
> used in any program, regardless of the specific application. (Let's ignore
RENT
> considerations for purposes of this discussion).
>
> There's also the  FIRST TIME BRANCH:
>
>           NOP  *+12
>           OI      *-3,X'F0'
>           B       SOMEWHER
>
> Where the branch to SOMEWHER occurs only the first time.
>
>
> I want to see someone design a LAST TIME NOP (or branch). The rules are
that
> you can't "cheat" by testing any condition or storage external to the
actual
> code itself, nor can the code be modified by anything outside of itself.
It
> should be useable in any application (again, forget RENT stuff). The
action
> (NOP or BRANCH) can only be taken the LAST TIME the code is executed.
>
>
>

Just how do you know that it is the last time?

Sven



Report this thread to moderator Post Follow-up to this message
Old Post
Sven Pran
03-20-04 01:28 AM


Re: Last Time NOP Brain Teaser
"glen herrmannsfeldt" <gah@ugcs.caltech.edu> wrote in message
news:Cgawb.217404$275.810476@attbi_s53...
> xarax wrote:
> 
knowledge of 
>
> Consider phase conjugate optics, where given an optical signal a device
> will create the time reversed version of the signal.
>
> Also, consider compilers with a COME FROM statement, that does the
> opposite of the GO TO statement.
>
> -- glen
>

COME FROM is no problem, any decent trouble diagnostics program includes
that for a traceback of the calling sequence leading up to the error.

Reversing time to see what the future will bring seems, well Startrek
technology
some 500 years ahead of us?

Sven



Report this thread to moderator Post Follow-up to this message
Old Post
Sven Pran
03-20-04 01:28 AM


Re: Last Time NOP Brain Teaser
Sven Pran said ---

>
>
>Just how do you know that it is the last time?
>
>

Ah, how indeed ...


Report this thread to moderator Post Follow-up to this message
Old Post
RFCOMMSYS
03-20-04 01:28 AM


Re: Last Time NOP Brain Teaser
On Tue, 25 Nov 2003 05:41:12 GMT glen herrmannsfeldt <gah@ugcs.caltech.edu>
wrote:

:>RFCOMMSYS wrote:

:>> Sven Pran said ---

:>>>Just how do you know that it is the last time?

:>> Ah, how indeed ...

:>There is a question in another newsgroup about how to find the value of
:>the fifth from the last element of a linked list with one pass through
:>the list.

Well.......

You can save the last five values.

Obviously there are more constraints.

--
Binyamin Dissen <bdissen@dissensoftware.com>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel

Report this thread to moderator Post Follow-up to this message
Old Post
Binyamin Dissen
03-20-04 01:28 AM


Re: Last Time NOP Brain Teaser
It's a standard M$ interview question. It simply means managing two pointers
that represent a specified span of elements in the linked-list. Just walk th
e
first pointer for 5 elements, then continue walking both elements. When the
first pointer gets to the end of the list, the other pointer is 5 elements f
rom
the end.

A variation of this technique is used for walking damaged linked-lists to fi
nd
the broken element (the one that points incorrectly back into the previous
elements somewhere).

"glen herrmannsfeldt" <gah@ugcs.caltech.edu> wrote in message
news:YXBwb.221104$mZ5.1690987@attbi_s54...
> RFCOMMSYS wrote:
> 
> 
> 
>
> There is a question in another newsgroup about how to find the value of
> the fifth from the last element of a linked list with one pass through
> the list.
>
> -- glen
>



Report this thread to moderator Post Follow-up to this message
Old Post
xarax
03-20-04 01:28 AM


Re: Last Time NOP Brain Teaser
rfcommsys@aol.com (RFCOMMSYS) wrote
> I want to see someone design a LAST TIME NOP (or branch). The rules are th
at
> you can't "cheat" by testing any condition or storage external to the actu
al
> code itself, nor can the code be modified by anything outside of itself. I
t
> should be useable in any application (again, forget RENT stuff). The actio
n
> (NOP or BRANCH) can only be taken the LAST TIME the code is executed.

If this were possible, what path would the following code take:


TOP_LOOP
...
... some looping process code
...

*
* Use of the grand-spankin new macro - LASTTIME_BRANCH_TO label
*
LAST_TIME_CHECK DS 0H
LASTTIME_BRANCH_TO  PARADOX_CODE
B   TOP_LOOP
*
PARADOX_CODE DS 0H
B   LAST_TIME_CHECK

So, does the macro LASTTIME_BRANCH_TO ever branch? Is the label PARADOX_CODE
ever reached?  Is this an infinite loop?

Tim

Report this thread to moderator Post Follow-up to this message
Old Post
Tim Coffey
03-20-04 01:28 AM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

ASM370 archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:53 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.