Thursday, May 28, 2020

16 bit programs of 8085, addition, subtraction, multiplication and division of two 16 bit number.






  Adiition of two 16 bit numbers:-

some important instructions which are used to 16 bit prgrams :-

1. LHLD :- load H-L register direct
  •  This instruction copies the contents of memory location pointed out by 16-bit address into register L.
  • It copies the contents of next memory location into
    register H.
  • Example: LHLD 2040 H
2.SHLD:-Store H-L registers direct.
  • The contents of register L are stored into memory location 
           specified by the 16-bit address.
  • The contents of register H are stored into the next memory location..
  • Example: SHLD 2550 H

3. XCHG :- Exchange H-L with D-E.
  • The contents of register H are exchanged with the
    contents of register D.
  • The contents of register L are exchanged with the
    contents of register E.
4. DAD:- Add register pair to H-L pair.
  • The 16-bit contents of the register pair are added to the
    contents of H-L pair.
  • The result is stored in H-L pair.
  • If the result is larger than 16 bits, then CY is set.
  • No other flags are changed.
5. ADC:- Add register or memory to accumulator with
carry.
  • The contents of register or memory and Carry Flag (CY) are added to
    the contents of accumulator.
  • The result is stored in accumulator.
  • If the operand is memory location, its address is specified by H-L pair.
  • All flags are modified to reflect the result of the addition.
  • Example: ADC B or ADC M
6SBB:- Subtract register or memory from accumulator
with borrow.
  • The contents of the register or memory location and Borrow Flag (i.e.
    CY) are subtracted from the contents of the accumulator.
  • The result is stored in accumulator.
  • If the operand is memory location, its address is specified by H-L
  • All flags are modified to reflect the result of subtraction.
  • Example: SBB B or SBB M
PROGRAM:-

           LDA 0000 H
          MOV B, A
          LDA 0002 H
         ADD B
         STA 0004 H
         LDA 0001 H
         MOV B, A
         LDA 0003 H
        ADC B          ( A+B+CY)
        STA  0005 H
         HLT

2nd method:-

LHLD 0000 H
XCHG                (HL to DE)
LHLD 0002H
DAD D    (H+D & D+E)
SHLD
HLT



subtraction of two 16 bit number :-

LDA 0002 H   (load 8 bit data)
MOV B, A       ( move accumulator to register B)
LDA 0000 H
SUB B              ( SUB A-B= A)
STA 0004 H      (result store in location)
LDA 0003 H
MOV B, A
LDA 0001 H
SBB B               (subtract with borrow)
STA 0005 H      (store carry)
HLT
















Saturday, May 23, 2020

8085 programs, two 8 bit number addition, subtraction, multiplication & division.

                  


                                  8085 MICRO PROCESSOR  PROGRAM

Addition of two 8 bit number:-   explanation of some      important instructions which are  used in 8 bit addition  program.
  • MVI  Rd , data = move immediate 8 bit data in destination  register or memory.
                                          MVI  D , 08
  • MOV Rd , Rs = This instruction copies the contents of the  source register into the destination register.
                                MOV  B, C        
  • LDA    The contents of a memory location, specified by  a 16 bit address in the operand, are copied to the accumulator.
                               1. LDA 2001
  • STA  =  The contents of accumulator are copied into the memory location specified by the operand.
                     1. STA 2002
  • ADD  =  The contents of register or memory are added to the contents of accumulator. result is stored in the accumulator.
  • INR =   The contents of register or memory location are incremented by 1. result is stored in the same place.
  • JNC =     Jump on no carry
  • JNZ =     jump if not zero.
  • LXI =     load register pair with address of memory location.
  • HLT =     terminate the program.
      
                 Execution of  8 bit addition program

 MVI C, 00             Initialize C register to 00
 LDA 4150              Load the value to Accumulator.
