Showing posts with label Rajesh. Show all posts
Showing posts with label Rajesh. Show all posts

Friday, 29 July 2011

8085 Instruction set - Branch Instructions

             The branching instructions alter the normal sequential program either conditionaly or unconditionally.



As formerly seen in my previous posts in this Series, we divided the Series into four parts:

UNCONDITIONAL BRANCHING INSRTRUCTIONS:

     JMP :
          This instruction is used to jump from one set of programs to another set
                e.g:   In a 8 bit multiplication program, JN2 LOOP it means that if no zero results in previous arithmetic operation, it will jump to LOOP.
    CALL :
          This instruction is used to call the function.
                e.g:   CALL DIV,CALL SUB etc..
    RET :
          This instruction is used to return to the program after doing some manipulation for a program to succeed.

CONDITIONAL BRANCHING INSTRUCTIONS :
          Here we are going to discuss some instructions which we use with jump instruction.
The instructions are

        NZ Not Zero (Z = 0)
        Z    Zero (Z = 1)
        NC No Carry (C = 0)
        C    Carry (C = 1)
        PO Parity Odd (P = 0)
        PE Parity Even (P = 1)
        P   Plus (S = 0)
        M  Minus (S = 1)

        Jumps Calls Returns
        C CC RC (Carry)
        INC CNC RNC (No Carry)
        JZ CZ RZ (Zero)
        JNZ CNZ RNZ (Not Zero)
        JP CP RP (Plus)
        JM CM RM (Minus)
        JPE CPE RPE (Parity Even)
        JP0 CPO RPO (Parity Odd)
        
        Two other instructions can affect a branch by replacing the contents or the program counter:

        PCHL Move H & L to Program Counter
        RST    Special Restart Instruction Used with Interrupts

Stack I/O, and Machine Control Instructions:
    The following instructions affect the Stack and/or Stack Pointer:

        PUSH  Push Two bytes of Data onto the Stack
        POP     Pop Two Bytes of Data off the Stack
        XTHL Exchange Top of Stack with H & L
        SPHL  Move content of H & L to Stack Pointer

The I/0 instructions are as follows:
        IN     Initiate Input Operation
        OUT Initiate Output Operation

The Machine Control instructions are as follows:
        EI      Enable Interrupt System
        DI     Disable Interrupt System
        HLT Halt
        NOP No Operation

Thursday, 28 July 2011

8085 Data Transfer Instructions


       Here we are going to discuss about data transfer instructions which move data between register or memory locations.
INSTRUCTIONS:
       MOV :
           This instruction is used to move the data from accumulator or memory to some registers or vice versa.
      e.g: If [A] = 00 and [B] = 20
             after MOV A,B
             [A] = 20 and [B] = 20
      MVI :
          This instruction is used to move the data from accumulator or memory to some registers or vice versa using the immediate data
e.g: after MVI B , 09
       [B] = 09
      LDA:
          This instruction is used to load the accumulator directly from the memory.
e.g: assume [4200] = FE
       after LDA 4200 
       [A] = FE
      STA :
           This instruction is used to store the content of accumulator directly to a memory address
e.g: If [A] = FF
       after STA 4200
       [4200] = FF

      LHLD :
           This instruction is used to load H&L registers directly from memory
e.g: If [4200] = FE and [4201] = 29
       after LHLD 4200
       [H] = 29 and [L] = FE

      SHLD :
           This instruction is used to store the H & L registers directly to memory.
e.g: If [H] = 29 and [L] = FE
       after SHLD 4200
       [4200] = FE and [4201] = 29

          Now we are going to see some data transfer instruction which deals with the register pair. To indicate the register pair we are using a term called ‘X’.
 LXI :
     This instruction is used to load the register pair with the immediate data.
            e.g:  after LXI H 4200
                    [H] = 42 and [L] = 00

 LDAX
     This instruction is used to load the accumulator with the data from address in register pair( 16 bit address).
            e.g: If [4432] = 3F and [A] = 00
                   [B]= 44 and [C]=32                      
                   after LDAX B
                   [A] = 3F

 STAX :
      This instructions is used to store the accumulator in address in register pair.
             e.g: If [A] = 32 and [D] = 40 and [E] = 00
                    after STAX D 
                    [4000] = 32.

 XCHG
      This instruction is used to exchange the data of H&L register pair with D&E register pair.
             e.g:  If [H] = 00, [L] = 01 and
                        [D] = 15 and [E] = 30
                     after XCHG 
                     [H] = 15 and [L] = 30
                     [D] = 00 and [E] = 01

 XTHL
      This instruction is used to exchange the top of stack with H&L.
             e.g: If [H] = 20 and [L] = 18 
                   assume that contents of stack is  
                  after XTHL                          
                  [H] = [01] and [L] = [09] and the contents of satck will be 


