Anda di halaman 1dari 56

Lecturer 1 UNIT II Instruction Set and Programming with 8085 Instruction:- Instructions are the tools which help

p the user to perform different operation . Program:-program is a group of instruction which are arranged in this manner that they perform Some operation and give the output. Programming languages are divided into three categories. 1. High level languages 2. Low level languages(Assembly level languages) 3. Machine level languages High level languages: High level languages hide the details of the computer and operating System. Examples include C++, Java, and Fortran. Low level languages(Assembly level languages): Assembly language is an example of a lower level language. Each microprocessor has its own assembly language. A program written in the assembly language of one microprocessor cannot be run on a different microprocessor. Backward compatibility used in order to have old programs that ran on a old microprocessor, can run on a newer model. Assembly language can manipulate the data stored in a microprocessor. Lowest level of languages(Machine level languages) : Contains binary values to cause microprocessor to perform operations . Microprocessor understands the machine language, and thus it is in this state that it executes a instruction set. The mpu use the Assembler & Compiler. Which are explain below. Compilers:- Compiler checks statement in a program is valid. If every instruction is syntactically correct, then the compiler generates a object code.

Microprocessor & interfacing

Page 1

Linker combines object code as an executable file. Executable file copied into memory, and microprocessor then runs the machine code contained in that file. A high-level language statement is usually converted to a sequence of several machine code instructions. Every high-level language statement might have more then one valid conversion of a statement. Assemblers:- Every statement in assembly language however corresponds to one unique machine code instruction. The assembler converts source code to object code, and then the linking, and the loading of procedures occur.

Lecture 2
Microprocessor & interfacing Page 2

Addressing mode (condition) :- The way the data source or destination add are specified In the mnemonics that moves that data determines the Addressing mode. There are four type of add. mode .which are 1. Immediate addressing . mode 2. Register addressing . mode 3. direct addressing mode 4. Indirect addressing mode 5. Implicit addressing mode Immediate addressing mode :- in this add. mode the source is data which is 8 bit or 16 bit & it is used immediately. this data get from the immediately from the input devices. For Exmp. MVI A,09H . Register addressing mode :- in this add. mode the source or destination are register or both are register For Exp. MOV A,B ADD B direct addressing mode :- In this addressing mode the operand is given by a direct add where the data is present .in this mode the operand is memory location. Hence these type . of instruction are 3 bytes For Exp. LDA ,3445H

Indirect addressing mode:- In this add. mode the data are in the memory location which is stored in the reg pair or in this mode the instruction does not have the add. of the data to be operated For Exp. MOV M ,D Implicit addressing mode :- the implied mode of addressing does not require any Operand. The data is specified within the OPCODE itself. Generally it is a one byte Instruction. For Exp. RLC Lecturer 3
Microprocessor & interfacing Page 3

.Data transfer:- The instruction set which is used to transfer the data from one location to other location . Register addressing mode:1. Data transfer between registers Data transfer between registers:- In this instructions the source and destination both are register. MOV Rd ,Rs Description:- This instruction copies the contents of the source register into the destination register; Example: MOV B, C Before the execution of instruction

C=01

B=00

After the execution of instruction


C=01 B=01

Bytes:- 1 bytes T states:-4 Addressing mode :-Register addressing mode.

Microprocessor & interfacing

Page 4

Immediate data transfer This are two type according to the data size which are 8 bit or 16 bit 1. 8 bit data transfer 2. 16 bit data transfer 1. 8 bit data transfer :- this instruction are immediately copy the 8 bit data to the register which is source register the name of register A, B, C, D, H, L For example MVI Rs, 8 bit data Example: MVI B, 57H Before the execution of instruction
B=00

57

After the execution of instruction


B=57

57

Microprocessor & interfacing

Page 5

Addressing mode :- immediate addressing mode

Bytes:- 2 bytes No. of T sate No. of Flags MVI M, data Description:- The 8-bit data is stored immediately in the destination memory. If the operand is a memory location . its location is specified by the contents of the HL registers . Example: MVI M, 57H Before the execution of instruction A F B D H=40 A F B D H=40 C E L=00 C E L=00
4000 00

After the execution of instruction


4000 57

Bytes:- 2 bytes

No. of T sate No. of Flags

2. 16 bit data transfer :- In this instruction sets we transfer 16 bit data immediately to the register pair which are BC ,DE, HL For Example :- LXI Rp, 16 bit data
Microprocessor & interfacing Page 6

Description :- this instruction load 16 bit data specified with instruction Rp. LXI H,4000H Before the execution of instruction A B D H=00 F C E L=00

After the execution of instruction A B D H=40 F C E L=00 Bytes:- 3 bytes No. of T sate No. of Flags-0

Microprocessor & interfacing

Page 7

Lecture 4 Data transfer from memory to register or reverse :- this instruction deals with memory location and register mostly register A. This instruction sets are divided in two parts
1. Direct data transfer 2. Indirect data transfer 1. Direct data transfer :- the direct data transfer means that the memory location are given in

the instruction . The direct data transfer instruction is divided in two part according to the size of data
1. 8 bit data . 2. 16 bit data.

