1 / 4

Stored Program

Stored Program. Instruction memory is used to store a program Processor gets one instruction at a time It stores it locally (like) I0, I1 registers PC points to next location It is automatically incremented Control directs execution Another memory stores data Execution goes as follows

nikita
Download Presentation

Stored Program

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. Stored Program • Instruction memory is used to store a program • Processor gets one instruction at a time • It stores it locally (like) I0, I1 registers • PC points to next location • It is automatically incremented • Control directs execution • Another memory stores data • Execution goes as follows LD/STADD/SUB/OR/XOR/AND I0 <-- IMEM[PC], PC+ I0 <-- IMEM[PC], PC+ I1 <-- IMEM[PC], PC+ Rz <-- (Rx) OP (Ry) Addr <-- (I1) Rx <-- DMEM[Addr] for LD, or DMEM [Addr] <-- Rx for ST

  2. Conditional Branch Instruction • PC points to next instruction that is to be executed by a machine • However, user may want to change control flow • They use a branch instruction and condition code • For example if one wants to check if register R1 is greater than R2, we may subtract R2 from R1 and check the sign bit • Sign bit one means result is negative and R1 is smaller than R2 SUB R0, R1, R2 BNEG neg pos: …… ……. neg: ……. …….. • The conditions to check: • GT, LT, EQ, NE, GE, LE

  3. Another Example: Deciding Grade • Consider a program segment to decide final grade If (grade < 50) then GRADE is fail (0) else if (grade < 60) then GRADE is D (1) else if (grade < 70) then GRADE is C (2) else if (grade < 80) then GRADE is B (3) else GRADE is A (4) we need to compare grade (say in register R1) with fixed values say in R2 (=50), R3(=60), R4(=70), R5(=80), and decide what to do • How will we write the program? SUB R0, R1, R2 /* Sub R2 from R1 and store result into R0 */ BPOS g50 /* Branch if result is a positive value */ LD R3, ZERO /* Load value from location called zero */ BR Done /* we are done */ g50: SUB R0, R1, R3 /* Store R1-R3 into R0 */ BPOS g60 /* Branch if > 60 */ …..

  4. Inst Mem IIAD PC INST IAddr WIAD Input Output RA1 RA2 M- Reg WOUT Reg File OpCode EMR EALU EI S H I F T A L U WM Mem Unit Cond Code RM WR Data Addr SC WA EM WDAD Accounting for Branch Condition • If the branch condition is met, then we want to change PC value with new value, else we just increment PC • Branch address is part of instruction • We need to copy new address in PC • What change we need to make in data path?

More Related