Wednesday, 27 July 2011

8085 Logical Instructions

        In my previous post we saw about arithmetic instructions of 8085uP. Now, we are going to discuss about some logical operations which we perform in registers, memory location and on flags.



As formerly seen in my previous post in this Series, we divided the Series into four parts:
LOGICAL INSTRUCTIONS
       ANA :
         It logically AND with the accumulator. It means that the accumulator is multiplied with some register values.
         e.g: If [A] = 20 >> 0 0 1 0 0 0 0 0
                [B] = 30 >> 0 0 1 1 0 0 0 0
                After instruction >> [A] = 0 0 1 0 0 0 0 0
       ANI :
        It logically AND with the accumulator using the immediate data.
          e.g: For   [A] = FE  (i.e 1111 1110 )
                 after ANI 07        ; 07 = 0000 0111
                 [A] = 06     (i.e 0000 0110 )
                                 
      ORA:
       It logically OR with the accumulator. It means that the accumulator is added with the registers.
           e.g: If [A] = FE (i.e 1111 1110 )
                  and [B] = 31 (i.e 0011 0001 )
             after instruction  [A ] = FF (i.e 1111 1111 )
      ORI :
           As u guessed, it logically OR with the accumulator using the immediate data.
e.g: if [A] = 7D (i.e 0111 1101 )
      after ORI 17            ;17 = 1 0 0 0 0 1 1 1
      [A] = FF (i.e 1111 1111 )

      XRA :
          It logically EX-OR with the accumulator. It means that if any two numbers are same its output will be 0 else if not same output will be 1 
e.g: If [A] = 7F                                (i.e 0111 1111 )
       and [B] = 32                              (i.e 0011 0010 )
                After instruction >> [A] = 4D (i.e 0100 1101 )
         XRI:
     It logically EX-OR with the accumulator using the immediate data.
         e.g: If[A] = FE           (i.e 1111 1110 )
                after  XRI 07  ; 07 = 0000 0111
                [A] = F9              (i.e 1111 1001 )

COMPARE INSTRUCTIONS:
     It compares the content of 8 bit data with the contents of accumulator Some 2 instructions are there here they are,

           CMP:
                It compares the conetents with the contents of accumulator. This instruction is used to check whether the numbers are same or zero etc.
           CPI:
      It compares with the contents of accumulator using immediate data.They are mostly used in 8 bit and 16 bit multiplication or division programs etc..

RLC :
     It means the that the contents of accumulator is rotated to left.
        e.g: [A] = 1 0 1 0 1 1
               after RLC
               [A] = 0 1 0 1 1 1

RRC:
     It is as same as RLC but it is rotated to right side.
       e.g: [A] = 1 1 1 1 1 0
              after RRC
              [A] = 0 1 1 1 1 1

RAL:
     It rotates each bit of accumulator to left with carry.
        e.g: If [C]=0 and [A]= 1 1 0 1 1 1 0 1
               after RAL
               [C] =1 and [A] = 1 0 1 1 1 0 1 0

RAR:
     It is as similar to RAL But I will rotate in right side.
        e.g: If [C] =0 and [A] = 1 1 1 1 1 0
               after RAR
               [C]=0 and [A] = 0 1 1 1 1 1


COMPLEMENT AND CARRY FLAG INSTRUCTIONS:
      These instructions are used to complement the data. The names of instructions are self-explaining abbreviations 
CMA: 
          It complements the accumulator.
             e.g: If [A] = 0 0 0 1
                    after CMA 
                    [A] = 1 1 1 0

CMC: 
          It complements the carry
            e.g: [C] = 0
                   after CMC
                   [C] = 1

STC: 
         It sets the carry.
         e.g: If [C] = 0 or 1
                after STC 
                [C] = 1

