Scrap Mechanic

Scrap Mechanic

Not enough ratings
SuperCPU: Scrap Mechanic's Most Powerful CPU's Guide
By PrincH2A
Learn How My SuperCPU Works & How To Program It Yourself!
   
Award
Favorite
Favorited
Unfavorite
Introduction
This Is A Detailed Guide On How The SuperCPU Works & How To Program It Yourself!

CHECK OUT THIS CPU RUNNING PLAYABLE TETRIS GAME HERE!

ⓘ Helpful Note For Easier Reading:
The guide will be split into sections, you can jump between them using the "Guide Index" on the right side of your screen at any time.

Also yes some aspects of this CPU are inspired by the real life 6502 CPU :)


User Interface
Contents Of This Section:
  • All User Interfaces On The SuperCPU                                                                               


  • All User Interfaces
    Here you'll find descriptions of all user interfaces on the SuperCPU.
Main Controls
     
  • Left Yellow Switch:
    Activates single stepping mode, combine with the button near it to single step the CPU's clock.
        🛈 CPU must be turned on via the green switch for this to take effect.

  • Left Dark Yellow Button:
    Combine with the yellow switch to single step the CPU's Clock.

  • Left Yellow Logic Gate:
    Outputs the CPU's clock if you wanted to hook up other external devices to the CPU's clock.


  • Middle White Button:
    Resets ALL the CPU's Internal Registers to 0, except the Stack Pointer that gets reset to FFFE (hex).

  • Middle Green Switch:
    Main power switch, turns on the clock and starts the whole CPU.
        🛈 Do NOT spam this switch way too quick, its not made to be spammed.


  • Right Light Red Switch:
    This is an input to the Interrupt flag bit on the flags register, updating that flag as said in the flags section will make it read this switch.

  • Right Red Switch:
    IRQ Interrupt Trigger.

  • Right Red Button:
    NMI Interrupt Trigger.

  • Right Red Logic Gate:
    Indicates whether the CPU is inside of an interrupt or not. Off = outside of an interrupt.
        🛈 Learn more about Interrupts in the interrupts section.

Overview
     
  • Letter Blocks Indicating Internal Registers:
    All Internal registers' currently stored data is visible through the Logic Gates next to these Letter Blocks that indicate which register is which.
    Here's a list of what the letters indicate:
    • P-> Program Counter
    • S-> Stack Pointer
    • M-> Memory Address Register
    • X-> X-Register
    • Y-> Y-Register
    • A-> A-Register
    • L-> ALU
    • C-> Carry output from ALU
    • B-> B-Register
    • H-> H-Register
    • T-> Step Counter
    • F-> Flags Register
    • I-> Instruction Register
    And here's a diagram showing how the registers are connected:

IO-Chip: Port-A
     
  • Red Line Of Logic Gates Next To The Letter A:
    Port-A's Output register, can be written to and read back by the CPU.

  • Green Line Of Logic Gates Next To The Letter A:
    Port-A's Input pins, can be fed a value by the user or any external device and be read by the CPU.

  • Right Yellow Logic Gate:
    Flashes when Port-A's register is set into Timer Mode and finishes the time.


IO-Chip: Port-B
     
  • Red Line Of Logic Gates Next To The Letter B:
    Port-B's Output register, can be written to and read back by the CPU.

  • Green Line Of Logic Gates Next To The Letter B:
    Port-B's Input pins, can be fed a value by the user or any external device and be read by the CPU as well as get latched onto the port's register.


🛈 Know more about the IO-Chip in the IO-Chip section

Data Bus
     
  • Red 24-Logic Gates:
    This is the Data Bus, used to share information internally & externally.


Address Bus
  • 4 Sets Of Yellow 16-Logic Gates:
    These are the Address Bus, yes all of them are one thing, each row is the output of a different register but all columns get ORed in the RAM to act as one set of 16-gates.


Read & Write Pins
  • Light Blue W Letter Logic Gate:
    This indicates that the CPU is trying to write data to an external device.
        🛈 The logic gate itself needs to stay purple to function.

  • Pink R Letter Logic Gate:
    This indicates that the CPU is trying to read data from an external device.
        🛈 The logic gate itself needs to stay purple to function.