The direct data transfer instruction are also divided in two parts according to the direction of data
1. Memory location to the microprocessor (i/p) 2. Microprocessor to the memory location (o/p)

8 bit data transfer


1. Memory location to the microprocessor (i/p): - in this instruction we used only LDA

instruction LDA, Add (16 bit) Description :- this instruction copy the content of memory location to the accumulator the address of memory location stored 8 bit data which is copied in to the accumulator LDA,4000 Before the execution of instruction A=00 B D H F C E L
4000 58

After the execution of instruction


4000 58 Page 8

A=58 F B C D E Microprocessor & interfacing H L

Bytes:- 3 bytes No. of T sate No. of Flags-0


2. Microprocessor to the memory location (o/p): - in this instruction we used only STA

instruction STA, address (16 bit ) Description :- this instruction copies the content of the accumulator to the memory location. STA ,4000 Before the execution of instruction A=58 B D H F C E L
4000 00

After the execution of instruction

A=58 B D H

F C E L Bytes:- 3 bytes No. of T sate No. of Flags-0

4000

58

Lecture 5
Microprocessor & interfacing Page 9

16 bit data transfer Indirect data transfer :- this instruction sets are used register pair to stored the memory location so the microprocessor went to the register pair and than find the address of data so this type of instruction are called indirect data transfer instruction . This are two type according to the data size which are 8 bit or 16 bit 1. 2. 8 bit data transfer 16 bit data transfer

1. 8 bit data transfer:- in this instruction sets only 8 bit data are transferred to the accumulator The direct data transfer instruction are also divided in two parts according to the direction of data
1. Memory location to the microprocessor (i/p) 2. Microprocessor to the memory location (o/p)

Memory location to the microprocessor (i/p) 1. LDAX, Rp Description:- this instruction copies the content of memory location to the accumulator where the memory location is stored in the register pair the register pairs are BC, DE Bytes:- 3 bytes No. of T sate No. of Flags-0
1. Microprocessor to the memory location (o/p)

STAX, Rp Description :- this instruction copies of the content of accumulator to the memory location the address of memory location is given by the Rp register specify along with the instruction Bytes:- 3 bytes No. of T sate
Microprocessor & interfacing Page 10

No. of Flags-0 Between the input and output devices :- in this instruction sets microprocessor input & output devices 1. IN, 8 bit address Description: - the contents of the input port (like key board ,sensor )designated in the operand are Read and loaded into the accumulator. These instruction transfer the data to the i/p To the no other registers. Note- in this i/p & o/p instruction only 8 bit address are used but in the mpu there are 16 bit add. Bus .it means that both add.(higher order add. bus and lower order add. bus are provided same Add.) we have to choice to use both add. bus or ignore any one. IN ,01H Bytes:- 3 bytes No. of T sate No. of Flags-0 2. OUT,8 bit port add. Description: -the contents of the accumulator are copied into the o/p port (like display devices LED , printer etc )specified by the operand OUT,02H Bytes:- 3 bytes No. of T sate No. of Flags-0

Lecture 6
Microprocessor & interfacing Page 11

Arithmetic operation:- According to the flow chart the next instruction set is arithmetic instruction as we know that there are four main arithmetic al operation which are addition, subtraction, multiplication and division .but in the mpu we can perform only two arithmetical operation which are addition and subtraction .the diagram is shown below . the data are taken according to the data transfer instruction hence every arithmetical operation are divided in three parts .this division are according to the source of data. Here the destination are constant which are acc . Addition instruction:-according to the block diagram there three instruction. Which described below 1. ADI 8 bit data Description:- This instruction adds the 8 bits of data specified along with the instruction to acc. & result is stored in the acc. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 1

A=01 B D H ADI 09H

F=01 C E L

After the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

A=01 A=0A B D H F=00 C E L +09 0A

Microprocessor & interfacing

Page 12

Bytes:- 2 bytes No. of T sate:No. of Flags:-All the flags are affected. 2. ADD R Description:-This instruction adds the contents of reg R & acc. & store the result in the acc. The data of reg. B is not change but the content of acc. Is changed & it stored the result in acc. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 1

A=01 B=09 D H

F=01 C E L ADD B After the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 00

A=0A B=09 D H

F=00 C E L Bytes:- 2 bytes No. of T sate:No. of Flags:-All the flags are affected.

Microprocessor & interfacing

Page 13

3. ADD M Description:-this instruction uses HL pair as memory pointer. The contents of memory location addressed by HL pair are added with acc. & the result is stored in the acc. Before the execution of instruction A=01 B D H=40 ADD M After the execution of instruction instruction the flag register are same as previous F C E L=00
4000 09

A=0A B D H=40

F C E L=00 Bytes:- 1 bytes No. of T sate:-

4000

09

No. of Flags:-All the flags are affected

Lecture 7 Addition with carry:- carry play very important role in arithmetic operation .specially when We add more than two numbers in the mpu we add only two numbers at. A time but in
Microprocessor & interfacing Page 14

