Presentation is loading. Please wait.

Presentation is loading. Please wait.

R.RAJKUMAR DEPARTMENT OF CSE

Similar presentations


Presentation on theme: "R.RAJKUMAR DEPARTMENT OF CSE"— Presentation transcript:

1 R.RAJKUMAR DEPARTMENT OF CSE
UNIT Microprocessor R.RAJKUMAR DEPARTMENT OF CSE

2 Microprocessor understands Machine Language only!
Microprocessor cannot understand a program written in Assembly language A program known as Assembler is used to convert a Assembly language program to machine language Assembly Language Program Assembler Program Machine Language Code

3 INTRODUCTION TO 8085 Differences between:
Microprocessor –silicon chip which includes ALU, register circuits & control circuits Microcomputer –a computer with a microprocessor as its CPU. Includes memory, I/O etc. Microcontroller –silicon chip which includes microprocessor, memory & I/O in a single package. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

4 Definition of the Microprocessor
CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018 Definition of the Microprocessor The microprocessor is a programmable device that takes in numbers, performs on them arithmetic or logical operations according to the program stored in memory and then produces other numbers as a result. 11/17/2018 CS1007 MICROPROCESSOR AND INTERFACING CS2007 MICROPROCESSOR AND INTERFACING

5 1. Introduction A microprocessor executes instructions given by the user Instructions should be in a language known to the microprocessor Microprocessor understands the language of 0’s and 1’s only This language is called Machine Language

6 CS1007 MICROPROCESSOR AND INTERFACING
11/17/2018 Definition (Contd.) Lets expand each of the Programmable device: The microprocessor can perform different sets of operations on the data it receives depending on the sequence of instructions supplied in the given program. By changing the program, the microprocessor manipulates the data in different ways. Instructions: Each microprocessor is designed to execute a specific group of operations. This group of operations is called an instruction set. This instruction set defines what the microprocessor can and cannot do. 11/17/2018 CS1007 MICROPROCESSOR AND INTERFACING CS2007 MICROPROCESSOR AND INTERFACING

7 CS1007 MICROPROCESSOR AND INTERFACING
11/17/2018 Definition (Contd.) Takes in: The data that the microprocessor manipulates must come from somewhere. It comes from what is called “input devices”. These are devices that bring data into the system from the outside world. These represent devices such as a keyboard, a mouse, switches, and the like. 11/17/2018 CS1007 MICROPROCESSOR AND INTERFACING CS2007 MICROPROCESSOR AND INTERFACING

8 CS1007 MICROPROCESSOR AND INTERFACING
11/17/2018 Definition (Contd.) Numbers: There are only 10 type of people in the world one can understand others don’t The microprocessor has a very narrow view on life. It only understands binary numbers. A binary digit is called a bit The microprocessor recognizes and processes a group of bits together. This group of bits is called a “word”. The number of bits in a Microprocessor’s word, is a measure of its “abilities”. 11/17/2018 CS1007 MICROPROCESSOR AND INTERFACING CS2007 MICROPROCESSOR AND INTERFACING

9 CS1007 MICROPROCESSOR AND INTERFACING
Definition (Contd.) CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018 Arithmetic and Logic Operations: Every microprocessor has arithmetic operations such as add and subtract as part of its instruction set. Most microprocessors will have operations such as multiply and divide. Some of the newer ones will have complex operations such as square root. In addition, microprocessors have logic operations as well. Such as AND, OR, XOR, shift left, shift right, etc. Again, the number and types of operations define the microprocessor instruction set and depends on the specific microprocessor. 11/17/2018 CS1007 MICROPROCESSOR AND INTERFACING CS2007 MICROPROCESSOR AND INTERFACING

10 CS1007 MICROPROCESSOR AND INTERFACING
Definition (Contd.) CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018 Stored in memory : First, what is memory? Memory is the location where information is kept while not in current use. Memory is a collection of storage devices. Usually, each storage device holds one bit. Also, in most kinds of memory, these storage devices are grouped into groups of 8. These 8 storage locations can only be accessed together. So, one can only read or write in terms of bytes to form memory. Memory is usually measured by the number of bytes it can hold. It is measured in Kilos, Megas and lately Gigas. A Kilo in computer language is =1024. So, a KB (KiloByte) is 1024 bytes. Mega is 1024 Kilos and Giga is 1024 Mega. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018 CS2007 MICROPROCESSOR AND INTERFACING

