<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Nim and the Sinclair Cambridge Programmable calculator</title>
	<atom:link href="http://www.suppertime.co.uk/blogmywiki/2018/09/sinclair-nim/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.suppertime.co.uk/blogmywiki/2018/09/sinclair-nim/</link>
	<description>reading, writing, coding, making</description>
	<lastBuildDate>Tue, 24 Oct 2023 13:43:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: Sean Riddle</title>
		<link>http://www.suppertime.co.uk/blogmywiki/2018/09/sinclair-nim/#comment-100708</link>
		<dc:creator>Sean Riddle</dc:creator>
		<pubDate>Sun, 30 May 2021 19:04:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.suppertime.co.uk/blogmywiki/?p=3228#comment-100708</guid>
		<description>Every different calculator or game has its own unique ROM that tells the chip what to do.  Usually an ID code is printed on the chip package and is also marked on the die.  All of the early microcontrollers use mask ROM - the ROM was permanently fixed when the chip was made.  So no chance for updates if bugs were found!  

In fact, Hap on the MAME team informed me that there are 2 versions of the Sinclair Cambridge Programmable MM5799; ID codes EHY and NBP.  The one I bought is marked NBP; I assume since N comes after E that it has the later ROM, but we won&#039;t know the differences unless the EHY also gets dumped.