RAM Programming
     
  • Dark Blue Switches:
    defines the most significant 8-bits of the word which is used to define instructions in.

  • Bright Blue Switches:
    defines the least significant 16-bits of the word which is used to define the parameter of the instruction.

  • Yellow Switches:
    defines the address to point at in the RAM.

  • Light Blue Button:
    saves the current data (instruction & parameter) at current location
    specified by yellow address switches.


  • Pink Switches:
    shows the contents of the current address pointed at by the yellow address switches.


Instruction Programming
     
  • Green Switches:
    defines the instruction opcode.

  • Yellow Switches:
    defines the step of the instruction.

  • Red Switches:
    defines the flags of the instruction.

  • Light Blue Button:
    saves the current chosen control signals to the exact combination of selected flags, instruction opcode and step.

  • Brown Switches:
    Used to reprogram the default instructions if the PROM gets reset.

        🛈 Check Control Signals (2/2) section notes to know more about default
            instructions and their opcodes..


Control Signals
     
  • Control Signal Switches:
    Every switch corresponds to the Letter blocks infront of and behind it.
Hardware Specs & Registers
Contents Of This Section:
  1. Quick Hardware Specs
  2. Registers & Their Functions                                                                                           


1. Quick Hardware Specs
  1. Clock Speed
    One of the SuperCPU's main strengthes is the fact that the Clock Speed can be ANY number you want it to be!
    🛈 Know more in the Clock Speed & How To Change It section.
  2. Register Amount
    The CPU has a total of 9-usable registers to store data in, tho only 5 of them are actually made to store user/program data and not things like addresses or instructions.
  3. Subroutines Capable
    Really this CPU is capable of anything with the extreme flexibility it gives you, sky is your only limit!
  4. Instructions & Instructions PROM
    The CPU can have upto 256 different instructions that are fully customizable by the user and are stored in the CPU's instructions PROM. Any instruction can be a super complex 31-step instruction that can have conditional & unconditional loops within itself.
    🛈 Know more in the DRAM & Instruction PROM Programming section.
    🛈 PROM is short for Programmable Read Only Memory
  5. Data RAM
    SuperCPU Comes with a 24-bit 65k RAM that can be manipulated by the CPU. Also comes with a PROM that stores the instruction's-control signals which can be manipulated by the player.
    🛈 Know more in the DRAM & Instruction PROM Programming section.
  6. Instruction Throughput
    Considering how the Clock Speed can be basically anything then the throughput is dependent on how fast you set the clock speed, can be in the hundreds or even higher!.
  7. Screen
    The CPU comes with a 32x32 Screen which can be fully rendered by the CPU.
    🛈 Know more in the Screen section.
  8. Interrupts
    The SuperCPU allows for 2 kinds of interrupts, IRQ and NMI each with different uses and conditions,
    🛈 Know more in the interrupts section.
  9. IO-Chip
    To make interfacing with the CPU easier i made a dedeicated IO-Chip with IO-ports that act as inputs and outputs.
    🛈 Know more in the IO-Chip section.
  10. Flags
    The CPU Comes with 5 case flags and a control flag to enable/disable incoming interrupts.
    🛈 Know more in the Flags section.
  11. Stack
    The CPU comes with a 16-bit stack pointer that can access the whole 65k Data RAM. Also defaults to FFFE in hex whenever it gets reset.