11 CS1007 MICROPROCESSOR AND INTERFACING
Definition (Contd.) CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018 Stored in memory: When a program is entered into a computer, it is stored in memory. Then as the microprocessor starts to execute the instructions, it brings the instructions from memory one at a time. Memory is also used to hold the data. The microprocessor reads (brings in) the data from memory when it needs it and writes (stores) the results into memory when it is done. 11/17/2018 CS1007 MICROPROCESSOR AND INTERFACING CS2007 MICROPROCESSOR AND INTERFACING

12 CS1007 MICROPROCESSOR AND INTERFACING
Definition (Contd.) CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018 Produces: For the user to see the result of the execution of the program, the results must be presented in a human readable form. The results must be presented on an output device. This can be the monitor, a paper from the printer, a simple LED or many other forms. 11/17/2018 CS1007 MICROPROCESSOR AND INTERFACING CS2007 MICROPROCESSOR AND INTERFACING

13 8085 Architecture

14 CS1007 MICROPROCESSOR AND INTERFACING
8085 Architecture CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018 The features of INTEL 8085 are : It is an 8 bit processor. It is a single chip N-MOS device with 40 pins. It has multiplexed address and data bus.(AD0-AD7). It works on 5 Volt dc power supply. The maximum clock frequency is 3 MHz while minimum frequency is 500kHz. It provides 74 instructions with 5 different addressing modes. 11/17/2018 CS1007 MICROPROCESSOR AND INTERFACING CS2007 MICROPROCESSOR AND INTERFACING

15 CS1007 MICROPROCESSOR AND INTERFACING
Contd.. 11/17/2018 It provides 16 address lines so it can access 2^16 =64K bytes of memory. It generates 8 bit I/O address so it can access 2^8=256 input ports. It provides 5 hardware interrupts: TRAP, RST 5.5, RST 6.5, RST 7.5,INTR. It provides Acc ,one flag register ,6 general purpose registers and two special purpose registers(SP,PC). It provides serial lines SID ,SOD. So serial peripherals can be interfaced with 8085 directly. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018 CS2007 MICROPROCESSOR AND INTERFACING

16 8085 Architecture Diagram CS1007 MICROPROCESSOR AND INTERFACING
11/17/2018

17 Arithmetic and Logical group
Accumulator: It is 8 bit general purpose register. It is connected to ALU. So most of the operations are done in Acc. Temporary register: It is not available for user All the arithmetic and logical operations are done in the temporary register but user can’t access it. Flag: It is a group of 5 flip flops used to know status of various operations done. The Flag Register along with Accumulator is called PSW or Program Status Word. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

18 Arithmetic and Logical group Contd..
Flag Register is given by: S : Sign flag is set when result of an operation is negative. X : It is don’t care flip flops. Z : Zero flag is set when result of an operation is 0. Ac : Auxiliary carry flag is set when there is a carry out of lower nibble or lower four bits of the operation. CY : Carry flag is set when there is carry generated by an operation. P : Parity flag is set when result contains even number of 1’s. S Z X AC P CY CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

19 Register Group Temporary registers (W,Z):
These are not available for user. These are loaded only when there is an operation being performed. General purpose: There are six general purpose registers in 8085 namely B,C,D,E,H,L.These are used for various data manipulations. There are two special purpose registers in 8085: SP :Stack Pointer. PC:Program Counter. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

20 Register Group Contd.. Stack Pointer: This is a temporary storage memory 16 bit register. Since there are only 6 general purpose registers, there is a need to reuse them . Whenever stack is to be used previous values are PUSHED on stack and then after the program is over these values are POPED back. Program Counter: It is 16 bit register used to point the location from which the next instruction is to be fetched. When a single byte instruction is executed PC is automatically incremented by 1. Upon reset PC contents are set to 0000H and next instruction is fetched onwards. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

21 Instruction Register, Decoder & Control
When an instruction is fetched , it is executed in instruction register. This register takes the Opcode value only. Instruction decoder: It decodes the instruction from instruction register and then to control block. Timing and control: This is the control section of µP. It accepts clock input . CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