arithmetic operation we add more than two numbers .in the mpu we add two .Number which are in binary number & the result is binary number , the carry is also binary Number which are stored in a carry flag register. When we use the instruction sets of add with Carry then mpu first check the carry flag the carry flag is set according previous condition Either 0 or 1 then it add the carry to result and stored the result in acc. 1.ACI 8bit data Description:- this instruction add immediate 1 byte data, carry flag & acc & stores the result Accumulator. ACI 06H Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register A=04 B D H F=01 C E L
S=0 Z=0 X AC=0 X P=0 X CY= 1

ACI 06H when mpu read the instruction it add the 8bit data and content of carry flag to the accumulator & store the result and according to the addition it change the content of flag register. After the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

A=0B B D H

F=00 C E L

A=04 + 06 01 A= 0B in the binary number 0B=0000,1011

Here the result of add operation is 0B which change the following f lags

Microprocessor & interfacing

Page 15

Sign Flag= sign is not change hence the sign flag is not change or not in the minus from hence the content of s=0 Zero flag= the content of acc. Is not zero hence zero flag is low. Z=0 Auxiliary carry flag= in this addition operation there is no carry is generated from the lower Nibbles to higher nibbles hence it is zero. AC=0 Parity flag= the result is stored in the acc is 0B which converted in binary no. then the no of one is Counted which is 3 .then the no of 1 is odd hence P=0 Carry flag= after the addition there is no carry generated hence the carry flag is 0. CY=0

Bytes:- 2 bytes No. of T sate:No. of Flags:-All the flags are affected ADC R Description:- this instruction add the contents of reg R, carry flag CY & acc & stores the The result in the acc. ADC B Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register A=04 B=06 D H F=01 C E L
S=0 Z=0 X AC=0 X P=0 X CY= 1

ADC B when mpu read the instruction it add the 8bit data and content of carry flag to the accumulator & store the result and according to the addition it change the content of flag register. After the execution of instruction
Microprocessor & interfacing Page 16

A=0B B D H

F=00 C E L

Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

A=04 + B= 06 01 A= 0B ADC M Description:- this instruction uses HL pair as memory pointer. The contents of memory location addressed by HL pair and carry flag are added with acc. & the result is stored in acc. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 1

A=01 B D H=40 ADC M

F=01 C E L=00

4000

09

After the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

A=01
Microprocessor & interfacing Page 17

A=0B B D H

F=00 C E L

4000

09

+09 0A

Bytes:- 2 bytes No. of T sate:No. of Flags:-All the flags are affected.

Lecture 8 Subtraction instruction:- The other arithmetic instruction is subtraction instruction .this
Microprocessor & interfacing Page 18

Instruction is also subdivided in the three parts according to data Sources. SUI 8bit data Description:- this instruction subtracts the data specified along with instruction from the acc. & Result is stored in the acc. SUI 01H Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register A=00 B D H F=00 C E L
S=0 Z=0 X AC=0 X P=0 X CY= 0

SUI 01H when mpu read the instruction it add the 8bit data and content of carry flag to the accumulator & store the result and according to the subtraction it change the content of flag register. After the execution of instruction A=FF B D H F=00 C E L 11 A=00 - 01 FF

accumulator & flag register Flag register


S=1 Z=0 X AC=1 X P=0 X CY= 1

Sign Flag= In the subtraction the sign flag play very important role because it not necessary the content of acc. Is always greater than data in this condition sign flag is set. This sign flag set only when we assume the data is sign number. hence the sign flag is change or in the minus from hence the content of s=1
Microprocessor & interfacing Page 19

Zero flag= the content of acc. Is not zero hence zero flag is low. Z=0 Auxiliary carry flag= in this subtraction operation there is carry is generated from the lower Nibbles to higher nibbles hence it is zero. AC=1 Parity flag= the result is stored in the acc is FF which converted in binary no. then the no of one is Counted which is 8 .then the no of 1 is even hence P=1. Carry flag= in the subtraction operation the carry flag is also called a borrow flag. Which is shown in by CY . after the subtraction operation there is carry generated hence the carry flag is 1. CY=1 SUB R Description:- This instruction subtracts the contents of the register from the acc. & stored the result Is placed in acc. The content of reg is not change. Here R= A,B,C,D,E,H,L SUB B Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register A=04 B=01 D H F=01 C E L
S=0 Z=0 X AC=0 X P=0 X CY= 1

After the execution of instruction A=03 B=01 D H F=00 C E L A=04 - 01 03

Accumulator & flag register Flag register


S=0 Z=0 X AC=0 X P=1 Page 20 X CY= 0

Microprocessor & interfacing

SUB M Description:-This instruction subtract memory location content (whose add is given by HL) from The acc. & result is placed in the acc. The subtraction is performed in the same way as Other subtraction operation . SUB M Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 1

A=0A B D H=40 SUB M

F=01 C E L=00

4000

09

After the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

A=0A A=01 B D H F=00 C E L


4000 09

+09 01

Bytes:- 1 bytes No. of T sate:Microprocessor & interfacing Page 21

No. of Flags:-All the flags are affected.

Lecture 9 Subtraction with borrow:- this is another the of subtraction operation in the arithmetic

