Post Reply 
When ISZ/DSZ > ISG/DSE
05-23-2019, 11:51 PM
Post: #1
When ISZ/DSZ > ISG/DSE
Ran across something interesting (to me at least) in an HP KeyNotes issue.

The situation was on the HP-67, the I register contained either a zero or one. Goal was to use ISZ/DSZ to switch it. Think of it as a brain-teaser:

"The X register contains either a zero or one. Flip the value without using any digit keys or X=? test conditionals."

The solution presented was...

ISZ
DSZ
DSZ
ISZ

which works. Then I started thinking. That's hard to do on the HP41 style structure.

ISG won't work here. Thoughts?

Try it on your HP67 or an emulator and help me think through how to do it this way on an HP41. No X=Y? or X=0? conditionals allowed. :-)
Find all posts by this user
Quote this message in a reply
05-24-2019, 12:00 AM
Post: #2
RE: When ISZ/DSZ > ISG/DSE
SIGN
LASTX
-
Visit this user's website Find all posts by this user
Quote this message in a reply
05-24-2019, 12:44 AM
Post: #3
RE: When ISZ/DSZ > ISG/DSE
Which certainly works on X as I laid it out. Thomas is a master. :-)

What proposals for a value in a memory register?
Find all posts by this user
Quote this message in a reply
05-24-2019, 01:08 AM
Post: #4
RE: When ISZ/DSZ > ISG/DSE
(05-24-2019 12:00 AM)Thomas Okken Wrote:  SIGN
LASTX
-

Awesome. And elegant!

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
05-24-2019, 02:59 AM
Post: #5
RE: When ISZ/DSZ > ISG/DSE
ACOS
SIN


By Andrés Rodríguez, I think.
Find all posts by this user
Quote this message in a reply
05-24-2019, 04:10 AM (This post was last modified: 05-26-2019 03:59 AM by Paul Dale.)
Post: #6
RE: When ISZ/DSZ > ISG/DSE
On the 34S, I think the minimal real mode solution would be:

Code:
NOT

The 34S has both flavours of increment (i.e. ISG and ISZ).


Pauli
Find all posts by this user
Quote this message in a reply
05-24-2019, 12:59 PM
Post: #7
RE: When ISZ/DSZ > ISG/DSE
Thank you Gerson for remembering this old answer from me to an old similar challenge!

Andrés C. Rodríguez (Argentina)

Please disregard idiomatic mistakes.
My posts are mostly from old memories, not from current research.
Find all posts by this user
Quote this message in a reply
05-24-2019, 01:31 PM
Post: #8
RE: When ISZ/DSZ > ISG/DSE
(05-24-2019 12:44 AM)Gene Wrote:  What proposals for a value in a memory register?

Here is a proposal for a value in memory register 01 that keeps the stack and lastX unchanged:
Code:
X<> 01
DSE X
CHS
CHS
X<> 01
Find all posts by this user
Quote this message in a reply
05-24-2019, 02:00 PM (This post was last modified: 05-24-2019 02:01 PM by Gerson W. Barbosa.)
Post: #9
RE: When ISZ/DSZ > ISG/DSE
CHS
ISG X


Two steps also, but Andrés Rodríguez’s solution should be still one byte shorter.
Find all posts by this user
Quote this message in a reply
05-24-2019, 02:35 PM (This post was last modified: 05-24-2019 02:37 PM by Thomas Okken.)
Post: #10
RE: When ISZ/DSZ > ISG/DSE
(05-24-2019 02:00 PM)Gerson W. Barbosa Wrote:  CHS
ISG X


Two steps also, but Andrés Rodríguez’s solution should be still one byte shorter.

Andrés' solution looks unbeatable on size, but it is slower. Not a lot slower, to be honest, since it takes advantage of special cases in ACOS and SIN, so it really is quite brilliant. I wish I had thought of it. Smile

CHS ISG X is flawed because the ISG skips the next instruction in the 0 → 1 case...
Visit this user's website Find all posts by this user
Quote this message in a reply
05-24-2019, 04:02 PM
Post: #11
RE: When ISZ/DSZ > ISG/DSE
(05-24-2019 02:35 PM)Thomas Okken Wrote:  CHS ISG X is flawed because the ISG skips the next instruction in the 0 → 1 case...


Yes, I am aware of that. Anyway, the following works on both the 41 and 42:

01 LBL “W”
02 CHS
03 ISG X
04 END


0 XEQ W -> 1
XEQ W -> 0
XEQ W -> 1


and so on...
Find all posts by this user
Quote this message in a reply
05-28-2019, 09:41 PM
Post: #12
RE: When ISZ/DSZ > ISG/DSE
Thomas, Gerson,

Your generous (and mostly undeserved) comments about [ACOS | SIN] made my day. Thank you!!

Andrés C. Rodríguez (Argentina)

Please disregard idiomatic mistakes.
My posts are mostly from old memories, not from current research.
Find all posts by this user
Quote this message in a reply
05-29-2019, 12:33 AM
Post: #13
RE: When ISZ/DSZ > ISG/DSE
(05-28-2019 09:41 PM)Andres Wrote:  Thomas, Gerson,

Your generous (and mostly undeserved) comments about [ACOS | SIN] made my day. Thank you!!

You are most welcome!

Besides, unto Andrés what belongs to Andrés! :-)

Here it is, exactly fourteen years ago now:

A tiny solution for the 0<>1 toggle
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)