Unit 1
Unit 1
Qs t         heuce       auo   at
                dehuned
    Selech         ud          (uterconneehng. havdw@
Conputn Arclidechans
          nshdhn
                                    N                        SyDeslg
                                     MiC anctiteu
                Set
            Anlutechunal            (Ohpustw Oraaudzoho
Whot O How
special multiply unit or by the method of repeated addition by using the add unit of the system.
The model of a computer can be described by four basic units in high level abstraction. These
basic units are:
Menor
    1. Central Processor Unit [CPU]: Central processorunit consists of two basic blocks
              .The program control unit has a set of registers and control circuit to generate
                control signals.
              .The execution unit or data processing unit contains a set of registers for
                storing data and an Arithmetic and Logic Unit (ALU) for execution of
                arithmetic and logical operations.
              In addition, CPU may have some additional registers for temporary storage of
              data.
   2. Input Unit: With the help of input unit data from outside can be supplied to the
      computer. Program or data is read into main storage from input device or secondary
      storage under the control of CPU input instruction.
      Example of input devices: Keyboard, Mouse, Hard disk, Floppy disk, CD-ROM drive
       etc
   3. Output Unit: With the help of output unit computer results can be provided to the
       user or it can be stored in storage device permanently for future use. Output data from
       main storage go to output device under the control of CPU output instructions.
       Example of output devices: Printer, Monitor, Plotter, Hard Disk, Floppy Disk etc.
                                            Page 4 of 106
    4. Memory Unit: Memory unit is used to store the data and program. CPU can work
         with the information stored in memory unit. This memory unit is termed as primary
          memory or main memory module. These are basically semiconductor memories.
          There are two types of semiconductor memories
          Volatile Memory       : RAM (Random Access Memory).
                                            Page 5 of 106
      2. Stack organization
               All     operations are done using the hardware stack
                   For example, an OR instruction will
                                                        pop the two top elements from the             stack,
                   do a logical OR on them, and
                                                 push result on the stack
                                                      the
      3.    General register   organization
               .   Used by most modern computer processors
                   Any the registers can be used as the source or destination for
                       of
                                                                                  computer
                   operations
1.2.2.      ACCUMULATOR TYPE OF ORGANIZATION
In   case   of accumulator type of
                                   organizations,        one   operand is in memory and other is in
accumulator.
The instructions we       can run     with accumulator are:
                                        Adder and
              FromDR                      logic
                                          circuit
                                                                                  AC          1
            From INPR             |                                                                   To bus
                                          Control
                                          Gates
Stack:
                                                  Page 6 of 106
                                                           nested   interrupt services
          Very useful feature for nested subroutines,
          Also efficient for arithmetic   expression evaluation
          Storage which can be accessed in LIFO
          Pointer: SP
          Only PUSHand POP operations are applicable
Stack type of organization is of two      types
      1. REGISTER STACK ORGANIZATION
Address
           Flags                                               63
FULL                EMPTY
    Stack pointer                                              4
      SP                                                       3
          6 bits
DR
      PUSH                                      POP
    SPSP +1                                  DR-MISP]
     MISP]-DR                                SPSP-1
    If(SP= 0) then (FULL-1)                   If(SP = 0) then (EMPTY+1)
     EMPTY0                                  FULL-0
         PUSH: SPSP 1 M
         SP] DR
                                               Page 7 of 106
   POP: DRM [SP]
      SPSP+1
Note: Most computers do not provide hardware to check stack overflow (full stack) or
underflow (empty stack) must be done in software
                                                   1000
        PC                         Programn
                                instrucudns)
                                      Data
     AR
                                  (OperandS
         SP                                        3000
                                                   3997
                                                   3998
                                                   3999
                                                   4000
                                                   4001
                                                    Stack grows
                                                    In this direction
In this we take the help of various registers, say Ri to R8 for transfer and manipulation of data.
                                              Page 8 of 106
                                REGISTER BASED                                          CPU
DETAILED DATA PATH OF
                      A TYPICAL
                                                                             Input
                       Clock
                 R
                 R2
                 R3
                 R4
                 R5
Load
Output/Result
organization.
                                                   Page 9 of 106
                                      Begin
                                      Fetch Next
                                        Instruction
                                      Decode
                                      Instruction
                                        Execute
                                      nstruction
       1. Fetch Cycle
       2. Decode Cycle
       3. Execute Cycle
 Working of Instruction feteh Execute Cycle
       1. Fetch an instruction from memory.
       2. Fetch any data required by the instruction from memory.
       3. Execute the instruction (process the data).
       4. Store results in memory.
       5. go back to step (1)
       1.   Fetch Cycle: The fetch cycle begins with retrieving the address stored in the Program
            Counter (PC). The address stored in the PC is some valid address in the memory
                        instruction to be executed. (In      case   this address   does   not   exist   we   would
            holding the
            end up causing an interrupt or exception).
            The Central processing unit completes this step by fetching the instruction stored at
this address from the memory and transferring this instruction to a special register -
            Instruction Register (IR) to hold the instruction to be executed. The program counter
            is incremented to point to the next address from which the new instruction is to be
            fetched.
                                                                             instruction that was
   2        Decode   Cycle: The decode cycle is used for interpreting the
            fetched in the Fetch Cycle. The operands are retrieved from the addresses if the need
            be.
   3.       Execute Cycle: This cycle   as   the   name   suggests, simply executes the instruction that
            was fetched and decoded.
                                                                                       is
The symbolic notation used to describe the micro-operation transfers amongst registers
                                              Page 10 of 106
called Registertransfer language.
 The term register transfer means the availability of hardware logic circuits that can perform a
 stated micro-operation and traDsfer the result of the operation to the same or another register.
 The word language is borrowed from programmers who apply this term to programming
                                                                                 a                     given
languages.This programming language is a procedurefor writing symbols to specity
Computational process.
 Following are some commonly used registers:
                                                                                                         the
 Accumulator: This is the most               common    register, used       to store data taken out from
 memory.
  General Purpose Registers: This is used to store data intermediate results during program
  execution. It can be accessed via assembly programming.
                                       Users do not     access     these registers. These registers   are
                                                                                                            for
 Special Purpose Registers:
  Computer system,
                                                                         holds the address for memory unit.
 MAR: Memory Address Register are those registers that
of replacement operator.
R2-R1
                                                                  6 5 4 3 210
                                      Register R                 Showing Individual Bits
8 7
RI PCH) PCL)
                                                    Page 11 of 106