22 Interrupt Control It accepts different interrupts like TRAP INT5.5,6.5,7.5and INTR. Serial IO Control Group It is used to accept the serial 1 bit data by using SID and SOD signals and it can be performed by using SIM & RIM instructions. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

23 CS1007 MICROPROCESSOR AND INTERFACING
8085 Pin Diagram CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

24 CS1007 MICROPROCESSOR AND INTERFACING
8085 Pin Diagram CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

25 CS1007 MICROPROCESSOR AND INTERFACING
8085 Pin Description Some important pins are : AD0-AD7: Multiplexed Address and data lines. A8-A15: Tri-stated higher order address lines. ALE: Address latch enable is an output signal.It goes high when operation is started by processor . S0,S1: These are the status signals used to indicate type of operation. RD¯: Read is active low input signal used to read data from I/O device or memory. WR¯:Write is an active low output signal used write data on memory or an I/O device. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

26 CS1007 MICROPROCESSOR AND INTERFACING
Contd.. READY: This an output signal used to check the status of output device. If it is low, µP will WAIT until it is high. TRAP: It is an Edge triggered highest priority , non mask able interrupt. After TRAP, restart occurs and execution starts from address 0024H. RST5.5,6.5,7.5:These are maskable interrupts and have low priority than TRAP. INTR¯&INTA:INTR is a interrupt request signal after which µP generates INTA or interrupt acknowledge signal. IO/M¯:This is output pin or signal used to indicate whether 8085 is working in I/O mode(IO/M¯=1) or Memory mode(IO/M¯=0 ). CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

27 CS1007 MICROPROCESSOR AND INTERFACING
Contd.. HOLD&HLDA:HOLD is an input signal .When µP receives HOLD signal it completes current machine cycle and stops executing next instruction.In response to HOLD µP generates HLDA that is HOLD Acknowledge signal. RESET IN¯:This is input signal.When RESET IN¯ is low µp restarts and starts executing from location 0000H. SID: Serial input data is input pin used to accept serial 1 bit data . X1X2 :These are clock input signals and are connected to external LC,or RC circuit.These are divide by two so if 6 MHz is connected to X1X2, the operating frequency becomes 3 MHz. VCC&VSS:Power supply VCC=+ -5Volt& VSS=-GND reference. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

28 Low-level/High-level languages
Machine language and Assembly language are both Microprocessor specific (Machine dependent) so they are called Low-level languages Machine independent languages are called High-level languages For e.g. BASIC, PASCAL,C++,C,JAVA, etc. A software called Compiler is required to convert a high-level language program to machine code

29 Memory Pointer Registers Timing and Control Unit
2. Programming model of 8085 Accumulator ALU Flags Instruction Decoder Register Array Memory Pointer Registers Timing and Control Unit 16-bit Address Bus 8-bit Data Bus Control Bus

30 Stack Pointer (SP) (16-bit)
Accumulator (8-bit) Flag Register (8-bit) B (8-bit) C (8-bit) D (8-bit) E (8-bit) H (8-bit) L (8-bit) Stack Pointer (SP) (16-bit) Program Counter (PC) (16-bit) S Z AC P CY 8- Lines Bidirectional 16- Lines Unidirectional

31 Overview: 8085 Programming model
Six general-purpose Registers Accumulator Register Flag Register Program Counter Register Stack Pointer Register

32 Six general-purpose registers
B, C, D, E, H, L Can be combined as register pairs to perform 16-bit operations (BC, DE, HL) Accumulator – identified by name A This register is a part of ALU 8-bit data storage Performs arithmetic and logical operations Result of an operation is stored in accumulator

33 Flag Register This is also a part of ALU 8085 has five flags named
Zero flag (Z) Carry flag (CY) Sign flag (S) Parity flag (P) Auxiliary Carry flag (AC)

34 These flags are five flip-flops in flag register
Execution of an arithmetic/logic operation can set or reset these flags Condition of flags (set or reset) can be tested through software instructions 8085 uses these flags in decision-making process

35 Program Counter (PC) A 16-bit memory pointer register Used to sequence execution of program instructions Stores address of a memory location where next instruction byte is to be fetched by the 8085 when 8085 gets busy to fetch current instruction from memory PC is incremented by one PC is now pointing to the address of next instruction