Microprocessor & interfacing

Page 22

which Is important & use for more than two number subtraction operation Hence there also three type of subtraction instruction according to the source of data SBI 8bit data Description:-This instruction subtracts the data and borrow flag from the acc. & store the Result in acc. SBI

Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register A=08 B D H F=01 C E L SBI 06H Description :- when mpu read the instruction it SBI the 8bit data and content of carry flag to the accumulator & store the result and according to the subtraction it change the content of flag register. After the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0 S=0 Z=0 X AC=0 X P=0 X CY= 1

A=01 B D H

F=00 C E L

A=08 - 06 01 A= 01 in the binary number 0B=0000,0011

SBB R
Microprocessor & interfacing Page 23

Description:- This instruction subtracts reg & the borrow flag from acc. & result is placed in the Acc. Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register A=04 B=01 D H F=01 C E L
S=0 Z=0 X AC=0 X P=0 X CY= 1

After the execution of instruction A=03 B=01 D H F=00 C E L A=04 B= - 01 F= 01

A= 02 Accumulator & flag register Flag register


S=0 Z=0 X AC=0 X P=1 X CY= 0

SBB M Description:-This instruction subtracts memory location & the borrow flag from acc. & Result is stored in acc. The add of memory location is given by HL reg pair. The operation are same as SBB R instruction. SBB M Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 1

Microprocessor & interfacing

Page 24

A=0A B D H=40 SBB M

F=01 C E L=00

4000

09

After the execution of instruction

Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

1 A=0A A=01 B D H F=00 C E L


4000 09

09 00

Bytes:- 1 bytes No. of T sate:No. of Flags:-All the flags are affected.

Lecture 10 Increment:- Increment is also another type of arithmetic operation .it is similar to the Addition operation but in the increment always added number is one. means It is addition of in the data which is given by various data sources. In this group of instruction we first divided according to the bit
Microprocessor & interfacing Page 25

There are two type of instruction group 1. 8 bit increment 2. 16 bit increment
INR R Description:-this instruction increment the content of the specified reg by 1 & result is stored in the

A B=FF D H

Same reg. here R=A,B,C,D,E,H,L INR B Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register F=00 S=0 Z=0 X AC=0 X P=0 C E L INR B

CY= 0

A B=00 D H

After the execution of instruction in this instruction we add 1 in the content of reg of B . here the content of reg B is FF & if we add F=00 the 1 in C Content of B & result is 100 but the B s E capacity is only L B= FF 8 bit hence it stored 00 & the carry flag is not + 01 Affected hence it is 0 B= 100 Accumulator & flag register Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

INR M Description:-This instruction increment the contents of memory location add by HL reg pair by & Result is stored back at the same memory location. INR M in this instruction mpu red the content of memory location and increment the content of memory location not the reg. Before the execution of instruction
Microprocessor & interfacing Page 26

Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

A B D H=40

F C E L=00
INR M

4000

09

After the execution of instruction Flag register


S=0 Z=0 X AC=0 4000 X 0A P=0 X

A B D H=40

F C E L=00 Bytes:- 1 bytes No. of T sate:-

CY= 0

3.

A B=01 D H

No. of Flags:-All the flags are affected. Except carry flag. INX Rp Description:-This instruction increments the contents of reg pair by 1 & result is stored in the Same reg. pair. Rp= BC, DE,HL. Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register F=00 S=0 Z=0 X AC=0 X P=0 X C=FF E L

CY= 0

A B=02 D H

INX B After the execution of instruction F=00 C=00 E L


Page 27

BC=01FF + 01

Microprocessor & interfacing

0200 Accumulator & flag register Flag register


S=0 Z=0 X AC=0 X P=1 X

Bytes:- 1 bytes No. of T sate:No. of Flags:- No flags are affected.

CY= 0

Lecture 18 Decrement:- this instruction is also the part of subtraction instruction .here the subtract by 1 It is also two types according to the size of bit.
Microprocessor & interfacing Page 28

1. 8 bit 2. 16 bit

DCR R Description:-this instruction decrements the register content by 1 & the result is stored in the Same register. here R=A,B,C,D,E,H,L. DCR B Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register A B=FF D H F=00 C E L DCR B After the execution of instruction in this instruction we subtract 1 in the content of reg of A B=FE D H F=00 C E L B . here the content of reg B is FF & if we subtract by the 1 in content of B & result is FE is stored in B
S=0 Z=0 X AC=0 X P=0 X CY= 0

B= FF 01

B= FE Accumulator & flag register Flag register


S=0 Z=0 X AC=0 X P=0 Page 29 X CY= 0

Microprocessor & interfacing

Bytes:- 1 bytes No. of T sate:No. of Flags:- all flags are affected. Except carry flag. DCR M Description:-This instruction decrements the content of memory location add. by HL reg pair by 1 & the result is stored back at the same memory location Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

A B D H=40 DCR

F C E L=00 M

4000

09

After the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

A B D H=40

F C E L=00 Bytes:- 1 bytes No. of T sate:-

4000

08

Microprocessor & interfacing

Page 30

