How does instructions is converted into actions in every microcontroller? - Page 1
Forum section: electronics / beginners

author: electrowhiz
author_rank: Contributor
timestamp: May 15, 2018, 06:26:14 am
content: If there is a instruction to copy the data from one register to another eg: MOV Reg1, reg2 . How does the micrcontroller understands this instruction and perform inner actions to move the data from one register to another?

author: taydin
author_rank: Frequent Contributor
timestamp: May 15, 2018, 06:30:05 am
content: Every CPU has an internal sequencer circuit that reads the current instruction from memory. Once the instruction is read, depending on the CPU architechture, either an internal state machine is put into gear to execute the current instruction (CISC), or that instruction is directly executed in one clock cycle (RISC).

author: Richard Crowley
author_rank: Super Contributor
timestamp: May 15, 2018, 06:35:32 am
content: One section of the CPU (Central Processing Unit) is the "Instruction Decoder" It decodes the bits of the instruction, identifies which command it is, and sends signals to the rest of the CPU to tell it what to do.

author: cowasaki
author_rank: Frequent Contributor
timestamp: May 15, 2018, 09:11:20 am
content: To simply this I can give you an example of a processor I just made up which uses 8 data bits with the first four as the OP code and the next four as the target.As the clock pulse hits the processor it increments the program counter which is connected to the memory which makes the memory's data line change to whatever is at that location.So we now have 8 bits of information to process. In our simple processor we can take the four OP code lines and decode this into 16 lines where one would be high for each different OP code. So we can now use those 16 lines to implement commands....We also do the same with the other four bits of information. In this case the "target" could be a particular 4 bit register. Using a simple logic circuit we could expose an internal four bit holder register Z to the contents of one of the 16 targets eg reg d,e,f,g etcNow we have the Z register set we can again use simple logic controlled by the 16 command lines to do something....So image we have the command "GET e" which is decoded as 00010010 then d would be the second nibble 0010 and GET would be the first 0001. The GET line would be high and due to our simple logic the internally used Z register would contain the contents of register d. We can now implement GET again using simple logic where the A accumulator now gets overwritten by the internal Z register.The command has now finished and the clock moves on.The next command might be "ADD f" which decodes as 00100100 or 0010 as ADD and 0100 as the f register. f is transferred to Z just like d was earlier and now the ADD line is high which causes the processor to ADD the Z register to the accumulator. etc etcThis explains in an extremely simplified way how anunusablysimple processor COULD work but in reality you would have your 8 bit command as MOV A,B or ADD A,C as op codes and op codes requiring memory locations would have these after the code so MOV A,(#8EF0) would be implemented as three bytes and the program counter moved on by the requisite amount as the other two bytes are read.Have a look on youtube around something like the 6502 eg

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 15, 2018, 09:23:16 am
content: Another awesome question from electrowhiz

author: dnwheeler
author_rank: Regular Contributor
timestamp: May 23, 2018, 10:16:35 pm
content: If you really want to know the details, Ben Eater has a great series of videos on YouTube, where he constructs an 8-bit processor on breadboards and thoroughly explains everything:https://www.youtube.com/playlist?list=PLowKtXNTBypGqImE405J2565dvjafglHUYou can also start from his web site:https://eater.net/8bit/