Posts by dpiponi@mathstodon.xyz
 (DIR) Post #B53UZzevKZyqs6XPSy by dpiponi@mathstodon.xyz
       0 likes, 1 repeats
       
       Now I have some time I can do some of those things I've been meaning to look at for a while, like reverse engineering the ROM on this thing which I think is even more of a marvel than the better known Sinclair. It's programmable and yet the ROM is 1.5K in size.But it's hard - the instruction set is bizarre. For example ADX is a 4 bit add which behaves differently in the special case of adding 6. It's like someone printed out a program for a calculator in C, cut it up into random pieces, and made each piece a machine instruction whatever lines of code just happened to get grouped together. So someone saw an add followed by a comparison with 6 and thought "let's call that ADX".https://www.seanriddle.com/nationalcopsi.pdf
       
 (DIR) Post #B53Ua0ZzuNdNj7EzQW by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       Finally, found something to do with a transcendental function  0764 @0725  165  LM 5           ; log(10) = 2.302585!!!  0765 @0752  170  LM 8            0766 @0765  165  LM 5            0767 @0772  162  LM 2            0770 @0775  160  LM 0            0771 @0776  163  LM 3            0772 @0777  162  LM 2            0773 @0737  100  RET
       
 (DIR) Post #B53Ua10EKqcN2TVwJc by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       The only constants with more than 2 digits in this ROM seem to be log(10), cos(0.005), and pi/2. The plot thickens.
       
 (DIR) Post #B53Ua1NcvrKiD2Scme by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       This CPU is insane.There is an LB instruction that loads a constant into a register called B. What could be simpler?If you have N LBs in a row, you'd expect all but the last one to be ignored because each one overwrites the previous one.But no, it's all but the *first* one that gets ignored. It's clever because you can have a sequence of LB instructions and jump into the middle and that becomes the first one. So a caller can control the starting value of B in a subroutine by calling slightly different addresses.
       
 (DIR) Post #B53Ua1m5SutnQtu9uS by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       The code also has 180/pi stored in it. And the calculator has deg->rad and rad->deg keys. So it was a safe bet that if I started the emulator where it loads up 180/pi, then either add or divide came next. Sure enough, I can now see how it multiplies.Simple repeated addition. Multiples A by B into R by repeatedly adding B to R while decrementing the last digit of A. And when the digit hits zero, it shifts and continues. The decimal version of the standard binary method.
       
 (DIR) Post #B53Ua2BxuhbCjA0pFI by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       Oh, this is too weird! It gives users space for a 36 step program. And I just found a loop that does a big 36 digit rotate. And I'm thinking there isn't a user program counter but instead it rotates the entire program and only ever executes the first instruction!
       
 (DIR) Post #B53Ua2bUNo120JxD1s by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       Among the weirdness: throughout code are shift operations ie. multiply/divide by 10. Some places have two shifts in a row. Apart from sqrt (maybe) it's hard to know why anyone needs multiply/divide by 100.This processor has families of operations for "serial" operations working through binary operations on pairs of buffers a digit at a time. They have auto increment that automatically bails out of the loop at the end.So what's the end? Its's hard-coded in the CPU as either position 13 or position 16 (aka 0) in your buffer. So if you want to process the entire buffer you call once to get to 13 and again to finish the job. Hence pairs of call to the shifter.There can't be a lot of of CPUs with "13 or 0" hard-coded into them. Or "equals 6" either.
       
 (DIR) Post #B53Ua32QldZBLsYj1U by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       Anyway I've traced keypad input and debouncer. And traced operations like multiplication. But between them something is wrong as simulated key presses don't do what I expect. So the hardware description here isn't quite right. Debugging that might be beyond my ability, especially when I have job interviews to prepare for. Also the ROM is from decapping the chip and might not be 100% correct https://www.seanriddle.com/sinclaircambridgeprogrammable/sinclaircambridgeprogrammableromacid.jpgAlso I'm pretty sure I found a bug in the numerical rounding when it checks if the bottom digit is >=5 :)
       
 (DIR) Post #B53Ua3RbG3hQbwKpFo by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       @dpiponi I can see some instructions that do something like x,y -> y,x+y/100. I wonder if you can build trig functions from this. This calculator is very approximate so 1/100 isn't that surprising a number to see hard-coded.
       
 (DIR) Post #B53Ua3phoQyvohc4pM by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       In sunlight the camera shutter allows me to see the display strobe. Wanted to make sure it matches expectations.
       
 (DIR) Post #B53Ua4DSO7yr0Mj2qe by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       Woohoo! If I start the calculator emulator, manually set one RAM location to zero, and then simulate the key presses to compute exp(exp(0)) it displays "2.71726 2".So - maybe a bit or two in the ROM is corrupted, or the emulator is buggy, or maybe the CPU docs don't match reality. The last is possible as the device was slightly configurable by the manufacturer.(The real calculator says "2.7179766" - it's famously inaccurate.)
       
 (DIR) Post #B53Ua4FwEtxv83t1iS by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       And the suspicious deer that passed by during my experiments.
       
 (DIR) Post #B57fngrBuSyWjwqiKO by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       @mjd I think I want to say that it's straightforwardly true but why would you make a cartoon about something so ordinary?
       
 (DIR) Post #B5qHe27sK3Dp1SiDDc by dpiponi@mathstodon.xyz
       1 likes, 0 repeats
       
       The US has basically abandoned democracy and replaced it with some kind of weird game involving fractals.
       
 (DIR) Post #B69PbuaJse3agvkqqu by dpiponi@mathstodon.xyz
       0 likes, 0 repeats
       
       Text adventure games were brutal in the old days. Here's my first move in Kingdom of Hamil
       
 (DIR) Post #B6K1rr1ccde47j9ZeS by dpiponi@mathstodon.xyz
       0 likes, 1 repeats
       
       Vanity purchase on eBay due to having a mention in it. But check out these ads. I tried doing something with Shortcuts on my iPhone this morning but I think that Sharp might do it many times better. Only problem is I now have to figure out how to restore failed glue in a "perfect bound" magazine from the 80s.