No. of Flags:-All the flags are affected. Except carry flag. DCX Rp Description:-This instruction decrement the content of reg pair by 1 & result is stored in the Same reg pair. Here Rp= BC,DE ,HL Before the execution of instruction comment:-in this example the content of accumulator & flag register Flag register A B=01 D H F=00 C=00 E L DCX B After the execution of instruction A B=00 D H F=00 C=FF E L 1 BC=0100 + 01 00FF Accumulator & flag register Flag register
S=0 Z=0 X AC=0 X P=1 X CY= 0 S=0 Z=0 X AC=0 X P=0 X CY= 0

Bytes:- 1 bytes No. of T sate:No. of Flags:- No flags are affected. Lecture 19 Application :- The increment & decrement instructions are used for counters. Some imp. Instruction which also arithmetic instruction. These are
Microprocessor & interfacing Page 31

1. DAD Rp 2. DAA Which is describe below DAD Rp Description:-This instruction adds the contents of specified reg pair to HL pair & Stores the result in HL pair. Here Rp=BC,DE This instruction is special because it perform 16 bit addition without use of acc. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

A B D=02 H=23 DAD D

F=00 C E=10 L=F0

After the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

A B D=02 H=26

F=00 C E=10 L=00

HL=23F0H +BC=0210 HL=2600H

Bytes:- 1 bytes No. of T sate:Microprocessor & interfacing Page 32

No. of Flags:-No flags are affected. DAA Description:-The content of the acc. Are changed from a binary value to its equivalent Two, 4 bit binary coded decimal i.e. BCD number this is only instruction That uses auxiliary carry flag to perform the operation of BCD conversion

This instruction checks the following conditions: 1. If the value of the low order 4 bits D3-D0 in the acc. Is greater than 9 or it AC flag is set, the instruction adds 6 to the low order 4 bits of acc. 2. If the value of the high order 4 bits D7-D4 in the acc is greater than 9 or if CY flag is set, The instruction add 6 to the high order 4 bits of acc Note this instruction is used after the ADD, ADI etc. if it use single instruction it is cause wrong instruction 12 = 0001 0010 + 39= 0011 1001 4B= 0100 10011 MVI A,12 ADI 39 DAA Before the execution of instruction comment:-in this example the content of accumulator & flag register

Flag register A=4B B D H F=04 C E L


S=0 Z=0 X AC=0 X P=1 X CY= 0

Microprocessor & interfacing

Page 33

DAA After the execution of instruction A=51 B D H F=00 C E L

A=0101 1011 + 0110 01010110

Accumulator & flag register Flag register


S=0 Z=0 X AC=1 X P=1 X CY= 0

Bytes:- 1 bytes No. of T sate:No. of Flags:- All flags are affected.

Lecture 19 logical instruction:- The logical instruction are divided according to the number of logic gates & some logical instruction which are divided in mainly two parts according to the byte & bit (I) According to byte type 1. AND
Microprocessor & interfacing Page 34

2. OR 3. NOT 4. XOR 5. CMP 6. CMA Description:- The contents of the specified register are logically ANDed with the contents of acc. & Result is placed in the acc. ANA B Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

Binary form of the hexadecimal in the acc & reg B A=56 B=82 D H F=00 C E L A=0101 0110 B=1000 0010

ANA B After the execution of instruction Flag register


S=0 Z=0 X AC=1 X P=0 X CY= 0

1 A= 0101 0110 A F=00 B=82 C D E H L Microprocessor & interfacing B= 1000 0010

Page 35

A=0000 001

Bytes:- 1 bytes No. of T sate:No. of Flags:- 1.Sign ,Zero & parity flags are affected. 2.Carry flag reset 3.Auxillary carry flag is set ANI Data Description:- the contents of the acc. Are ANDed with 8 bit data specified along with The instruction & the result is placed in the acc. ANI 82H Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

Binary form of the hexadecimal in the acc & reg B A=56 B D H ANI 82H After the execution of instruction Flag register
S=0 Z=0 X AC=1 X P=0 X CY= 0

F=00 C E L

A=0101 0110 Data =1000 0010

Microprocessor & interfacing

Page 36

A= 0101 0110 A=01 B D H F=00 C E L Bytes:- 2 bytes No. of T sate:No. of Flags:- 1.Sign ,Zero & parity flags are affected. 1. Auxiliary carry flag is set. ANA M Descriptions:- the contents of memory location are ANDed with acc. & result is placed in acc. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

B= 1000 0010 A=0000 001

2. Carry flag reset.

A=56 B D H=40 ANA M

F C E L=00

A=01001 0110 M = 1000 0010

4000

82

After the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

A=01 B D H=40

F C E L=00

A=01001 0110 M = 1000 0010 A=0000 001


Page 37

Microprocessor & interfacing

4000

82

Bytes:- 1 bytes No. of T sate:No. of Flags:- 1.Sign ,Zero & parity flags are affected. 3.Auxiliary carry flag is set. 2. Carry flag reset.

Lecture 20 ORA R Description:- the contents of specified reg or ORed with acc. & Result is stored in acc. ORA B
Microprocessor & interfacing Page 38

Before the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

