This is an abbreviated version of Assembly but the gist of it is in this code.
The CPU is made up of two parts.
The control unit is responsible for handlig the the instructions and sending data where it should be.
The ALU isresponsible for ecery calculation and stores the result in th Accumulator (AC)
We have a couple of registers where the processor stores the commands.
Here you store the actove instruction. o you know what to do.
Here you store where in the memory yher program is right now.
This register provides you with the address where the instruction can read data from or write data to.
This holds the data that has been fetched or isabout to be written to the memory address (MAR)
This stores the logical results produced by the ALU
Every instruction is has two parts. The first number is the instruction in it self and the second part is the address where the data is stored.
There are several instructions:
Every memory slot has an address so we know where it is in the RAM. In our abbreviated world the memory adress is two digits witch means that we only have 00 to 99 memory slots. in the real computer the address i much longer and therefore there are a lot more slots. After the addres there is an instruction and in our example the instruction consist of three digits but in a read computer the instruction is a lot longer. Our example:
00 505 ; Fetch from address 05 to AC
01 104 ; Add value in address 04 to AC
02 305 ; Store AC to address 05
03 000 ; Halt
04 034
05 103
Real computer example (16 bits):
A0 34 12 ; fetch from address 1234 to AC
04 05 ; add 5 to AC
A2 34 12 ; save AC to address 1234
In our example we use decimal system since its the system we are used to work with but in the other example we use hexadecimal system since that is tha system the computer allways use.
Use our system and write the code for adding five numbers with input and then output the result
Expand assignment 1 to also calculate the average using integer division of theese five numbers.