1 / 21

The CPU

The CPU. Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches . The CPU. The Central Processing Unit is one of the main parts of a computer It consists of; Control Unit (CU)

lot
Download Presentation

The CPU

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches

  2. The CPU • The Central Processing Unit is one of the main parts of a computer • It consists of; • Control Unit (CU) • The Arithmetic Logic Unit (ALU) • Registers

  3. Structure of the CPU Arithmetic Logic Unit Accumulator Control Unit Program Counter Instruction Register

  4. Parts of the CPU • Control Unit: The manager of the CPU, decodes instructions and controls the operations done by the ALU • Arithmetic Logic Unit: Arithmetic and logic operations are carried out. • Instruction register: Stores a copy of the current instruction being executed • program counter: Stores the address of the next instruction in the program to be executed • Bus: Transfer of data

  5. Assembly Language • The CPU uses what is known as Assembly Language • Assembly Language is made up of op-codes and operands • Instructions in assembly language are rather simple

  6. Assembly Language Operations A few examples

  7. Moving Data

  8. Computing Data

  9. Program Flow For more info: http://en.wikibooks.org/wiki/X86_Assembly/X86_Instructions

  10. Using Op-Codes (mnemonics) • Op-Codes are used instead of binary • Op - Codes are short words normally made up of 3 characters • When used they perform a function • Op-Codes are easier to remember by programmers, since their name refers to what they will perform

  11. Op – Code Examples

  12. Addressing • With Assembly Language, we have three ways in which the computer can find locations from memory; • Absolute Addressing • Relative Addressing • Symbolic Addressing

  13. 9 10 11 12 13 LDA 10 Absolute Addressing • When we use Assembly Language different memory locations are used • In some cases we can actually specify which memory location we wish to use (example, LDA 10 is specifying that the accumulator should be filled with the contents found in memory location 10)

  14. Bx Bx+1 Bx+2 Bx+3 Bx+4 Note: BX is the base address MOV CX,[BX+4] Relative Addressing • This is indicated by specifying the distance from another address • In this case it is called the base address, hence the exact memory location is not given (example, MOV CX, [BX+4] is specifying that the contents of Register C must be moved in the location which is found 4 locations off register B)

  15. 103 104 105 106 107 NUM1 LDA NUM1 Symbolic Addressing • A label can be given to a memory location in assembly language • Instead of referring to the memory location by the location a label is used. • The memory location 106 can be assigned a label Num1, and from then on, whenever location 106 is required, instead of calling memory location 106, Num1 is called, LDA Num1.

  16. Conditional & Unconditional branches • The program counter (PC) found in the CPU points to the next instruction to be fetched • If we change the PC, instructions can be executed in a different order not in a sequence • In order to use jump instructions, labels must be used. Labels can be created by simply specifying a label name and adding a colon at the end of the label. For example: label1: mov ax,5 mov bx,3

  17. Unconditional Jump • This type of branching instructs the processor to jump to a label without any conditions. • The command is JMP movax, 5 jmplab1 add ax, 4 lda10 lab1: sub ax, 3 When the JMP command is encountered, the flow of the program will resume from the specified label; in this case lab1.

  18. • In the program,; • As soon as the command jmp lab1 is encountered, the program will jump to the label • The program will continue from the label • The commands add ax,4 and lda 10 will be skipped • sub ax,3 will be worked next. • As already mentioned, an unconditional branch does not have any conditions, so when the jump command is encountered it will simply skip to the label.

  19. Conditional Branching • Conditional branching allows the program to skip to another location (through the use of labels) only if it satisfies a condition • In order to use this type of branching, a comparison must be done first • First we carry out the comparison, and then we jump to a label if the comparison satisfies the jump’s criteria

  20. The registers ax and bx are compared with each other using the command CMP Then the command jg (jump if greater) is used to jump to the label isgreater, if ax is greater than bx, otherwise it will jump to label after The actual comparison is carried out using the CMP command, and then different jump statements can be used.

  21. Different Jumps

More Related