Binary form of the hexadecimal in the acc & reg B A=56 B=82 D H F=00 C E L A=0101 0110 B=1000 0010

ORA B After the execution of instruction Flag register


S=0 Z=0 X AC=1 X P=0 X CY= 0

1 A= 0101 0110 A=D6 B=82 D H F=00 C E L Bytes:- 1 bytes No. of T sate:No. of Flags:- 1.Sign ,Zero & parity flags are affected. 2.Carry flag reset 3.Auxillary carry flag is set ORI 82H B= 1000 0010 A=1101 0110

Description:- The contents of acc. Are ORed with 8 bit data specified with the instruction & the
Microprocessor & interfacing Page 39

Result is stored in acc. The operation of ORing is performed in the same way as ORA R. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

Binary form of the hexadecimal in the acc & reg B A=56 B D H ORI 82H After the execution of instruction Flag register
S=0 Z=0 X AC=1 X P=0 X

F=00 C E L

A=0101 0110 Data =1000 0010

1 A= 0101 0110 A=D6 B D H F=00 C E L Bytes:- 2 bytes No. of T sate:No. of Flags:- 1.Sign ,Zero & parity flags are affected. 3.Auxiliary carry flag is set. ORA M B= 1000 0010 A=1101 0110

CY= 0

2. Carry flag reset.

Description:- The contents of acc. Are ORed with memory location contents & result is stored in acc. The add of memory location is given by HL reg pair .
Microprocessor & interfacing Page 40

Before the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

A=56 B D H=40 ORA M

F C E L=00

A=01001 0110 M = 1000 0010

4000

82

After the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

A=D6 B D H=40

F C E L=00
4000 82

A=01001 0110 M = 1000 0010 A=1101 0110

Bytes:- 1 bytes No. of T sate:No. of Flags:- 1.Sign ,Zero & parity flags are affected. 3.Auxiliary carry flag is set. Lecture 21 XRA R Description:- the contents of specified reg is EXORed with acc & result is placed in the acc. XRA B
Microprocessor & interfacing Page 41

2. Carry flag reset.

Before the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

Binary form of the hexadecimal in the acc & reg B A=56 B=82 D H XRA B After the execution of instruction Flag register
S=0 Z=0 X AC=1 X P=0 X CY= 0

F=00 C E L

A=0101 0110 B=1000 0010

1 A= 0101 0110 A=D4 B=82 D H F=00 C E L Bytes:- 1 bytes No. of T sate:No. of Flags:- 1.Sign ,Zero & parity flags are affected. 2.Carry flag reset 3.Auxillary carry flag is set XRI 82H B= 1000 0010 A=1101 0100

Description:- the content of acc. Are EXORed with 8bit data specified along with the instruction & Result is placed in acc.
Microprocessor & interfacing Page 42

Before the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

Binary form of the hexadecimal in the acc & reg B A=56 B D H XRI 82H After the execution of instruction Flag register
S=0 Z=0 X AC=1 X P=0 X

F=00 C E L

A=0101 0110 Data =1000 0010

1 A= 0101 0110 A=D4 B D H F=00 C E L Bytes:- 2 bytes No. of T sate:No. of Flags:- 1.Sign ,Zero & parity flags are affected. 3.Auxiliary carry flag is set. B= 1000 0010 A=1101 0100

CY= 0

2. Carry flag reset.

XRA M Description:- The contents of memory location are EXORed with acc & result is placed in acc. The Add. of memory location is given by HL reg pair. Before the execution of instruction
Microprocessor & interfacing Page 43

Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 0

A=56 B D H=40 XRA M

F C E L=00

A=01001 0110 M = 1000 0010

4000

82

After the execution of instruction Flag register


S=0 Z=0 X AC=0 X P=0 X CY= 0

A=D4 B D H=40

F C E L=00
4000 82

A=01001 0110 M = 1000 0010 A=1101 0100

Bytes:- 1 bytes No. of T sate:No. of Flags:- 1.Sign ,Zero & parity flags are affected. 3.Auxiliary carry flag is set. 2. Carry flag reset.

Lecture 22 Comparison instruction:- comparison is the process in which we compare the two number in which one number is greater or smaller . actually in the mpu comparison process is perform subtraction operation in which two numbers are

Microprocessor & interfacing

Page 44

subtract. in the Comparison operation the result in not there are only two condition are required . The two condition are 1. The subtract number is greater 2. the subtract number is smaller. this is detected by the borrow(carry) 1. in the subtract operation when carry is generated the subtracted number is greater 2. in the subtract operation if carry is not generated the subtracted no is smaller. CMP R Description:- this instruction compares the reg contents with acc. The operation of comparing is Performed by subtracting reg from acc.
Note:- the contents of reg or acc are not change.

The result of comparison is indicated by setting flags as follow: 1.A>R : cy is reset & zero flag is reset. 2.A=R :zero flag 3.A<R: cy is set. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X

A=56 B=82 D H
CMP B

F=00 C E L

Binary form of the hexadecimal in the acc & reg B A=56 0101 0110 B=82 1000 0010

CY= 0

After the execution of instruction Flag register