36 Stack Pointer Register
a 16-bit memory pointer register Points to a location in Stack memory Beginning of the stack is defined by loading a 16-bit address in stack pointer register

37 TIMING DIAGRAM

38 TIMING DIAGRAM Timing Diagram is a graphical representation. It represents the execution time taken by each instruction in a graphical format. The execution time is represented in T-states. Instruction Cycle:     The time required to execute an instruction is called instruction cycle. Machine Cycle: The time required to access the memory or input/output devices is called machine cycle. T-State: The machine cycle and instruction cycle takes multiple clock periods. A portion of an operation carried out in one system clock period is called as T-state.

39 Timing and State Diagram
The µP operates with reference to clock signal.The rise and fall of the pulse of the clock gives one clock cycle. Each clock cycle is called a T state and a collection of several T states gives a machine cycle. Important machine cycles are : Op-code fetch. Memory read. Memory write. I/Op-read. I/O write. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

40 MACHINE CYCLES OF 8085 The 8085 microprocessor has 5 basic machine cycles. Opcode fetch cycle (4T) Memory read cycle (3 T) Memory write cycle (3 T) I/O read cycle (3 T) I/O write cycle (3 T)

41 Timing and State Diagram Cont..
Op-code Fetch: It basically requires 4 T states from T1-T4 S0=1,S1=1 for Op-code fetch cycle. The ALE pin goes high at first T state always. AD0-AD7 are used to fetch OP-code and store the lower byte of Program Counter. A8-A15 store the higher byte of the Program Counter while IO/M¯ will be low since it is memory related operation. RD¯ will only be low at the Op-code fetching time. WR¯ will be at HIGH level since no write operation is done. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

42 Opcode fetch cycle (4T)

43 Timing and State Diagram Contd..
Memory write Cycle: It basically requires 3T states from T1-T3 . The ALE pin goes high at first T state always. AD0-AD7 are used to fetch data from CPU and store the lower byte of address. A8-A15 store the higher byte of the address while IO/M¯ will be low since it is memory related operation. RD¯ will be HIGH since no read operation is done. WR¯ will be at LOW level only when data fetching is done. S0=1,S1=0 for Memory write cycle. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

44 Memory Write Machine Cycle
The memory write machine cycle is executed by the processor to write a data byte in a memory location. The processor takes, 3T states to execute this machine cycle.

45 Timing and State Diagram Contd..
Memory Read Cycle: It basically requires 3T states from T1-T3 . The ALE pin goes high at first T state always. AD0-AD7 are used to fetch data from memory and store the lower byte of address. A8-A15 store the higher byte of the address while IO/M¯ will be low since it is memory related operation. RD¯ will only be low at the data fetching time. WR¯ will be at HIGH level since no write operation is done. S0=0,S1=1 for Memory read cycle. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

46 Memory Read Machine Cycle

47 I/O Write Cycle The I/O write machine cycle is executed by the processor to write a data byte in the I/O port or to a peripheral, which is I/O, mapped in the system. The processor takes, 3T states to execute this machine cycle

48 Addressing Modes of 8085

49 CS1007 MICROPROCESSOR AND INTERFACING
Addressing Modes of 8085 To perform any operation, we have to give the corresponding instructions to the microprocessor. In each instruction, programmer has to specify 3 things: Operation to be performed. Address of source of data. Address of destination of result. The method by which the address of source of data or the address of destination of result is given in the instruction is called Addressing Modes. The term addressing mode refers to the way in which the operand of the instruction is specified. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

50 Addressing Modes Contd..
Intel 8085 uses the following addressing modes: 1. Direct Addressing Mode 2. Register Addressing Mode 3. Register Indirect Addressing Mode 4. Immediate Addressing Mode 5. Implicit Addressing Mode CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

51 Direct Addressing Mode
In this mode, the address of the operand is given in the instruction itself. LDA 2500 H //Load the contents of memory location 2500 H in accumulator is the address of source. LDA is the operation. 2500 H is the address of source Accumulator is the destination. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

52 Example: Direct Addressing
16-bit Address of the memory location is specified in the instruction directly Examples- LDA 2050H ;load A with contents of memory location with address 2050H STA 3050H ;store A with contents of memory location with address 3050H

