(42S) CARDIAC
|
10-11-2014, 08:54 PM
(This post was last modified: 07-31-2022 10:11 AM by Thomas Klemm.)
Post: #1
|
|||
|
|||
(42S) CARDIAC
Quote:The acronym CARDIAC stands for "CARDboard Interactive Aid to Computation." It was developed by David Hagelbarger at Bell Labs as a tool for teaching how computers work in a time when access to real computers was extremely limited. The CARDIAC kit consists of a folded cardboard "computer" and an instruction manual. In July 1969, the Bell Laboratories Record contained an article describing the system and the materials being made available to teachers for working with it.-- Brian L. Stuart, A discription of the CARDIAC This program is a CARDIAC-simulator. It allows to run programs written for CARDIAC on your HP-42S. In order to work properly we need registers 00-99. Thus you have to set the size accordingly: SIZE 100 The simulator allows to load a CARDIAC-program (deck of cards) into the memory of the HP-42S. These cards have to be stored in a matrix. This is an example of a program that counts to 10. Program Listing: Code: 04 009 n DATA 009 Create a 1×2 Matrix and set it to GROW: 1 ENTER 2 MATRIX.NEW EDIT GROW Now enter all the numbers of the listing: Code: [ STO "COUNT" The first row [2, 800] is just the boot-loader program. At the end we write n = 9 into register 4 [4, 9] and then we jump to line 10 to start the program [2, 810]. This loads the program from the matrix into the memory and runs it: RCL "COUNT" XEQ "CARDIAC" Make sure to set flag 21 when using Free42 or it will run too fast to notice anything. Alternatively you may add a PSE in the implementation of OUT (LBL 05). If everything is correct you should see: R05=1 R05=2 R05=3 R05=4 R05=5 R05=6 R05=7 R05=8 R05=9 R05=10 The program is still loaded in the memory of the HP-42S. Let's assume we want to count to 100 instead: 99 STO 04 10 XEQ 99 R05=1 R05=2 R05=3 R05=4 (...) R05=97 R05=98 R05=99 R05=100 Implementation details The registers 00-99 are used as memory. The accumulator acc and the program-counter pc are kept on the stack. The instruction register ir consists of two parts: the code and the address addr. Furthermore the address consists of the left and the right digit. They are used in the "shift accumulator" operator. Here's an example: ir = 835 code = 8 addr = 35 left = 3 right = 5 Links Listing Code: ;---------------------;------------------ Attachment Code: Archive: cardiac.zip |
|||
10-12-2014, 06:15 PM
Post: #2
|
|||
|
|||
RE: (HP-42S) CARDIAC
Greatest Common Divisor
Code: 05 a DATA Example (after loading the program): What is gcd(408, 360)? 408 STO 05 360 STO 06 12 XEQ 99 The result is: R06=24 You can copy&paste this deck of cards into the simulator to run this example: 2 800 10 005 11 006 12 105 13 605 14 706 15 317 16 813 17 105 18 607 19 700 20 326 21 106 22 605 23 107 24 606 25 812 26 506 27 910 810 408 360 |
|||
10-13-2014, 07:30 PM
Post: #3
|
|||
|
|||
RE: (HP-42S) CARDIAC
Very cool. Kind of reminds me of the Manchester Small-Scale Experimental Machine emulator I wrote on my TI-92 back in high school. It was several orders of magnitude slower than the real thing; I imagine this CARDIAC simulator doesn't have the same problem.
|
|||
10-13-2014, 09:06 PM
Post: #4
|
|||
|
|||
RE: (HP-42S) CARDIAC
Loading and running the gcd-program above took ~42s while just running it took ~21s.
I used Christoph Giesselink's Emu42 but in my experience its speed is close to the original. Could you write useful programs with your emulator? Have you been running one of the first programs? |
|||
10-13-2014, 09:27 PM
Post: #5
|
|||
|
|||
RE: (HP-42S) CARDIAC
I don't recall programming anything terribly sophisticated with it. The original machine had only 7 instructions - one of them being stop - and no add instruction, just subtract and a combined load/negate. I was able to run various example programs on it, though, including one that would scroll a simple bitmap graphic across the "display" (very, very slowly, in the case of my emulator).
The TI-92 variety of Basic requires a lot of string handling for the type of indirection I was doing, so I wouldn't be surprised if the 42S could emulate it faster. |
|||
10-16-2014, 09:49 PM
Post: #6
|
|||
|
|||
RE: (HP-42S) CARDIAC
Factor
This is a very simple CARDIAC-program to find the factors of a number: Code: 03 0 ; DATA As long as you don't use self-modifying code it can be translated 1:1 to the HP-42S: Code: LBL "FACTOR" ; start Just make sure to initialize registers 00, 03 and 04 with 1, 0 and 2: 1 STO 00 0 STO 03 2 STO 04 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)