S=0 Z=0 X

A=56 B=82 D H

F=01 C E L

1 1 A= 0101 0110 B= 1000 0010 A=1101 0100 carry flag is set . It means that reg. B is greater than A .but the content A is not change

AC=1

P=0

CY=

Microprocessor & interfacing

Page 45

Bytes:- 1 bytes No. of T sate:No. of Flags:- 1.All flags are affected. 2.Carry flag & Zero flag used to reflact result. CPI data Description:-this instruction compares immediate data with acc. In the same way as CMP R Instruction & result is indicated by Z & Cy flags.the content of acc. Is not altered. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X

A=56 B D H

Binary form of the hexadecimal in the acc & reg B A=56= 0101 0110 F=00 Data =82=1000 0010 C E CPI 82H L After the execution of instruction Flag register
S=0 Z=0 X AC=1

CY= 0

A=56 B D H

F=01 C E L Bytes:- 2 bytes No. of T sate:-

1 A= 0101 0110 B= 1000 0010 A=1101 0100

P=0

CY= 1

No. of Flags:- 1.All flags are affected. 2.Carry flag & Zero flag used to reflact result CMP M Description:-This instruction compares the acc. & memory location contents the add. Of memory Is given by HL reg. pair . the operation is performed in same way as CMP R instruction. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X

A=01001 0110 A=56 F 4000 82 B C Microprocessor & interfacing Page 46 D E H=40 L=00

CY= 0

M = 1000 0010
CMP M

After the execution of instruction Flag register


S=0 Z=0 X

AC=0

P=0

A=56 B D H=40

F=01 C E L=00
4000

A=01001 0110 M = 1000 0010 A=1101 0100


82

CY= 1

Bytes:- 1 bytes No. of T sate:No. of Flags:- 1.All flags are affected. The last byte type of logical instruction is complement instruction. As we that the all the arithmatic & logical operation is performed in acc. In the comparison operation mpu change the content of acc.in this operation we have only one data needs so there is no need of diff. type of data source so there is only one instruction. Which are CMA

2.Carry flag & Zero flag used to reflact result

Description:- This instruction complements the contents of acc & result is placed in acc. The Compliant is performing NOT operation with each bit .In this operation all 0s will be replaced by 1s & all 1s with 0s.
Before the execution of instruction

Flag register
S=0 Z=0 X AC=0 X P=0 X

A=56 B D H

F=00 C E L

Binary form of the hexadecimal in the acc & reg B A=56 0101 0110 CMA After the execution of instruction

CY= 0

Flag register
S=0 Z=0 X AC=1 X P=0 X CY= 0

Microprocessor & interfacing

Page 47

A=56 B D H

F=00 C E L Bytes:- 1 bytes

A= 1010 1001

No. of T sate:No. of Flags:- 1.No flags are affected.

Lecture 23 According bit logical operations The bit type of instruction is the instruction which deal with on single bit . as we know that in hexadecimal operation every bits position play very imp role so this types of operation are very imp. the operations are 1. CMC
Microprocessor & interfacing Page 48

2. Rotate operation CMC Description:- This instruction complements the carry flag .if carry flag =1 instruction wii reset it & if CY flag=0 instruction will set it. Before the execution of instruction Flag register
S=0 Z=0 X AC=0 X P=0 X CY= 1

Binary form of the hexadecimal in the acc & reg B A=56 B D H CMC After the execution of instruction Flag register
S=0 Z=0 X AC=1 X P=0 X CY= 0

F=01 C E L

A=56 0101 0110

A=56 B D H

F=00 C E L Bytes:- 1 bytes No. of T sate:-

A= 1010 1001

No. of Flags:- 1.Only carry flag is affected & No other

flags are affected

Microprocessor & interfacing

Page 49

Rotate operation:- here the rotation means change the bit position but dont any bit. As we know The that if we change the position of bit the value of hexadecimal number is different so this types of operation performed very imp role in the mpu instruction set. The block diagram shows the different type of rotation operations. The rotation operation is mainly divided in two parts according to the direction. Which are 1.Left rotate . 2.Right rotate. Then according to mpu the rotate operation is also divided in two parts. which are 1 .rotate with carry 2. rotate without carry. Left rotate 1.RAL Description:- This instruction rotates the contents of acc. Left by 1 bit with carry .it means when the RAL executated the D7 bit moves to the carry & contents of carry move to the D0 bit. Before the execution of instruction ACC
0 D0 1 D7 0 D6

CY
1

1 0 D5 D4 1 1 D3 0 D2 D1

Binary form of the hexadecimal in the acc & reg B A=56 B D H RAL F=01 C E L A=56= 0101 0110

Microprocessor & interfacing

Page 50

After the execution of instruction

ACC
1 0 1

CY
0

0 1 1 0 1

D7 A=AD B D H F=00 C E L

D6

D5

D4

D3

D2

D1

D0

A=AD= 1010 1101