53 Register Addressing Mode
In this mode, the operand is in general purpose register MOV A, B //Move the contents of register B to A. MOV is the operation. B is the source of data. A is the destination. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

54 Operands are one of the internal registers of 8085 Examples- MOV A, B
Register Addressing Operands are one of the internal registers of 8085 Examples- MOV A, B ADD C

55 Register Indirect Addressing Mode
In this mode, the address of operand is specified by a register pair. MOV is the operation. M is the memory location specified by H-L register pair. A is the destination. MOV A, M \\ Move data from memory location specified by H-L pair to accumulator. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

56 Example: Indirect Addressing
A memory pointer register is used to store the address of the memory location Example- MOV M, A ;copy register A to memory location whose address is stored in register pair HL H L A 30H 20H 50H 2050H 30H

57 Immediate Addressing Mode
In this mode, the operand is specified within the instruction itself. MVI A, 05 H //Move 05 H in accumulator. MVI is the operation. 05 H is the immediate data (source). A is the destination. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

58 Example: Immediate Addressing
Value of the operand is given in the instruction itself Example- MVI A, 20H LXI H, 2050H ADI 30H SUI 10H

59 Implicit Addressing Mode
If address of source of data as well as address of destination of result is fixed, then there is no need to give any operand along with the instruction. CMA //Complement accumulator CMA is the operation. A is the source. A is the destination. CS1007 MICROPROCESSOR AND INTERFACING 11/17/2018

60 Assembly Language of 8085 It uses English like words to convey the action/meaning called as MNEMONICS For e.g. MOV to indicate data transfer ADD to add two values SUB to subtract two values

61 Assembly language program to add two numbers
MVI A, 2H ;Copy value 2H in register A MVI B, 4H ;Copy value 4H in register B ADD B ;A = A + B Note: Assembly language is specific to a given processor For e.g. assembly language of 8085 is different than that of Motorola 6800 microprocessor

62 3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV 246 Instructions, e.g. MOV A,B 8085 instructions can be classified as Data Transfer (Copy) Arithmetic Logical and Bit manipulation Branch Machine Control

63 1. Data Transfer (Copy) Operations
Load a 8-bit number in a Register Copy from Register to Register Copy between Register and Memory Copy between Input/Output Port and Accumulator Load a 16-bit number in a Register pair Copy between Register pair and Stack memory

64 Example Data Transfer (Copy) Operations / Instructions
Load a 8-bit number 4F in register B Copy from Register B to Register A Load a 16-bit number 2050 in Register pair HL Copy from Register B to Memory Address 2050 Copy between Input/Output Port and Accumulator MVI B, 4FH MOV A,B LXI H, 2050H MOV M,B OUT 01H IN 07H

65 2. Arithmetic Operations
Addition of two 8-bit numbers Subtraction of two 8-bit numbers Increment/ Decrement a 8-bit number

66 Example Arithmetic Operations / Instructions
Add a 8-bit number 32H to Accumulator Add contents of Register B to Accumulator Subtract a 8-bit number 32H from Accumulator Subtract contents of Register C from Accumulator Increment the contents of Register D by 1 Decrement the contents of Register E by 1 ADI 32H ADD B SUI 32H SUB C INR D DCR E

67 3. Logical & Bit Manipulation Operations
AND two 8-bit numbers OR two 8-bit numbers Exclusive-OR two 8-bit numbers Compare two 8-bit numbers Complement Rotate Left/Right Accumulator bits

68 Example Logical & Bit Manipulation Operations / Instructions
Logically AND Register H with Accumulator Logically OR Register L with Accumulator Logically XOR Register B with Accumulator Compare contents of Register C with Accumulator Complement Accumulator Rotate Accumulator Left ANA H ORA L XRA B CMP C CMA RAL

69 These operations are used to control the flow of program execution
4. Branching Operations These operations are used to control the flow of program execution Jumps Conditional jumps Unconditional jumps Call & Return Conditional Call & Return Unconditional Call & Return

70 Example Branching Operations / Instructions
Jump to a 16-bit Address 2080H if Carry flag is SET Unconditional Jump Call a subroutine with its 16-bit Address Return back from the Call Call a subroutine with its 16-bit Address if Carry flag is RESET Return if Zero flag is SET JC 2080H JMP 2050H CALL 3050H RET CNC 3050H RZ