2. Registers & Their Functions
Name
Function And Description
Size
A-Register (Also Known as Accumulator)
This is the main register that can do Shift OR Rotate operations to the right or left, as well as bitwise operations with the B-register, can switch from acting as a 16-bit register to a 24-bit one or back.
24-bits
ALU
This is the main ALU of the CPU that can add A-reg and B-reg or subtract B-reg from A-reg.
16-bits
B-Register
This is a basic Register.
16-bits
H-Register
Hold Register, this only takes its input from whatever the ALU is holding, ignores the Data Bus.
16-bits
Step Counter
This is both a counter and a register, it is what decides the step the instruction is on, can be written to by any instruction (allowing an instruction to loop in itself conditionally or unconditionally)
5-bits
Flags Register
Flags register (or status register), holds the specific set flags.
🛈 Know more about Flags in the Flags section.
6-bits
Instruction Register
Here is where every instructions gets executed, this register is split into 8-bits for the instruction and 16-bits for the parameter.
24-bits
Program Counter
Counter and register, starts off at 0000 (hex) and counts up every time there's a fetch.
16-bits
Stack Pointer
Counter and register, starts off at FFFE (hex) and can be controlled to count up or down via any instruction.
16-bits
Memory Address Pointer
Basic Register to point at some location in ram, cannot put its contents on the Data bus.
16-bits
X-Register
Register that can Increment, decrement and shift to the left only.
16-bits
Y-Register
Register that can increment and decrement only.
16-bits

Here's A Diagram I Made To Show How The Internal Components Are Laid Out And Connected Together:
🛈 The number next to each name is the register-size
Clock Speed & How To Change It
Contents Of This Section:
  1. Base Clock Speed
  2. How To Increase Clock Speed And Calculate Current Clock Speed                              


1. Base Clock Speed
Base clock speed is actually only 5.71hz but.. you can increase it to ANY amount you'd like!

2.a Changing The Clock Speed
  1. Aim at any of the Logic gates on the creation then press "Upgrade" button bound to "T" by default.

  2. Look in chat til it says "Speed Factor=" followed by a number, that'll be the multiplier of the clock speed, so if you set it at 2x it'll be 2 times faster.
      🛈 My favorite speed factors to run the CPU at are 256x or 128x

    ⓘ Important Notes:
    • The higher you make it the laggier it'll get so do NOT go too high.

    • If you want to decrease the Speed Factor then press crouch bound to "CTRL" by default AND upgrade bound to "T" by default.

2.b Calculating The Clock Speed
  • Simply multiply
    5.71 * the Speed Factor you set it to
    For example if you set it to 128x then the Clock Speed would be:
    5.71 * 128 = 730Hz
DRAM & Instruction PROM Programming
Contents Of This Section:
  1. What Is Data RAM & How To Program It
  2. What Is Intrusction PROM & How To Program Instructions on it                                 


1. Data RAM
Description: Data RAM is where all your programs and instructions get loaded into and stored for the CPU to execute one after the other, the CPU can read or write to it at any given moment.

Size: 24-bit long 65k RAM.

Programming: The CPU comes with a manual programmer for the RAM which is:
  • Dark Blue Switches:
    defines the most significant 8-bits of the word which is used to define instructions in.

  • Bright Blue Switches:
    defines the least significant 16-bits of the word which is used to define the parameter of the instruction.

  • Yellow Switches:
    defines the address to point at in the RAM.

  • Light Blue Button:
    saves the current data (instruction & parameter) at current location
    specified by yellow address switches.


  • Pink Switches:
    shows the contents of the current address pointed at by the yellow address switches.

🛈 Note: A piece of data in RAM can be treated as both instruction or a 24-bit word of data, depends on how you program the CPU to do it.

🛈 Note: Each nibble is colored a slightly different shade of color to make it easier for the user.


2.a Instruction PROM
Description: Here is where all the Control Signals for each instruction is stored, meaning an instruction's behaviour can be FULLY changed by the user at any time, this is one of the SuperCPU's unique and super useful feauters, as it allows maximum flexibilty and therefor maximum efficiency.

Size: The address word for this PROM is 18-bits long and its divided as the following:
  • 8-bits for the instruction.
  • 5-bits for the steps.
  • 5-bits for the flags.

2.b Programming Instructions:
With the CPU also comes another manual programmer for programming this Instruction PROM, which consists of 2 parts:
  • "Control Signals".
  • "Instruction Programming".
Now lets say you want to program an instruction, here's a step by step guide on how to:

Firstly
  • Go to the "Instruction Programming" section on the CPU and set the opcode you want for your instruction via the green switches. Now any thing you do will be set to that instruction with that opcode.

Secondly
  • Now you need to set the step you want the instruction to perform the task on/at via the yellow switches, the MINIMUM step is 00001 as step 00000 is used to fetch the instruction itself and cannot be used to perform other things.