Bytes:- 1 bytes No. of T sate:No. of Flags:- Only carry flag is affected & .No other flags are affected. 2.RLC Description:- This instruction rotates the contents of acc. Left by 1 bit without carry .it means when the RLC executated the D7 bit moves to the carry & move to the D0 bit. Before the execution of instruction CY 1 ACC
0 D7 D0 1 0 D6 1 D5 0 D4 1 1 D3 0 D2 D1

Binary form of the hexadecimal in the acc & reg B A=56 B D H RLC After the execution of instruction
0 Microprocessor & interfacing Page 51

F=01 C E L

A=56 =0101 0110

CY ACC
1 0 1 0 1 1 0 0

D7 A=AC B D H F=00 C E L

D6

D5

D4

D3

D2

D1

D0

A=AC= 1010 1100

Bytes:- 1 bytes No. of T sate:No. of Flags:- Only carry flag is affected & .No other flags are affected Right Rotate 1.RAR Description:- This instruction rotates the contents of acc. right by 1 bit with carry .it means when the RAR executated the D0 bit moves to the carry & contents of carry move to the D7 bit. Before the execution of instruction ACC
0 D0 1 D7 0 D6

CY
1

1 0 D5 D4 1 1 D3 0 D2 D1

Binary form of the hexadecimal in the acc & reg B A=56 B D H RAL
Microprocessor & interfacing Page 52

F=01 C E L

A=56 =0101 0110

After the execution of instruction ACC CY


1 0 1 0 0 1 0 1 1

D7 A=AB B D H F=00 C E L

D6

D5

D4

D3

D2

D1

D0

A= AB=1010 1011

Bytes:- 1 bytes No. of T sate:No. of Flags:- Only carry flag is affected & .No other flags are affected. 2.RRC Description:- This instruction rotates the contents of acc. Right by 1 bit without carry .it means when the RLC executated the D0 bit moves to the carry & move to the D7 bit. Before the execution of instruction CY 1 ACC
0 D1 D0 1 D7 0 D6 1 D5 0 D4 1 1 D3 0 D2

Binary form of the hexadecimal in the acc & reg B A=56 B D H RLC After the execution of instruction
Microprocessor & interfacing 0 Page 53

F=01 C E L

A=56 = 0101 0110

CY ACC
1 0 1 0 1 0 1 1

D7 A=AB B D H F=00 C E L

D6

D5

D4

D3

D2

D1

D0

A= AB=1010 1011

Bytes:- 1 bytes No. of T sate:No. of Flags:- Only carry flag is affected & .No other flags are affected Application of Rotate operation:-The rotate instruction is used arithmetic multiply & divide operation & for serial data transfer. 2.if we rotate the content of acc. 1bit right the content of acc. Is half . 08=0000 1000 After execution of rotate operation 04=0000 0100 3.If we rotate the content of acc 1bit left the content of acc is double. 08=0000 1000 After execution of rotate operation 10 =0001 0000 Lecture 24 1.Branch instruction within the program:- the branch instruction is also divided in two parts Which is shown in the block diagram. This types of branch instruction is called jump because the PC change directly or jump the desired add. Unconditional branch instruction:- in this instruction set the program counter is change the add.
Microprocessor & interfacing Page 54

Without checking any condition. This instruction is executed every time when the program counter is come on the add in which branch instruction is stored. There Is only 1 instruction which are jump which opcode is JMP. JMP Description:- When this instruction is executed the instruction directs mpu about jump & it provides The add where mpu has to transfer the control. JMP 4000 Bytes:- 3 bytes No. of T sate:-10 T state No. of Flags:- No flags are affected because this instructions are not perform in the ALU. Conditional branch instruction:- in the mpu conditions means the states of data after the operation. As we know that this conditions is reflected by flags so the conditional jump instruction are according to the flags.There are five flags but there is one flag auxiliary flag is not used so There are 4 flags are used. Which is explain after the description. Description:- in conditional jump instructions when the condition is true or satisfied then only jump Is made at the specified add. if condition is false or not satisfied it will check & proceed further to execute to execute the next instruction after it According the flags there are 4 conditions.

Every flags is single bit it means that they two types of no which are 1=set 0=reset Hence all are divided in two parts which are shown in block diagram. 1. Carry flag

Microprocessor & interfacing

Page 55

(i) (ii)

JC= jump if carry flag is set(1) JNC=jump if carry flag is reset(0)

2. Zero flag (i) (ii) JZ=jump if zero flag is set(1) JNZ=jump if zero flag is reset(0)

3. Sign flag (i) (ii) JP=jump if sign flag is reset(0) JM=jump if sign flag is set(1)

4. Parity flag (i) (ii) JPE=jump if parity is even(parity flag is set 1) JPO=jump if parity is odd(parity flag is reset 0)

Bytes:- 3 bytes No. of T sate:-10 T state(if condition is satisfied or instruction is executated.) or 7(if instruction is Executated.) No. of Flags:- No flags are affected because this instructions are not perform in the ALU. Branch instruction from one program to another program:-Now the second types of branching instruction which jump the program counter from one program to another program which are called subroutine (the word subroutine can be better understand when we do the time delay & counter program) The instruction set is also divided in two parts which is shown in block diagram.

Microprocessor & interfacing

Page 56

Anda mungkin juga menyukai