Thursday, 30 June 2011

8085 uP Instruction Set - Arithmetic Instructions

8085-MICRO PROCESSOR INSTRUCTION SETS
    8085 Micro Processor is 8 bit micro processor which has some instruction sets to perform its operation. The 8085 Instruction Set comprises of five instruction sets in this micro processor.
They are,
  
       Arithmetic instructions, Logical instructions, Data transfer instructions, Branch instructions and I/O , stack, machine control group.


We also divide the Instruction Set into four parts namely
ARITHMETIC INSTRUCTIONS
      Arithmetic instructions include some mathematical operations such as addition subtraction increment and decrement. For addition and subtraction the quantity is always stored in accumulator. Accumulator is a register which can hold 8 bit data where the arithmetic and logic values can be stored in it.


CONVENTIONS
   A - represents the accumulator.
   B,C,D,E,F,H,L - represents the general purpose registers.
   [A] - represents the contents of the registers A.
  Similarly , [B] represents the contents of register B . i.e the square brackets represents the contents of the particular register.
   [M] - represents the contents of memory location specified by the address M = xxxx ( 16 bit address ).
 Double square brackets  :  e.g: [[B]]
             If [4200] = 12 , [B] = 4200 , then [[B]] = [4200] =12.


INSTRUCTIONS
        1.  ADD r:
          ADD r means that the register content is added to the accumulator.
       Example: [B] = [1 1] , [A] = [D D]
       [A] + [B] = [A]
             So, [A] = [E E]
          Ie. = represents that arithmetic quantity is stored in accumulator.
      
       2.  ADD m:
         It means that the memory content is added to the accumulator.
             Example: [A] = 32,   [H]= 42,  [L] =01, [4201]=3F
             [A] + [HL] = [A]
             [A] = [71 ]
         Ie. = represents that arithmetic quantity is stored in accumulator.

 3. ADI 8 BIT:
         It means that the 8 bit immediate data is added to the contents of accumulator.
            Example: [A] = [1]
            For ADI 8F:
                 [A] = 90
           Ie. = represents that arithmetic quantity is stored in accumulator.

 4.SUB R:
           It means that the contents of register are subtracted from the contents of accumulator.
              Example: Sub B , [B] = [11] , [A] = [CC]
              [A] - [B] = [A]
              [A] = [BB]
           Ie. = represents that arithmetic quantity is stored in accumulator.

  5. SUB M:
           It means that the contents of memory location are subtracted from the contents of accumulator.
              Example: [A] = [32], [H] = 42, [L]=01, [4201]  = 22
              4201 is the memory address
              22 is the data which is stored in memory
              [A] = [A] – [HL]
              [A] = [10]
          Ie. = represents that arithmetic quantity is stored in accumulator.

 6. SBI:
          It means that the 8 bit data is subtracted from the contents of accumulator.
            Example: [A] = [FF]
            For SBI 22
            [A] = [A] – [22]
            [A]=DD
         Ie. = represents that arithmetic quantity is stored in accumulator.

 7. INR R:
         It means that the content of register is increased by value 1.
           Example: [B] = 01
           [B] = [B] + 1
           [B] = 02
         Ie. = represents that arithmetic quantity is stored in accumulator.

 8. DCR M:
         It means that the content of register is decreased by value 1.
           Example: [B] = FF
           [B] = [B] – 1
           [B] = FE
         Ie. = represents that arithmetic quantity is stored in accumulator.

 9. INR M:
         It means that the data which is present in the memory is increased by a value 1.
           Example: [H] = 45, [L]= 01, [4501] = 32
           HL 4501 is the memory address.
           32 is the data which is stored in the memory.
           [H] = 45, [L] = 01, [4501] = 33

10. DCR M:
         It means that the data which is present in the memory is decreased by a value 1.
           Example: [H] = 45, [L]=01,  [4501] = 32
           HL 4501 is the memory address.
           32 is the data which is stored in the memory.
           [H] = 45 , [L] = 01  [4501] = 31

11. INX Rp:
         It means that the content of register pair is increased by 1.
           Example B 50/23 C
           B 50/24 C

12. DCX Rp:
        It means that the content of register pair is decreased by 1.
           Example B 32/FE C
           B 32/FD C
           
The next post will be shortly…

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More