HP nut CPU and illegal instruction sequences


Does anyone know how the 41 nut cpu behaves when it comes to instruction sequences that should be avoided?

The David assembler manual basically says that AND and OR should not follow an arithmetic instruction that can have a carry out of the highest bit of the register.

The HP internal doc states that various instructions, most flag instructions (plus AND and OR) should not follow an arithmetic class 2 instruction.
What is an arithmetic class 2 instruction here? Is it any class 2 instruction, even such as C=0 which does not even affect carry? Are relational compare instructions such as A<C affected as well (it probably does an internal subtraction)? What about C#0?

The HP description does not feel right, I have done things that should be avoided in the past without getting any ill effects I could see. I feel a little bit puzzled by this.

In short, what should I look out for? Should I trust David, HP or are there other interpretations on what should be avoided?


Hi, Håkan;

I am sorry not having an answer to your question, but I am surely following the thread.




Note that HP had three generations of Nut CPU chips, 1LA5, 1LE3, and 1LF5 (and more if you count some of the later Voyager variants), so it is remotely possible that bugs might have been fixed in the later ones. On the other hand, they probably didn't have any significant justification for investing the engineering effort to fix the bugs, so it is more likely that they kept the logic design of the core the same.


Hi, Håkan;

A recent addition to T.O.S. (Doug Wilder´s QuinTable.pdf) brings the following relevant notes:

3. NOT (C=-C-1) always sets carry.
4. AND and OR misbehave if carry is set.
5. POP misbehave in DEC mode: increments msd if in the range A-F.
6. G register misbehave if PT=13
Copyright 1987, 2005 STC, W.D.Wilder

No specific explanation about the reasons or internal structure, but it gives some extra info.


Luiz (Brazil)

Edited: 30 Dec 2009, 9:49 p.m.


Guess what, you get to test! get your head out of your ass and test your surmise, don't be stupid, test your premise:

It ain't that hard to test your code, don't be afraid, just try it,
it can only crash your calc and you can revive via MEMORY LOST.

don't be afraid, i love 41c. Don't be afraid.



Edited: 31 Dec 2009, 10:56 a.m.


I hoped there were some deeper insights available in this issue. In that case I will need to fire up my MLDL and HP41 and try some stuff out myself.

I am not afraid, I had far fewer MEMORY LOST messages doing MCODEing than I did with synthetics... :)

It is just that I do not have my MLDL anywhere close to me at the moment, so it will have to wait. Anyway, I have some good starting points what to look at when I get around to it.


I know nothing beats the real thing but V41 does an excelent job as surrogate of a HW MLDL. It supports the Hepax module quite flawlessly (others maybe too but I haven't tried them).

Bad news if you're not using Windoze, though - but maybe you've got another system available fot these purposes.

Best wishes,


My paper "Inside the NUT CPU" over on the unmentionable site may
provide some insights.

I was never able to figure out the "not after class 2" restriction.
If I had to guess, I would say that it has something to do

with a carry affecting the instruction similar to how it is

used for the conditional jumps... but that is just a guess.

I do not consider the G=13 case to be a bug. As I explain

in the aforementioned paper, the results are exaclty what falls

out of a straigtforward bit-serial implementation of the normal


In all cases, it is important to remember that this design

is from an era when every single transistor counted, so a

designer would spend time minimizing the number of transistors.

Add to this the bit-serial operation, and most of the "bugs"

that have been documented can be easily explained.

Because emulators typically do not atempt to mimic this

bit-serial operation, it is unlikely that they will duplicate

out-of-the-norm cases. Even with my NEWT design, which retains

the bit-serial operation, I didn't ever try to verify all of

the abnormal cases. For example, arithmetic operations, in

decimal mode, when the register contents are not valid decimal

numbers. Odds are that the results will be the same, because

the arithmetic functions are the same, but I never bothered

simulating these cases.



I have so far studied old HP documentation, Doug Wilder´s QuinTable.pdf, David's assembler manual, the Monte Dalrymple's "Inside the NUT CPU" and "NEWT Microprocessor Technical Manual".

The G register and pt=13 thing I have stumbled over myself by accident way back before I even saw it documented. It is well explained in the Newt paper as well as David's assembler manual.

David also explains the C=C|A and C=C&A bugs, but the description is
not the same as I saw in QuinTable.pdf. I will need to experiment with it myself a bit on real hardware.

Non-BCD numbers in decimal mode arithmetics behavior is tested by the service module. I found this out when I tried the service module
on my emulator. (I did it wrong initially).

Anyway, I feel there is a reasonable complete understanding of many of the things going on. The darkest corner seems related to the class 2 (arithmetic) instructions being followed by certain other instructions mystery.

Many thanks, I will keep the information I have collected so far in mind when I can power up my MLDL later for some experiments.


On the Saturn CPU, decimal arithmetic with non-BCD digits is non-commutative. I haven't tested this with the Nut or earlier CPUs, but it's on my todo list.

Possibly Related Threads...
Thread Author Replies Views Last Post
  HP PRIME: interlinked sequences? Alasdair McAndrew 4 618 11-23-2013, 10:39 PM
Last Post: Alasdair McAndrew
  HP-71B CPU frequency? Christoph Giesselink 18 1,659 03-02-2013, 09:35 AM
Last Post: Gerson W. Barbosa
  x swap (I) hp 35s instruction Denis Doyon 4 654 12-25-2012, 11:22 AM
Last Post: Walter B
  82162 printer escape sequences Hans Holzach 3 486 07-08-2012, 11:50 AM
Last Post: Hans Holzach
  That's a tough nut to crack... Matt Agajanian 7 791 05-25-2012, 01:53 PM
Last Post: Mike Morrow
  OT: Mechanical CPU clock Ethan Conner 1 432 04-19-2012, 01:23 AM
Last Post: Mike Morrow
  HP-41 NUT Assembler question MichaelG 6 731 02-14-2012, 03:35 AM
Last Post: MichaelG
  HP 15C LE programming, does CPU run fast? designnut 1 394 02-12-2012, 05:13 PM
Last Post: Jeff O.
  34s: Anyone have an instruction timing table? Gene Wright 15 1,379 07-19-2011, 11:28 PM
Last Post: Paul Dale
  HP-41 MCODE breakpoint/trap instruction? Håkan Thörngren 4 572 03-15-2011, 08:22 AM
Last Post: Håkan Thörngren

Forum Jump: