A CPU that uses Chicken++ as its assembly language, implemented using hneemann's Digital circuit simulator.
Digital 'Program memory' utility uses little endian format to store and load data.
- In order to read a new character from user in, you must first write to user in. The value that you try to write will be thrown away. This is implemented internally with the READ opcode, but must be done manually if using LOAD or PRINTMEM. This is due to the internal construction of the memory unit that interfaces with user input and output.
- Another line?
The valid instructions for Chicken++ are as follows
Number of Chickens | Double Wide | Name | Chicken Name | Clock Ticks | Description |
---|---|---|---|---|---|
0 | no | return/exit | axe | 16 (return) / infinite (exit) | Returns from the current subroutine, or if no subroutine exits the program. |
1 | yes | push | lay (an egg) | 6 | Pushes the value of the second portion of the instruction to the stack. |
2 | no | pop | pluck | 6 | Pops the topmost value from the stack and discards it. |
3 | no | add | hatch | 8 | Pops the two values from the top of the stack, adds them together, and pushes the result back onto the stack. |
4 | no | subtract | fox | 8 | Pops the top two values from the stack, subtracts the second from the first, and pushes the result back onto the stack. |
5 | no | multiply | rooster | 8 | Pops the top two stack values, multiplies them, and pushes the result to the top of the stack. |
6 | no | divide | divide | 8 | Pops the top two values from the stack, divides the first by the second using integer division, and pushes the result back onto the stack. |
7 | no | negate | antichicken | 7 | Pops the top value from the stack, negates it, and pushes the result back onto the stack. |
8 | no | read | cookbook | blocks | Reads a single char from usrin and pushes it to the stack. Blocks until a char is available. |
9 | no | char | squawk | 6 | Pops the topmost char from the stack and prints it to usrout. |
10 | no | memchar | BBQ | 9 | Pops the top two values from the stack, then prints a value from memory to usrout, using the first value as device ID and the second value as the address. |
11 | no | draw | scratch | 11 | Pops the top three values from the stack, and draws the color specified by the thord value on the screen at the x-y coordinates specified by the first and second values. |
12 | no | load | pick | 9 | Pops the top two values (a and b) off the stack, and then pushes the data stored at address a of memory device b. |
13 | no | store | peck | 9 | Pops the top three values (a, b, and c) off the stack, then writes c to address a on memory device b. |
14 | yes | compare | compare | 10 | Pops the top two values (a and b) off of the stack and computes a - b. If the PZN value of the result matches any of the PZN bits given in the next line, a 1 is pushed to the stack, else a 0 is pushed to the stack. |
15 | no | jump | jump | 8 (jump) / 7 (no jump) | Pops the top two values (a and b) from the stack, and sets PC to a if b is not equal to zero. |
16 | no | gosub | flap | 19 (jump) / 8 (no jump) | Pops the top three values (a, b, and c) off the top of the stack and goes to the subroutine at address a of device b if c is not equal to zero. |
17 | no | swap | dance | 9 | Swaps the top two values on the stack. |
18 | no | and | rice | 8 | Pops the top two values (a and b) off the stack and then pushes the value a & b. |
19 | no | or | theegg | 8 | Pops the top two values (a and b) off the stack and then pushes the value a | b. |
20 | no | not | cow | 7 | Pops the top value (a) off the stack and pushes ~a. |
21 | no | leftshift | left | 8 | Pops the top two values (a and b) off the stack and then pushes the value a << b. |
22 | no | rightshift | right | 8 | Pops the top two values (a and b) off the stack and then pushes the value a >> b. |
23 | no | modulo | giblets | 8 | Pops the top two values (a and b) off the stack and then pushes the value a % b. |