Here are some giant pictures of the chip with the top metal layer and with it removed, some slightly smaller pictures of just the ROM array on the chip, a visual transcription of the bits from the ROM array, and those bits rearranged into how the CPU processes them.  There&#039;s also a text file describing how the chip is wired up:
http://www.seanriddle.com/sinclaircambridgeprogrammable/</description>
		<content:encoded><![CDATA[<p>Every different calculator or game has its own unique ROM that tells the chip what to do.  Usually an ID code is printed on the chip package and is also marked on the die.  All of the early microcontrollers use mask ROM &#8211; the ROM was permanently fixed when the chip was made.  So no chance for updates if bugs were found!  </p>
<p>In fact, Hap on the MAME team informed me that there are 2 versions of the Sinclair Cambridge Programmable MM5799; ID codes EHY and NBP.  The one I bought is marked NBP; I assume since N comes after E that it has the later ROM, but we won&#8217;t know the differences unless the EHY also gets dumped.</p>
<p>Here are some giant pictures of the chip with the top metal layer and with it removed, some slightly smaller pictures of just the ROM array on the chip, a visual transcription of the bits from the ROM array, and those bits rearranged into how the CPU processes them.  There&#8217;s also a text file describing how the chip is wired up:<br />
<a href="http://www.seanriddle.com/sinclaircambridgeprogrammable/" rel="nofollow">http://www.seanriddle.com/sinclaircambridgeprogrammable/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blogmywiki</title>
		<link>http://www.suppertime.co.uk/blogmywiki/2018/09/sinclair-nim/#comment-100684</link>
		<dc:creator>blogmywiki</dc:creator>
		<pubDate>Fri, 28 May 2021 17:54:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.suppertime.co.uk/blogmywiki/?p=3228#comment-100684</guid>
		<description>Hi Sean - that&#039;s amazing! I can&#039;t pretend I follow all of it, but sounds like a weekend project for me to figure it all out. I&#039;d love to find out more about the NatSemi chip at the heart of it. I assume the ROM was custom-flashed for each device?
best wishes and good luck with the emulation project.
Giles</description>
		<content:encoded><![CDATA[<p>Hi Sean &#8211; that&#8217;s amazing! I can&#8217;t pretend I follow all of it, but sounds like a weekend project for me to figure it all out. I&#8217;d love to find out more about the NatSemi chip at the heart of it. I assume the ROM was custom-flashed for each device?<br />
best wishes and good luck with the emulation project.<br />
Giles</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Riddle</title>
		<link>http://www.suppertime.co.uk/blogmywiki/2018/09/sinclair-nim/#comment-100655</link>
		<dc:creator>Sean Riddle</dc:creator>
		<pubDate>Thu, 27 May 2021 06:26:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.suppertime.co.uk/blogmywiki/?p=3228#comment-100655</guid>
		<description>I know it&#039;s been a long time since you posted this but I just came across it after purchasing an EC-4001, which is the same calculator rebranded for Radio Shack.

The program plays by always trying to leave you with 4n+1 matches.  You can always win by starting off with 4n+1 matches and taking 3 every turn.  A human opponent might notice what you are doing and vary the number of matches he picks (you can still win but have to change the number of matches you take accordingly), but the program will take 1 match every time there are 4n+1 remaining.

The code is confusing because it uses &quot;convenience functions&quot;, which are invoked when an operator (+, -, x, /) or the equals sign follows an operator.  The loop that subtracts 4 does &quot;- - -&quot;, and when the loop ends the code does &quot;- - +&quot;.  The &quot;- -&quot; convenience function changes the sign of the current result.  This is useful because the conditional jump operator is &quot;go if negative&quot; (gin), but the code needs to loop if the value is positive. &quot;- - gin - # 4&quot; will jump if the initial value was positive, and the 3rd - changes the sign back to its original state before subtracting 4. &quot;- - gin + # 5&quot; will not jump if the initial value was negative or zero, then the + changes the sign back and adds 5.

I found it easier to first look at the code with the section in the parentheses removed: STO - ( ) - STOP = STOP = = = =
It stores your initial # then subtracts what it calculates in the parentheses then &quot;hits&quot; the minus key (which displays the result) and stops.  You enter the number of matchsticks you want to take and hit RUN, which resumes the program at the equals sign, then it stops again.  Since the minus key had been hit before ypu entered your number, your number is subtracted from the total and the equals sign displays the new total.  When you hit RUN, the code resumes at the first of 4 minus signs, which do nothing but advance the program to the end of the program at line 35, where it rolls over to the beginning (they could have used a GOTO 00, which is also 4 instructions).  At this point, it&#039;s like you just started a new game with the new total.

The code in the parentheses RCLs the number of matchsticks and adds 3.  Then it subtracts 4 in a loop until the result is zero or negative.  If negative, 4 is added; if zero then 1 is added.  If the number of matches was not a multiple of 4 plus 1, this will be the number of matches to take to make the new total a multiple of 4 plus 1.  If the number of matches was a multiple of 4 plus 1 then the code just takes 1; it needs to take 0 or 4 to get back to a multiple of 4 plus 1, but those choices are illegal.

I bought the calculator to preserve it through emulation.  The chip inside is a National Semiconductor MM5799, a general purpose microcomputer with 1536 bytes of ROM and 48 bytes of RAM (not megabytes or even kilobytes!)  It was also used in a couple of educational calculators and some Mattel handheld LED games (basketball, hockey and soccer) which are already emulated.  I will use a blowtorch to remove the plastic package from the chip revealing the silicon die.  I&#039;ll take pictures of it, then use acid to remove the metal and take more pictures.  I&#039;ll transcribe the bits that make up the calculator&#039;s &quot;brains&quot; and send those to the MAME team who will add it to the list of devices that are emulated.</description>
		<content:encoded><![CDATA[<p>I know it&#8217;s been a long time since you posted this but I just came across it after purchasing an EC-4001, which is the same calculator rebranded for Radio Shack.</p>
<p>The program plays by always trying to leave you with 4n+1 matches.  You can always win by starting off with 4n+1 matches and taking 3 every turn.  A human opponent might notice what you are doing and vary the number of matches he picks (you can still win but have to change the number of matches you take accordingly), but the program will take 1 match every time there are 4n+1 remaining.</p>
<p>The code is confusing because it uses &#8220;convenience functions&#8221;, which are invoked when an operator (+, -, x, /) or the equals sign follows an operator.  The loop that subtracts 4 does &#8220;- &#8211; -&#8221;, and when the loop ends the code does &#8220;- &#8211; +&#8221;.  The &#8220;- -&#8221; convenience function changes the sign of the current result.  This is useful because the conditional jump operator is &#8220;go if negative&#8221; (gin), but the code needs to loop if the value is positive. &#8220;- &#8211; gin &#8211; # 4&#8243; will jump if the initial value was positive, and the 3rd &#8211; changes the sign back to its original state before subtracting 4. &#8220;- &#8211; gin + # 5&#8243; will not jump if the initial value was negative or zero, then the + changes the sign back and adds 5.</p>
<p>I found it easier to first look at the code with the section in the parentheses removed: STO &#8211; ( ) &#8211; STOP = STOP = = = =<br />
It stores your initial # then subtracts what it calculates in the parentheses then &#8220;hits&#8221; the minus key (which displays the result) and stops.  You enter the number of matchsticks you want to take and hit RUN, which resumes the program at the equals sign, then it stops again.  Since the minus key had been hit before ypu entered your number, your number is subtracted from the total and the equals sign displays the new total.  When you hit RUN, the code resumes at the first of 4 minus signs, which do nothing but advance the program to the end of the program at line 35, where it rolls over to the beginning (they could have used a GOTO 00, which is also 4 instructions).  At this point, it&#8217;s like you just started a new game with the new total.</p>
<p>The code in the parentheses RCLs the number of matchsticks and adds 3.  Then it subtracts 4 in a loop until the result is zero or negative.  If negative, 4 is added; if zero then 1 is added.  If the number of matches was not a multiple of 4 plus 1, this will be the number of matches to take to make the new total a multiple of 4 plus 1.  If the number of matches was a multiple of 4 plus 1 then the code just takes 1; it needs to take 0 or 4 to get back to a multiple of 4 plus 1, but those choices are illegal.</p>
<p>I bought the calculator to preserve it through emulation.  The chip inside is a National Semiconductor MM5799, a general purpose microcomputer with 1536 bytes of ROM and 48 bytes of RAM (not megabytes or even kilobytes!)  It was also used in a couple of educational calculators and some Mattel handheld LED games (basketball, hockey and soccer) which are already emulated.  I will use a blowtorch to remove the plastic package from the chip revealing the silicon die.  I&#8217;ll take pictures of it, then use acid to remove the metal and take more pictures.  I&#8217;ll transcribe the bits that make up the calculator&#8217;s &#8220;brains&#8221; and send those to the MAME team who will add it to the list of devices that are emulated.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