MOV B, A              Move the content of Accumulator to B register.
LDA 4151               Load the value to Accumulator.
ADD B                  Add the value of register B to A
JNC LOOP            Jump on no carry.
INR C                     Increment value of register C
LOOP: STA 4152  Store the value of Accumulator (sum)
MOV A, C             Move content of register C to Acc.
STA 4153             Store the value of Accumulator (carry)
HLT                  Halt the program.


             SUBTRACTION OF TWO 8 BIT NUMBER

1. Any 8-bit number, or the contents of register, or the
   contents of memory location can be subtracted from
   the contents of accumulator. The result is stored in the accumulator.
2. Subtraction is performed in 2’s complement form.
3. If the result is negative, it is stored in 2’s complement form.
4. No two other 8-bit registers can be subtracted directly.

EXECUTION OF PROGRAM:- 

MVI C, 00            Initialize C to 00
LDA 4150            Load the value to Acc.
MOV B, A            Move the content of Acc to B register.
LDA 4151            Load the value to Acc.
SUB B
JNC LOOP          Jump on no carry.
CMA                    Complement Accumulator contents.
INR A                   Increment value in Accumulator.
INR C                   Increment value in register C
LOOP: STA 4152 Store the value of A-reg to memory address.
MOV A, C             Move contents of register C to Accumulator.
STA 4153               Store the value of Accumulator memory address.
HLT                       Terminate the program.

              OBSERVATION:
              Input: 06 (4150)
                         02 (4251)
            Output: 04 (4152)
                          01 (4153)
RESULT:
Thus the program to subtract two 8-bit numbers was executed.

                Multiplication of two 8 bit number

AIM:
To perform the multiplication of two 8 bit numbers using 8085.

ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
2) Move the data to a register (B register).
3) Get the second data and load into Accumulator.
4) Add the two register contents.
5) Check for carry.
6) Increment the value of carry.
7) Check whether repeated addition is over and store the value of product and carry
in memory location.

8) Terminate the program.

PROGRAM:

MVI D, 00           Initialize register D to 00
MVI A, 00          Initialize Accumulator content to 00
LXI H, 4150
MOV B, M          Get the first number in B – reg
INX H
MOV C, M          Get the second number in C- reg.
LOOP: ADD B   Add content of A - reg to register B.
JNC NEXT         Jump on no carry to NEXT.
INR D                Increment content of register D
NEXT: DCR C  Decrement content of register C.
JNZ LOOP        Jump on no zero to address
STA 4152           Store the result in Memory
MOV A, D
STA 4153           Store the MSB of result in Memory

HLT                  Terminate the program.

OBSERVATION:
Input: FF (4150)
FF (4151)
Output: 01 (4152)
FE (4153)

RESULT:
Thus the program to multiply two 8-bit numbers was executed.

                  Division of two 8 bit numbers


AIM:
To perform the division of two 8 bit numbers using 8085.

ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
2) Move the data to a register(B register).
3) Get the second data and load into Accumulator.
4) Compare the two numbers to check for carry.
5) Subtract the two numbers.
6) Increment the value of carry .
7) Check whether repeated subtraction is over and store the value of product and
carry in memory location.
8) Terminate the program.


PROGRAM:

LXI H, 4150
MOV B,               M Get the dividend in B – reg.
MVI C, 00           Clear C – reg for quotient
INX H
MOV A, M          Get the divisor in A – reg.
NEXT: CMP B    Compare A - reg with register B.
JC LOOP             Jump on carry to LOOP
SUB B                 Subtract A – reg from B- reg.
INR C                 Increment content of register C.
JMP NEXT         Jump to NEXT
LOOP: STA 4152    Store the remainder in Memory
MOV A, C
STA 4153           Store the quotient in memory
HLT                    Terminate the program. 

2nd method of division:-

 LDA   0000
MOV B, A
LDA   0001
MVI  D, 00
BACK :SUB B
INC  D
JNC , BACK
STA    0002
MOV D, A
STA    0003 
HLT