Thridly
  • You now have the opcode and step selected, now you can choose to either make your instruction work at a specific combination of flags via the red switches (know more about flags in the flags section) OR you can make it unconditional by leaving the red switches completely off.

Lastly
  • Go to the "Control Signals" section and select what you want the instruction to do at that step at those flags you chose and press the Light Blue "SAVE" button on the side of the "Instruction Programming" section when you've decided the Control Signals for that step.

    🛈 you have to save on every step, so its basically 'set wanted control signals -> save -> next step -> repeat'
Continue to the next section to learn about control signals
Control Signals (1/2)
Contents Of This Section:
  1. What Are Control Signals
  2. List Of Control Signals & What They Do                                                                        


1. What Are Control Signals?
  • Control Signals are what make up an instruction, for example an instruction that "Puts A-Register's value onto X-Register, increments it and puts it back into A-Register" would have these Control Signals at those Steps:
    Step
    Control Signal
    Control Signal
    Step 00001 (1)
    AO (A-Reg Out On Data Bus)
    XI (X-Reg In From Data Bus)
    Step 00010 (2)
    XU (X-Reg Count Up)
    Step 00011 (3)
    XO (X-Reg Out On Data Bus)
    AI (A-Reg In From Data Bus)

  • As you saw, you can completely change what an instruction does at every step and at every flags combination.

  • Also each control signal has a 2 letter name to indicate it which is written on the CPU's control signal programmer here using letter blocks:



2. List Of Control Signals & What They Do

