CPU 4917 for iPad manual

This application simulates a very simple microcomputer and behaves correspondingly. You should write your program on paper, then manually translate it to hexadecimal machine codes, enter it to the memory, and only then run it. Be prepared for debugging process!

 

What are registers, commands and codes of 4917?

There are two 4-bit general-purpose registers, R0 and R1. Feel free to use them. There is a 4-bit Instruction Point (IP) register, which you can use indirectly by commands D­­-F. There is a 8-bit Instruction Set (IS) register, which is unavailable to your programs.

You can see all commands & codes in the left tab of the application. Commands 0-7 are single-length, and commands 8-F are double-length (they use the next value as the argument). Here is detailed explanation:

Code

Description

0

Immediately stops the processor. Your program must contain at least one such command!

1

Calculates the sum R0+R1 (modulo 16) and places it to R0. There is no method to check if overflow happened.

2

Calculates the difference R0-R1 (modulo 16) and places it to R0. There is no method to check if the result is negative.

3

Increases R0 by 1 (modulo 16). There is no method to check if overflow happened.

4

Increases R1 by 1 (modulo 16). There is no method to check if overflow happened.

5

Decreases R0 by 1 (modulo 16). There is no method to check if the result is negative.

6

Decreases R1 by 1 (modulo 16). There is no method to check if the result is negative.

7

Rings a bell. Yes, it is pretty useless.

8x

Prints number x, followed by space. If you want to have a printable variable, you should store its value right after print command.

9x

Places content of memory location with address (x) to R0.

Ax

Places content of memory location with address (x) to R1.

Bx

Places content of R0 to memory location with address (x). Yes, you can change the program itself so be careful!

Cx

Places content of R1 to memory location with address (x). Yes, you can change the program itself so be careful!

Dx

Unconditional jump to address x.

Ex

Jump to address x if R0 contains zero.

Fx

Jump to address x if R0 is NOT zero.

How exactly this processor works?

It keeps in IP an address of command which must be executed next time. So, in the beginning of each cycle, the processor loads from memory the value at memory location (IP) into special internal register IS0 and increases IP by 1. If that loaded value is higher than 7, it loads from memory the value at memory location (IP) into special internal register IS1 and additionally increases IP by 1. Then it executes content of IS0 or IS0&IS1 as described above. Command D modifies IP, loading x into it; commands E and F also can do this depending on content of R0.

How to reset a computer?

Just turn power off and then turn it on with the switch in low-left corner. After such reset check the following:

·         All registers (IP,R0,R1) must contain zeroes.

·         All memory locations must contain zeroes.

·         In the “Memory” panel address 0 must be highlighted.

How to enter a program?

Check the switch “ADVANCE”. It should be in the RIGHT position.

Now just consequently enter your codes by pressing appropriate keys on keyboard (under “Input data”). E.g., to enter “803B1F” press 8, then 0, then 3 and so on. When you press a key, it loads a value into memory location with address (IP) and then increases IP. (If the switch “Advance” is in the LEFT position, there is no increasing, and you must change IP manually every time)

How to load a sample program?

Tap a “book” symbol in the left tab. You’ll see three sample programs with brief descriptions. Choose one and tap it. That’s all. Tap a “book” again to hide samples if you don’t want to load any of them.

It is highly recommended to explore these programs.

How to edit a program?

In the “Memory” tab press a button with desired address. This makes it active and loads it into IP. Then press a key on the keyboard to modify this memory location. Repeat this for each memory location you wish to change. You may want to set switch “ADVANCE” to the LEFT when editing your programs.

How to run a program? How to stop it?

Just press the “RUN/STOP” button. When program runs, it changes its color to red. When it’s red, press it to stop running.

Please note that program always starts from address 0 with zeroes in R0 and R1. The computer clears all registers automatically.

How to load, save or share a program?

This microcomputer has “external memory” which can be used to keep one program. It stores all 16 memory locations and remember them even you “turn power off” or even close the application!

To save your program first enter it to the memory, then press “SAVE” button in “STORAGE” tab. It is highly recommended to save a program before starting it the very first time.

To load your saved program just press “LOAD” button in “STORAGE” tab.

To share a program stored in internal memory, press “DUMP” button in “STORAGE” tab. The content of memory will be copied into system clipboard as the text string, in 4 groups of 4 digits. Now you can paste it to E-mail message, to document in your favorite text editor etc.

How to clear or save printer output?

Just use one of two keys near the “printer”. The left one clears it, and the right one copies its content to the clipboard.

How to debug a program?

Use the switches in “DEBUG” tab.

When “TRACE” mode is on, the computer prints “X:Y” or “X:YZ” every time it executes a command. Which means, “Y” or “YZ” command at address X was executed. This mode usually produces a lot of printed information, and it doesn’t fit to printer window. So use “copy” button as described above, and transfer all info to somewhere you can see and analyze it.

When “SLOW” mode is on, the computer executes commands very slow, about 1 command per second, and shows these commands in mnemonics. Sometimes it helps to understand what’s going on.

What if I meet a problem?!

Feel free to contact me. E-mail: michael.balandin@gmail.com; twitter: @MichaelBalandin

But please, use an appropriate subject! E-mail messages with “Help!” or “I got a problem!” can be classified as a spam.

Happy coding!