Register Transfer Language Instructions
              Instruction Set.....cont...
      (A) Data Transferoperation
           These     operations simply COPY the data from the source to the
            destination.            A
                                                ***
          >They transfer:
                   Data between registers.
                   Data Byte to a register or memorylocation.
                   Data betweena memory locationand a register.
                Databetweenan l/ODeviceandtheaccumulator.
          Thedata in the sourceis not changed.
          Data transfer instructions neveraffect the flag bits.
               eg LDA, STA,MOV, LDAX, STAX, MVI, LXI etc.
   DA oad Actumulatok
 L
S TA -Shr Accumulaton
                                         L            AX    laad a cCumulaker    indud
                                         STAX-             S t o a CCumulskoi in ouet
MVI MO    Immu oliolt
 XI -Load ngiin fa mmeolialt
                                         LI            H     400oH
 Exmpl          MoV        M,   *
               MVI H, olata
               MVI       A, 0S
               MV1 M, dlala
                      Instruction Set....cont...
          (B) Arithmetic Operation
                   These instruction perform addition, subtraction and compareoperations
                   These operations are always performed with accumulator as one of the
                     operands.
                   The status of the resultcan be verified by the contents of the flag register.
                Addition: Any 8-bit number, or the contents of a register or the contents of a
                memory location can be added to the contents of the accumulator and
               sum is stored in the accumulator. The instruction DAD is an exception; it adds    the
               16-bit data directly inregister pairs. Ex ADD, ADI
               Subtraction Any 8bit number, or the contents of a registér, or the contents
               of a memory location can be subtracted from the contents of the accumulator
               and the results stored in the accumulator, Subtraction is done by 2s
               compliment method and set carry tlag toindicate borrow.SUB.SBI
               Increment/Decrement         The 8-bit contents of     a register or a memory
               location can be incremented or decrement by 1 Similarly,  the 16-bit contents
               a register pair (such as BC) can
                                                be incremented or decrement by 1. INR,DCR. of
                                                                www
6       PR           BC              E H
                InstructionSet.. (Cont..)
           (C) Logical Operation                 .
                                                        .
                                                            *
                                                                  .
                                                                          .   ..
                                                                               ..
                                                           Exclusive-OR with
           accumulator The results are stored in the accumülatOr                          the   contents of the
                                                                      .
                                        used      o call a p             e du
                          Call&RET        4ddus o the tauk
                                                                                 o Hhe              mam
                                 Rd            e u em thu pro adwre
            Conditional branchinstructions Transfertheprogramtothe specified label or
             address when certain conditionissatisfied
                           JNCJCNZLPIM PE PO
                           CNC,CC CNZ CZ, CP CM.CPE, CPO                         pas/thve
                            RNC RC RNZ, RZ,RP,RM, RPE, RPO
                                                                wwN
                  InstructionSet...                       '.*
                                                                          Cont..
                                                                           .
                            I0loool; cy 20
3     RRC        Exomb lo     16ooooo                          Bit Dg Deuenas
                                            ;   C720P
                                                              Do Ca a flag
                     ,St | 00 o0 00
                     -                          C =1
                                                              Cy  mooi fj2d
                                                          q Ccaolg o A
                                                              bit Do
4)    RAR       EXampk                 l;(y=b
                               looo oool;
                                                                  Bit Do becenes
                                                               he C a y þit
            '
 Parts Of Instruction Format
The   parts   of the   instruction format   are:
1. Addressing Mode
         The data is
                      represented in the instruction format with the help of addressing          mode
     The       addressing mode is the first part of the instruction format
         The data      can   either be stored in the
                                                     memory of a   computer or   it can be located in the
         register of the CPU
3. OPERAND
     Format Of Instruction
    The set of instructions that manages the operation codes is called the format of instruction. The
    design of bits in instruction is supported by the format of instruction. The length of instruction is
    generally preserved in multiples of character, which is 8bits. The instruction format determines
    the behaviour and complexity of instruction. Dependling upon the number of addresses, the
    format of instruction is of variable length.
            The instruction format in which the instruction uses only one address field is called the
            one address instruction format
       I n this type of instruction format, one operand is in the accumulator and the other is in the
            memory location
            It has only one operand
      I t has two     special instructions   LOAD and STORE
  4    Three    AddressInstructionexarmples
       Assembly language instruction-ADD R1, A, B etc.