TOPICS:-Instruction and Instruction Sequencing •Register Transfer Notation(RTN) •Assembly Language Notation(APN) •Basic instruction type •Instruction execution & straight line sequencing •Branching •Condition codes •Generating memory address
Addressing modes •Types of addressing modes •Implementation of variables and constants •Indirection and pointer •Indexing and array •Relative addressing •Additional modes
Computer program consist of sequence of small steps,such as adding two numbers, testing for a particularcondition , reading a character from the keywordFour types of operation.1) Data transfers between the memory and the processor registers.2) Arithmetic and logical operations on data.3) Program sequencing and control.4) I/O Transfers
•Transfer of information from one location in thecomputer to another.•Possible locations that may be involved in such transfersare memory locations, processor registers and registersin the I/O subsystem.•Example –• Add the contents of the register R1 and R2 and thenplaces their sum into register R3. R3[R1]+[R2] Right side denoted the value. Left side denoted the name of the location where thevalue is to be placed.
•It represent machine instructions and program.•For this, we use assembly language format.•Example :- 1) Move LOC ,R1• The contents of LOC are unchanged by the execution ofthis instruction but the old contents of register R1 areoverwritten.2) Add R1,R2,R3
Three types of basic instruction:-1) 3 –Address instruction:- • Add A,B,C • A &B are called Source operands. • C is called Destination operand. Operation Source1,Source2,Destination • 3-address instruction is too large to fit in one word for a reasonable word length.
2) 2-Address Instruction:- • Add A,B • [B][A]+[B] • A is source operand and B is destination operand Operation Source, Destination • A single 2-address instruction cannot be used to solve original problem A and B , without destroying either of them ,and to place the sum in location C. • Move B,C C[B]
3) 1-Adress Instruction:- • Add A • Accumulator[A]+Accumulator Operation Destination • Using 1-address instructions , the operation [C][A]+[B] can be performed by execution the sequence the instruction:- • Load A • Add B • Store C
•Executing a given instruction is a two-phase procedure:-• 1) Instruction fetch:-•Instruction fetched from the main memory location whoseaddress in the PC.•This instruction placed in the IR in the processor.•2)Instruction execute:-•The instruction in IR is examined to determine whichoperation is to be performed.•The specified operation is performed by processor.•Perform arithmetic and logic operation.•Store the result in destination location.
•PC holds the address of the instruction to be executenext.•The address of 1st instruction placed into PC, then•The processor control circuits use the information in thePC to fetch and execute instruction ,one at a time , in theorder of increasing addresses . It is called straight linesequencing.•During each instruction PC incremented by 4 to point tothe next instruction
• It is loads a new value into the PC.•Processor fetch and executes the instruction at the newaddress , called branch target.•It follows the branch instruction in sequential addressorder .•A conditional branch instruction causes a branch only ifa specified condition is satisfied.•If the condition is not specified ,the PC is incremented.•And the next instruction in sequential order is fetchedand executed.• Branch>0 LOOP
•The processor keep the track of information about theresult of various operation for use by subsequentconditional branch instructions.•This is accomplished by recording the requiredinformation in individual bits, often called condition codeflags.•These flags are usually grouped together in a specialprocessor register called condition code register or statusregister.
•Four commonly used flags are:-•N(negative):-Set to 1 if the result is negative; otherwisecleared to 0•Z(zero):-Set to 1 if the result is 0;othrrwise cleared to 0•V(overflow):-Setto 1 if the arithmetic overflow occurs ;otherwise cleared to 0•C(carry):-Setto 1 if a carry-out results from theoperation ; otherwise cleared to 0
•The N and Z flags are affected by instructions thattransfer data such as Move ,Load , or Store.•TheInstruction Branch>0 tests one or more conditioncodes.•Insome computers ,the condition code flags are affectedautomatically by instruction that perform arithmetic orlogic operation
•Theinstruction set of a computer typically provides anumber of such method, called addressing modes.•Types of addressing modes:- EA=effective address Name Assembler syntax Addressing function Immediate # value Operand=value Register Ri EA=Ri Absolute(Direct) LOC EA=LOC Indirect (Ri) , (LOC) EA=[Ri] ,EA=[LOC] Index X(Ri) EA=[Ri]+X Base with Index (Ri,Rj) EA=[Ri]+[Rj] Base with Index and X(Ri,Rj) EA=[Ri]+[Rj]+X offset Relative X(PC) EA=[PC]+X Auto increment (Ri+) EA=[Ri] ;Increment Ri Auto decrement -(Ri) Decrement Ri EA=[Ri];
•A variable is represented by allocating a register or amemory location to hold its value.•Two addressing modes to access variables:- 1) Register mode:-The operand is the contents of aprocessor register .•Operand is held in register named in address file•EA = R•Limited number of registers•Very small address field needed Shorter instructions Faster instruction fetch•Move LOC,R1
2) Absolute mode:-•The operand is in a memory location.•The address of this location is given explicitly in theinstruction .•It is also called Direct mode.•Declaration such as• Integer A,B
Address and data constants can be represented inassembly level language using Immediate mode•Immediate mode:- The operand is given explicitly in theinstruction.•Example – Move 200immediate ,Ro•The common convention is to be used the sharp sign(#)in front of the value of the use as in immediate operand.• Move #200, Ro
•The register or memory location that contains theaddress of an operand is called a pointer.•Indirection is the ability to reference something using aname, reference, or container instead of the value itself.•The most common form of indirection is the act ofmanipulating a value through its memory address.•For example, accessing a variable through the use of apointer.•Indirection and use of pointers are important andpowerful concepts in programming.
•Indirectmode:-• The effective address of the operand is the contents ofregister or memory location whose address appears inthe instruction.•Memory cell pointed to by address field contains theaddress of (pointer to) the operand.•e.g. ADD (A) Add contents of cell pointed to by contents of A to accumulator• Add (R2),R1
•Indexing provide the different kind of flexibility foraccessing operands.•It is useful in dealing with lists and array.•IndexMode:-•The effective address of the operand is generated byadding a constant value to the contents of a register.
•The register used may be special register provided forthis purpose or general –purpose register called indexregister.• X(Ri)• EA=X+[Ri]•Where X denoted the constant value contained in theinstruction,•And Ri is the name of the register involved.
•Relative Mode:-•The effective address is determined by the index mode usingthe PC in the place of general purpose register Ri.• EA=[Ri]+PC•i.e. get operand from Ri cells from current location pointed toby PC•The mode can be used access data operands.•Most common used in to specify the target address in branchinstruction.• Branch>0 LOOP
• Auto increment mode:- (Ri)+• The effective address of the operand is the contents of a register specified in the instruction.• After accessing the operand ,the contents of this register are automatically incremented to point to the next item.• Auto Decrement mode:- -(Ri)• The contents of a register specified in the instruction are first automatically decremented.• After that used as the effective address of the operand.