(If you liked the content, then share and comment)........















  




Thursday, May 21, 2020

pin daigram of 8085 microprocessor, addressing modes, flag register

                           


                 
                              PIN DIAGRAM OF 8085

Intel 8085 Pin Diagram - Sahil Gupta | Seeking Things

8085 microprocessor consist 40 pins which are explain below :-

                                                                  
                                
HIGHER ORDER ADDRESS BUS :- The 8085 has eight higher order address lines A15—A8, A  Which are unidirectional and used as the high order address bus.

MULTIPLEX ADDRESS OR DATA BUS:-  the signal line  AD7—AD0  are bidirectional &   used for dual purpose. They are use  as the  low order address bus as well as data bus.in executing an instruction during the earlier part of the cycle these lines are used as lower order address bus , during the letter  part of the cycle these lines are used as data bus.
     
CONTROL AND STATUS SIGNAL:- This group of signal include two control signal   (RD & WR) and three status signal {I.O/M(bar) , S1 & SO}  to identify the nature of the operation and one special signal ALE(address latch enable) to indicate   the beginning of operation these signal are as follows.

 
      ALE:-   ALE stands for Address Latch Enable. It is the 3oth pin of 8085 which is used to enable or disable the address bus. the address bus will be enabled during the 1st clock cycle as the ALE pin goes high   during the first half cycle .


       READ(bar):- the read control signal (active low) this signal indicates the selected I/O or memory device Is to be read and data are available on the data bus.
                                    
  
WRITE(bar):- this write signal  (active low) this signal indicates the selected I/O or Memory device
is to be write.

IO/M(bar):-  this is a status signals used to diffrentiate b/w I/O and memory operation . when it is high, it indicates as I/O operations, when it is low it indicates memory operations.

S0--S1:-  these status signals similar to IO/M can identify various operation but they are used in small system.


                                        FLAG  REGISTER

It is a 8 bit register & it has five flags (flip flop) that are set or reset according to the result of the operation perform by ALU.
flags generally reflect data condition in the accumulator because the result is stored in accumulator in most operations.


       S
    z 

     AC

       P
      --
 CR

                 
S- sign:-  After the execution of an arithmetic  or logic operation if bit D3 of the result usually in accumulator is 1, the flag is set. this flag is used with signed number in a given byte.

Z- Zero flag :-  zero flag is set if the ALU operation results in zero & the flag is re-set if the result is not zero. this flag is modified by the results in the accumulator as well as in the other register.

AC- auxiliary carry flag:-   in a arithmetic operation, when a carry is generated  in digit D3 and passed on the flag D4, the AC flag is set. the flag is used to only internally for BCD (binary code decimal) operations & is not available for the programmer to change the sequence of  a program with a jump instruction.

Parity flag:- after an arithmetic or logical operation if  the result has even number of one's (1), the flag is set. if it has odd number of one's the flag is reset.

Carry flag:- if an arithmetic operation results in a carry, the flag is set. other wise it is reset. the carry flag is also serves as a borrow flag for substraction.


          ADDRESSING MODE OF 8085 

different  ways of specifying the operand in the instruction are called addressing mode. 8085 supports 5 types  of addressing mode in the instruction. 

1. register addresing mode:-   in this addressing mode operand is available  in the registers only.
      Example:- mov A , B 
      Example:- ADD R

 2. immediate addressing mode:- in this addressing mode operand is available in the instruction itself. 

Example:- MVI  C , 65 H
Example:- LXI H A001 H

 3. direct addressing mode:-  in this addressing mode address of the operand is available in the instruction directly.

Example:- LDA 2000 H
Example:- STA  2001 H 

4. Indirect addressing mode:- in this addressing mode address of the operand is given in the instruction indirectly.

Example:- MOV A , M

5. Implied addressing mode:- in this addressing mode operand is available in the opcode.

Example:-  C= xx
                   D= xx    ( add c+d and result will be save in H register).