ⓘ Important Notes:
  • "DB" Is short for Data Bus.
  • "AddB" Is short for Address Bus.
  • "OUT" Means show its content on the DB.
  • "IN" Means load data from the DB (except for H-Register that loads from the ALU's output).

Number
Name
Description
1
DR
Makes currently selected external device (such as Data RAM or IO Chip) show its content on DB
2
DW
Tells currently selected external device (such as Data RAM or IO Chip or Screen) to save the data currently on the DB
🛈 Know more about The Screen and IO-Chip and Data RAM in the sections of this guide.

3
PO
Makes Program Counter show its data on the DB
4
PA
Makes Program Counter show its data on the AddB
5
PU
Makes Program Counter count up
6
PD
Makes Program Counter count down
7
PI
Makes Program Counter load the data currently on the DB

8
SO
Makes Stack Pointer show its data on the DB
9
SA
Makes Stack Pointer show its data on the AddB
10
SU
Makes Stack Pointer count up
11
SD
Makes Stack Pointer count down
12
SI
Makes Stack Pointer load the data currently on the DB


13
MA
Makes The Memory Address Pointer show its data on the AddB
14
MI
Makes The Memory Address Pointer load the data currently on the DB

15
IO
Makes The Instruction Register show its data on the DB
16
II
Makes The Instruction Register load the data currently on the DB

17
TI
Makes The Step Counter load the data fed by the next Control Signals to jump to another step of the same instruction, allowing an instruction to loop within itself conditionally and unconditionally
18
TG
Step Counter 5th input bit
19
T8
Step Counter 4th input bit
20
T4
Step Counter 3rd input bit
21
T2
Step Counter 2nd input bit
22
T1
Step Counter 1st input bit

23
FO
Makes The Flags Register show its data on the DB
24
FI
Makes The Flags Register load the data currently on the DB

25
AO
Makes The A-Register show its data on the DB
26
AS
Makes The A-Register shift its bits
🛈 Rotating is the same as shifting except the bit that gets shifted out the registet gets fed back from the other side
27
AR
Makes The A-Register rotate its bits
28
AM
Switches A-Register's mode from behaving as a 24-bit register to a 16-bit register. Off = 24-bit mode
29
AD
Switches A-Register's shift/rotate direction from right to left. Off = right.
30
AI
Makes The A-Register load the data currently on the DB

31
BO
Makes The B-Register show its data on the DB
32
BI
Makes The B-Register load the data currently on the DB


33
HO
Makes The H-Register show its data on the DB
34
HI
Makes The H-Register load the current output of the ALU. Ignores the bus
🛈 Doesn't need LO to be on

35
LO
Makes The ALU show its data (which is A-reg + B-reg by default) on the DB
36
LC
Turns on the Carry In of the ALU's adder, simply adds 1
37
LB
Makes The ALU turn into subtracting mode, needs to be on to stay in subtracting mode
🛈 To output a subtraction's answer on the DB you need to have both LO and LB on at the same step
🛈 Its recommended to have a step to 'cook' the subtraction meaning to have LB on the step before you output it using LO and LB together

38
&O
Outputs the Bitwise AND operation of A-Register and B-Register on the DB
39
+O
Outputs the Bitwise OR operation of A-Register and B-Register on the DB
40
*O
Outputs the Bitwise XOR operation of A-Register and B-Register on the DB
41
!O
Outputs the Bitwise NOR operation of A-Register and B-Register on the DB
42
^O
Outputs the Bitwise XNOR operation of A-Register and B-Register on the DB
🛈 To do a NAND bitwise operation you'll need to do an AND then a NOR

43
XO
Makes the X-Register show its data on the DB
44
XU
Makes the X-Register count up
45
XD
Makes the X-Register count down
46
XS
Makes the X-Register shift to the left
47
XI
Makes the X-Register load the data currently on the DB

48
YO
Makes the Y-Register show its data on the DB
49
YU
Makes the Y-Register count up
50
YD
Makes the Y-Register count down
51
YI
Makes the Y-Register load the data currently on the DB

52
FZ
Updates the Zero flag
53
FN
Updates the Negative flag
54
FC
Updates the Carry flag
55
FO
Updates the Overflow flag
56
FE
Updates the Equal flag
57
FI
Updates the Interrupt flag
🛈 This takes its input from the red top switch on the side of the CPU. Know more in the User Inputs Section

Control Signals (2/2)
Number
Name
Description
58
RI
Returns from Interrupt, used in "Return From Interrupt" instruction.
🛈 Know more about interrupts in the interrupts section

59
RD
Disables the Data RAM to allow the CPU to communicate with other devices (like the Screen or the IO-Chip) with out interfering

60
P3
Peripheral input, used to communicate with the IO-Chip
61
P2
Peripheral input, used to communicate with the IO-Chip
62
P1
Peripheral input, used to communicate with the IO-Chip
🛈 Know more about the IO-Chip in the IO-Chip section

ⓘ Important Notes:
  • Control Signals number: 38, 39, 40, 41, 42 when all combined and activated will halt the CPU (its intended).

  • All control signals on the CPU are numbered and synced with the ones here.

  • The CPU comes with 3 pre-loaded default instructins which are
    1. Reset Instruction [RST]: Tiggered by the Reset Button and clears all registers but not RAM.
        🛈 Works with any flags.
    2. Interrupt Instruction [INT]: Triggered by the interrupt inputs and jumps to the interrupt vector.
        🛈 Only works with the flags 00000.
    3. Return From Interrupt Instruction [RFI]: Triggered by Opcode "11111110" or "FE" In Hex, It Returns from an interrupt and does the return sequence.
        🛈 Only works with the flags 00000.
        🛈 Know more about interrupts in the interrupts section.

  • If you ever end up resseting the Instructions PROM
    🛈 there's a red button to the bottom left of the word PROM that resets it
    you can use the brown switches found on the "Instruction Programming" section of the CPU programmers to rewrite the 3 default instructions for you, activate them one by one, no more than 1 at once.

  • The CPU Uses the Opcodes: FF, FE in HEX for Resetting and interrupt handling instructions so do NOT write over those opcodes.
Flags
Contents Of This Section:
  1. What Are Flags And Why Do We Need Them?
  2. The Flags Register & How The SuperCPU Handles Flags                            


1.a What are Flags?
Flags are indicators of specific things happening in the CPU at the moment.
for example a flag could be "Is A-Register equal to zero?" and if it was, then that specific bit in the flags register would get turned on!

1.b Why Do We Need Flags?
Having Flags and allowing the instructions to be affected by said flags and do different things depending on which flag was on allows for conditional instructions which allows the CPU to be turing complete.
In other words it allows the CPU to compute anything that is computable.


2.a Flags Register
Also referred to as "Status Register" is a register of X amount of bits with each bit corresponding to some specific case such as Is A-Register equal to zero?.
2.b SuperCPU's Flags Register
On the SuperCPU the flags register is a 6 bit register with the current layout:
  • First Bit (least significant, rightmost): Called the "Interrupt" Flag, this is the only special flag as this doesnt detect a condition but rather controls whether the CPU should accept incoming IRQ interrupts or not.
      🛈 Know more about interrupts in the Interrupts section

  • Second Bit: Called the "Equal" Flag (E for short) which is turned on whenever A-Register equals B-Register and the flag gets updated.

  • Third Bit: Called the "Overflow" Flag (O for short) which is turned on whenever an overflow happens and the flag gets updated. Overflow happens when two negative numbers are added and the answer comes positive or when two positive numbers are added and an answer comes as negative.

  • Forth Bit: Called the "Carry" Flag (C for short) which is turned on when a carry occurs and the flag gets updated. A carry occurs when an addition is too big to fit in 16-bits it produces a carry, or when a subtraction gives out a negative/signed number.

  • Fifth Bit: Called the "Negative" Flag (N for short) which is turned on when the most significant bit (sign bit) of the A-Register is on or not and when the flag gets updated.
    Note: if A-Register is set to 16-bit mode it'll detect the 16th bit and if its set to the 24-bit mode it'll detect the 24th bit as the sign bit.

  • Sixth Bit (most significant, leftmost): Called the "Zero" Flag (Z for short) which is turned on whenever A-Register equals zero and the flag gets updated.

ⓘ Important Note:
  • "the flag gets updated" is referring to how any instruction can update any flag independently.
      🛈 Know more in the DRAM & Instruction Programming section
IO-Chip
Contents Of This Section:
  1. What Is The IO-Chip?
  2. How It Works & How To Program It                                                              


1. What Is The IO-Chip?
The IO-Chip is a device made to make interfacing with the SuperCPU easier and quicker as it has 2 Ports that act as both inputs and outputs for the CPU to read & write from/to.
   🛈 IO stands for Input/Output


2.a How It Works
The IO-Chip has 2 IO Ports which are:
  • Port-A:
    1. The Register: A 24-bit Register that can be read from and written to by the CPU.

      • Special Feature: Can also be turned into a timer/counter that gets set to a certain value then counts down til 0 giving off a signal then restarting from said value.

    2. The Input: a 24-bit long line of input pins that the CPU can read at any given moment without interfering with the register.

  • Port-B:
    1. The Register: A 16-bit Register that can be read from and written to by the CPU.

    2. The Input: a 16-bit long line of input pins that the CPU can read at any given moment without interfering with the register.

      • Special Feature: Any data from the input pin gets latched into the Port-B Register.
2.b How To Program It
The SuperCPU communicates with the IO-Chip via the last 3 control signals.
   🛈 Know more about the peripheral control signals in the Control Signals (2/2) section.

The last 3 control signals are used as a 3-bit binary number to decode 8 possible communications between the CPU and the IO-Chip, here's how its decoded:
    The Last 3 Control Signals In Binary
    The Selected Function
    000
    IO-Chip Unselected
    001
    Port-A Register IN (from the Data Bus)
    010
    Port-A Register OUT (to the Data Bus)
    011
    Port-A INPUT Read (read external input pins of this port into the Data Bus)
    100
    Port-B Register IN (from the Data Bus)
    101
    Port-B Register OUT (to the Data Bus)
    110
    Port-B INPUT Read (read external input pins of this port into the Data Bus)
    111
    Switch Port-A Register into Timer Mode.
      Timer Mode
      When in timer mode, whenever the Port-A's Register gets fed a value it'll start counting it down to 0, giving off a signal through the yellow gate next to it and restarting from said value.
ⓘ Important Notes:
  • You must have "Ram Disable" control signal on when communicating with the IO-Chip or else it'll interfere with the RAM.

  • You still need to use Data Bus Write (DW no.2) & Data Bus Read (DR no.1) control signals to actually read or write anything from/to the IO-Chip.
The Screen
Contents Of This Section:
  1. About The Screen
  2. How The SuperCPU Renders It                                                                    


1. About The Screen
The screen is a very simple 32x32 array of logic gates that essentially acts as a big register that you change each of its bits separately.


2. How The SuperCPU Renders It
Using the Memory address pointer the SuperCPU can write to any of the screens pixels starting from the top left at address 7C00 (hex) to the very bottom right pixel at address 7FFF (hex).

ⓘ Important Notes:
  • The screen takes the first bit of the bus as the pixel Data.

  • Using the program counter or stack pointer to update screen pixels wont work, the screen only accepts the memory address pointer to write to its pixels.
Interrupts
Contents Of This Section:
  1. What Are Interrupts?
  2. SuperCPU Interrupts & How It Handles Them                                                               


1. What Are Interrupts?
Interrupts basically are the user Interrupting the CPU while executing a program to stop what its doing and go execute another program then go back to the first one.


2.a SuperCPU's Interrupts
The SuperCPU comes with 2 kinds of Interrupts, here's a list of what they are and how they work:
    Name
    Function
    IRQ (short for Interrupt Request)
    Triggers an interrupt and retriggers as long as the input is held and the Interrupt flag bit is turned off
    NMI (short for Non-maskable Interrupt)
    Triggers an interrupt on the rising edge of the input only once no matter how long the input is hed, doesn't care about the flag bit

2.b How The SuperCPU Handles Interrupts
On interrupt request (from either interrupt inputs) the CPU waits for the next 00000 step
(aka "fetching step") and then triggers the interrupt instruction which does the following:
  • Pushes the Program Counter onto the stack
  • Pushes the Flags Register onto the stack
  • Goes to address FFFF (hex) which is the "interrupt vector" and executes whatever instruction is there
        🛈 you can make it jump to somewhere else from there

    2.c Returning From Interrupts
    The CPU comes with a default instruction to return from interrupts called RFI (short for return from interrupt) thats capable of returning to the right addres it came from.

    ⓘ Important Notes:
    • The stack must be at the right location so if you counted it up within an interrupt you
            must count it back down before returning.

    • Check Control Signals (2/2) section notes to know more about default instructions and their opcodes.

Stack
Contents Of This Section:
  1. What Is The Stack?
  2. How The Stack Works In The SuperCPU                                                               


1. What Is The Stack?
Stack is a programmer's best friend as it allows an easy and quick way to store values at any given time, and easy and quick way to restore those values.


2. How The Stack Works In The SuperCPU
The SuperCPU has a 16-bit stack pointer which is a register & counter that can count up and down.

To make an instruction to push (for example) A-Register onto the stack all you need to do is program it like this:

Control Signals
Step
Description
AO
00001
Puts A-Register's data out on the Data Bus
SA
00001
Makes the Stack Pointer show its data on the Address Bus to point at some where in RAM
DW
00001
Tells the RAM to write the given Data at the given Address
SD
00001
Counts down the Stack pointer to point at the next address and be ready for another push
    🛈 To make an instruction that pulls the value you must count up stack first then read the         value at the pointed address

And just like that you can make an instruction push the data of Any register onto the stack in one step


Thats It!
I hope you enjoyed! This took a long time to make so dont forget to
11 Comments
Piano Man May 18, 2023 @ 5:05pm 
mhz? core amount? just curious
PrincH2A  [author] May 10, 2023 @ 5:54pm 
lol what even
WyvernQuester May 9, 2023 @ 11:46am 
my pc needs it
WyvernQuester May 9, 2023 @ 11:46am 
now make a guide for irl cpu cooling please
Piano Man Nov 17, 2022 @ 5:08pm 
good game!!!!
PrincH2A  [author] Nov 12, 2022 @ 4:38am 
ah pog gg
Piano Man Nov 12, 2022 @ 4:02am 
gg?
PrincH2A  [author] Nov 11, 2022 @ 4:42pm 
@Piano Man

what even? XD
Piano Man Nov 11, 2022 @ 3:35pm 
hg
PrincH2A  [author] Nov 7, 2022 @ 11:38pm 
@oil wow indeed