20 Mar 2013

What is a control word and how it write ?

As i mansion my earlier post that is send by programer to make understand 8255 that which port is Input and which one is Output. Now how we are do that ?

Format of Control Word




Mode Definition Control Byte. Indicate by bit b7=1.
Port A and upper half of Port C (Group A)
Bit b3 to bit b6 control the mode and direction of Group A


b6, b5            mode                operation
0                      0                        mode 0
0                      1                         mode 1
1                      0                         mode 2


b4 Port A direction, 0=output, 1=input


b3 upper half of Port C direction, 0=output, 1=input


Port B and lower half of Port C (Group B)
Bit b0 to bit b2 control the mode and direction of Group B


b2  mode operation, 0=mod 0, 1=mod 1
b1  Port B direction, 0=output, 1=input
 lower half of Port C direction, 0=output, 1=input


Now take a Example that we need Port A as a input Port and Port B as a Out put Port What will be the Control Word ?

For that we need  Bit  D7  =1 ( For Input/Output Operation )
                                  D6  =0
                                  D5  =0
                                  D4  =1 ( For Port A as Input)
                                  D3  =0
                                  D2  =0
                                  D1  =0  (For Port B as Output)
                                  D0  =0

So finally we got the number 10010000 or 90H.


                                 

WHAT IS PROGRAMMABLE PERIPHERAL INTERFACE 8255 ?

The 8255 Programmable Peripheral Interface (PPI) is a general purpose interface device which is widely used in microprocessor design. It contains three independent 8 bit ports named Port A, B and C. Port A and B can be programmed as either input or output (all eight line must be same), while port C is split into two 4 bit halves (Port C upper (PC4- PC7) and Port C lower (PC0-PC3)) that can be separately programmed as input or output.
There are four registers that control the operations of the PPI and they are mapped to four address locations in the 8085 Development System as shown below:

      Port                               Address
Port A Register                        80H
Port B Register                        81H
Port C Register                        82H
Control Register                       83H

Now question is what are the work of those resister ?

First three resister ( Port A,Port B,Port C) are the address resister it provide the identity of the Ports. And Control Register it has a main work to control them. It control Which Port is Input and Which is output depending on programer Control Word .

13 Mar 2013

Progrraming for Subtraction of two 8 bit numbers using 8085

As mention on previous blog for getting subtraction of two 8 bit number the algorithm is given bellow

             For 8 bit Subtraction we need

  •    Start the program by loading the first data into Accumulator.
  •     Move the data to a register (B register).
  •     Get the second data and load into Accumulator.
  •     sub the two register contents.
  •     Check for carry.
  •     Store the value of sum and carry in memory location.
  •     Terminate the program.

             Program                                              Comment

             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.

             SUB B                                          Subtract  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.

Progrraming for addition of two 8 bit numbers using 8085.

Now starting with Microprocessor program of 8085 we at-first think about the steps or algorithm of the program. 

             For 8 bit addition we need

  •    Start the program by loading the first data into Accumulator.
  •     Move the data to a register (B register).
  •     Get the second data and load into Accumulator.
  •     Add the two register contents.
  •     Check for carry.
  •     Store the value of sum and carry in memory location.
  •     Terminate the program.

             Program                                              Comment

             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.

What is a Assembly Language ?

The language we are communicate each other is a High label language and a Micro processor understand only low label language like 01. But we not understand or rather say difficult to communicate with a microprocessor with this language so we need a mediator means some language which we understand easily and also machine easily transfer it in their language so we need assembly language.
Assembly language was designed to do the same work as machine code but be much easier to use. It replaced all the ones and zeros with letters that were easier to remember but it is still a low-level language. The assembly equivalent of our machine code example 11000110 00010101 is the code 

ADD A,m.              This means ‘add any Number ,m to the value stored in the accumulator. 

We can see immediately that it would be far easier to guess the meaning of ADD A,m than 11000110 00010101 and so it makes programming much easier. If we had to choose letters to represent the ‘add’ command, ADD A,m was obviously a good choice. A big improvement over alternatives like XYZ k,g or ABC r,h. The code ADD A,m is called a mnemonic.A mnemonic (pronounced as nemonic) is just an aid to memory and is used for all assembly codes. 

Here are some example which are:

SLA E                                             for shift to the left, the contents of register E.
LD B                                               25H load the B register with the number 25H.


Now see how easy it makes it by guessing the meaning of these:


INC H
LD C 48H


Finally, have a go at one that we have not considered yet.


LD B B

SLA E                                          means shift the contents of register E one place to the left, then
SRA E                                             means shift the bits one place to the right. 

LD C 48H                                       means putthe number 48H into the C register. LD B B enables us
                                                        to  copy the number stored in the B register into the B register.