An interesting use of the 4004 instructions
dkelvey at hotmail.com
Fri Dec 16 08:43:52 CST 2016
The 4004 destroys the ACC on return from subroutine calls and one
would have to use hard coded values to pass a value back so it
is common to the use carry flag in a similar way to pass a status
Since this the address part of the JCN instruction doesn't matter if
it never does the branch, that is used as an entry point for the
The code would look like:
Each of the LDM instructions is a point to branch into. Only the instruction
at the first address is executed and the others are skipped.
BBL is the I4004 return instruction, it loads the value into the ACC.
I've looked at a several cases of I4004 code and this is the first time that
I'd seen this skip trick used.
The SKIP is really the JCN instruction without any condition and the address
replaced by the LDM instruction. At first I thought it was bit rot in the old
ROMs but each entry is used 8 times in code.
It would be a JCN NEVER? One wonders what the assembly code originally
From: cctalk <cctalk-bounces at classiccmp.org> on behalf of Paul Koning <paulkoning at comcast.net>
Sent: Thursday, December 15, 2016 4:55:35 PM
To: General Discussion: On-Topic Posts
Subject: Re: An interesting use of the 4004 instructions
> On Dec 15, 2016, at 2:52 PM, dwight <dkelvey at hotmail.com> wrote:
> I was looking at some disassembled 4004 code when I came across
> a SKIP operation.
> It isn't normally an instruction but If you do a JCN with all the CCCC = 0,
> it will do a NEVER jump.
> This is the equivalent of a SKIP instruction.
> I would suppose a JCN with CCCC = $8000 would be an always jump,
> on page ( not real useful as JUN takes the same cycles and space ).
> I thought at first there was some errors in the code because there
> were JMS to the middle of JCN instruction but then I noticed that there
> were no conditions specified for the JCN. A little thought and I realized
> it was a way to skip over a single byte instruction.
It's a bit like a coding convention I've seen used a lot in PDP-11 code, at least in some programs; RSTS/E is full of them. Consider a function with two entry points, where Carry set or clear is used after entry to distinguish the two cases. The two entry points look like this:
fun1: tst (pc)+
; common code
Or a function that indicates a boolean result (say, success/fail) by Carry clear vs. set:
good: tst (pc)+
More information about the cctech