71 5. Machine Control Instructions
These instructions affect the operation of the processor. For e.g. HLT Stop program execution NOP Do not perform any operation

72 Input/Output Addressing
8-bit address of the port is directly specified in the instruction Examples- IN 07H OUT 21H

73 Instruction & Data Formats
8085 Instruction set can be classified according to size (in bytes) as 1-byte Instructions 2-byte Instructions 3-byte Instructions

74 1. One-byte Instructions
Includes Opcode and Operand in the same byte Examples- Opcode Operand Binary Code Hex Code MOV C, A 4FH ADD B 80H HLT 76H

75 2. Two-byte Instructions
First byte specifies Operation Code Second byte specifies Operand Examples- Opcode Operand Binary Code Hex Code MVI A, 32H 3EH 32H B, F2H 06H F2H

76 3. Three-byte Instructions
First byte specifies Operation Code Second & Third byte specifies Operand Examples- Opcode Operand Binary Code Hex Code LXI H, 2050H 21H 50H 20H LDA 3070H 3AH 70H 30H

77 Writing a Assembly Language Program

78 Writing a Assembly Language Program
Steps to write a program Analyze the problem Develop program Logic Write an Algorithm Make a Flowchart Write program Instructions using Assembly language of 8085

79 Analyze the problem Program Logic
Program 8085 in Assembly language to add two 8-bit numbers and store 8-bit result in register C. Analyze the problem Addition of two 8-bit numbers to be done Program Logic Add two numbers Store result in register C Example (99H) A (39H) D (D2H) C

80 Translation to 8085 operations
3. Algorithm Translation to 8085 operations Get two numbers Add them Store result Stop Load 1st no. in register D Load 2nd no. in register E Copy register D to A Add register E to A Copy A to register C Stop processing

81 4. Make a Flowchart Load 1st no. in register D
Start Load 1st no. in register D Load 2nd no. in register E Load Registers D, E Copy D to A Copy register D to A Add register E to A Add A and E Copy A to register C Copy A to C Stop processing Stop

82 5. Assembly Language Program
Get two numbers Add them Store result Stop Load 1st no. in register D Load 2nd no. in register E MVI D, 2H MVI E, 3H Copy register D to A Add register E to A MOV A, D ADD E Copy A to register C MOV C, A Stop processing HLT

83 Program 8085 in Assembly language to add two 8-bit numbers
Program 8085 in Assembly language to add two 8-bit numbers. Result can be more than 8-bits. Analyze the problem Result of addition of two 8-bit numbers can be 9-bit Example (99H) A (99H) B (132H) The 9th bit in the result is called CARRY bit.

84 How 8085 does it? Adds register A and B Stores 8-bit result in A
SETS carry flag (CY) to indicate carry bit 99H A + B 99H 1 32H 99H A CY

85 Storing result in Register memory
A CY 1 32H Register B Register C Step-1 Copy A to C Step-2 Clear register B Increment B by 1

86 2. Program Logic Add two numbers Copy 8-bit result in A to C
If CARRY is generated Handle it Result is in register pair BC

87 Translation to 8085 operations
3. Algorithm Translation to 8085 operations Load two numbers in registers D, E Add them Store 8 bit result in C Check CARRY flag If CARRY flag is SET Store CARRY in register B Stop Load registers D, E Copy register D to A Add register E to A Copy A to register C Copy A to register C Use Conditional Jump instructions Clear register B Increment B Stop processing

88 4. Make a Flowchart Start Stop False Load Registers D, E Clear B
If CARRY NOT SET Load Registers D, E False Clear B Copy D to A Increment B True Add A and E Copy A to C Stop

89 5. Assembly Language Program
Load registers D, E MVI D, 2H MVI E, 3H Copy register D to A Add register E to A MOV A, D ADD E Copy A to register C Copy A to register C MOV C, A Use Conditional Jump instructions JNC END Clear register B Increment B MVI B, 0H INR B Stop processing HLT END:

90 Exercises Write a program for two 8 bit numbers Addition Subtraction
Multiplication Division


Download ppt "R.RAJKUMAR DEPARTMENT OF CSE"

Similar presentations


Ads by Google