Principles Of Execution - The CPU
Written by Harry Fairhead   
Thursday, 10 January 2019
Article Index
Principles Of Execution - The CPU
Fetch
The Op Code
Jumps

Jumps

Finally just to show you that everything you could possibly want can be easily included in this simple processor architecture consider how you might implement a “jump to xxxx” instruction.

Normally the next instruction to be executed is in the next sequential memory location but a jump makes the instruction at xxxx the next one.

How can this be achieved? Easy!

Just make the PC register correspond to register address 00 (rather than general purpose register D as suggested earlier). Now consider what  "load PC from address aaaa” does. It loads the PC register with the value stored in “aaaa” and so makes this the next instruction. Not quite what was required but it isn’t difficult see how it can be modified to make it work exactly as specified.

But this brings us to the interesting topic of addressing modes and that’s another story.

To make a computer capable of doing everything you need a computer to do you also need to add to jumps a conditional jump. A basic jump instruction is used for form loops - sections of code that repeat. Conditional jumps are used to implement conditionals which we know better as if statements. Extending our design to this is very easy. You need another register, the condition code register, and now when a register is loaded you provide the logic to set bits in the condition code register. If the register is zero then you set the zero bit, if negative the negative bit and if positive the postitive bit. You now modify the jump instruction to include logic that can test the condition bits. So now you have conditional jump instructions like jmpeq for jump if equal to zero, jmpn for jump if negative and so on. You should be able to see how to implement this - the condition bits simply enable or disable the loading of the PC register.

With conditional jumps our computer can now do everything - it is Turing Complete.

Beyond Fetch-Execute

If you know about modern processors you might be raising objections that this is not how they work. This is partly true. The first computers worked exactly as described but over time the fetch-execute cycle has been tweaked to make the machine work faster. In particular the fetch cycle, decoding and execution cycle are generally stretched out so that on a clock pulse an instruction is fetched while earlier instructions are decoded, and executed at the same time. This is generally called a pipeline and it is use by most modern machines but it is just a development on fetch-execute. Modern processors are so developed that you might have trouble seeing the simplicity of how they work but at the bottom it is still a fetch execute cycle that is responsible for computation.

 

What Programmers Know

knowcover

Contents

  1. The Computer - What's The Big Idea?
  2. The Memory Principle - Computer Memory and Pigeonholes
  3. Principles of Execution - The CPU
  4. The Essence Of Programming
  5. Variables - Scope, Lifetime And More
  6. Binary Arithmetic
  7. Hexadecimal
  8. Binary - Negative Numbers
  9. Floating Point Numbers
  10. Inside the Computer - Addressing
  11. The Mod Function
  12. Recursion
  13. The Lost Art Of The Storage Mapping Function *
  14. Hashing - The Greatest Idea In Programming
  15. XOR - The Magic Swap
  16. Programmer's Introduction to XML
  17. From Data To Objects*
  18. What Exactly Is A First Class Function - And Why You Should Care^
  19. Stacks And Trees
  20. The LIFO Stack - A Gentle Guide*
  21. Data Structures - Trees
  22. Inside Random Numbers
  23. The Monte Carlo Method
  24. Cache Memory And The Caching Principle
  25. Data Compression The Dictionary Way
  26. Dates Are Difficult
  27. Magic of Merging
  28. Power of Operators
  29. The Heart Of A Compiler
  30. The Fundamentals of Pointers
  31. Public Key Encryption
  32. Quick Median
  33. Functional And Dysfunctional Programming*

* Recently revised

Python

 



 

Comments




or email your comment to: comments@i-programmer.info

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, Facebook or Linkedin.

Banner


The Memory Principle - Computer Memory and Pigeonholes

We discover why computer memory can be likened to pigeonholes and even include instructions for you to build your own memory device.



Introduction to Boolean Logic

It may sound like a daunting topic, but Boolean logic is very easy to explain and to understand. It represents the simplest of all the logics and the very basis of computing.


Other Articles

<ASIN:1584504951>

<ASIN:0201000237>

<ASIN:0596526865>

<ASIN:0123744938>

<ASIN:1844254402>

<ASIN:0789736136>

<ASIN:0130620130>

 

 



Last Updated ( Thursday, 10 January 2019 )