Вы находитесь на странице: 1из 141

LABORATORY MANUAL

PROGRAMME: B.Tech SEMESTER /YEAR: 3rd year 5th Semester SUBJECT CODE: BM0313 SUBJECT NAME: Microprocessor & Microcontroller Lab

Prepared By: Name: A Bhargavi Haripriya Designation: Assistant Professor (OG)

DEPARTMENT OF BIOMEDICAL ENGINEERING


SCHOOL OF BIOENGINEERING, FACULTY OF ENGINEERING & TECHNOLOGY

SRM UNIVERSITY
(UNDER SECTION 3 of UGC ACT 1956)

KATTANKULATHUR-603203 Tamil Nadu, India

Microprocessor&MicrocontrollerLabManual

Contents
8085 Pin Diagram 8085 Instruction Set 8085 Programs
1. 2. 3. 4. 5. 6. 7. 8. 9. To perform 8-bit addition using accumulator 8 bit addition using memory register 8 bit subtraction using accumulator 8-bit subtraction using memory register Addition of BCD number 16-bit addition using accumulator 16-bit addition using register pair 16-bit subtraction using accumulator BCD subtraction

10. 8-bit multiplication using memory register 11. Hexadecimal division 12. Adding an array of data 13. Smallest element in an array 14. Largest element in an array 15. Fibonacci series 16. Arrange elements in ascending order 17. Arrange elements in descending order

I/O Interfacing
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Interfacing Programs
18. Generation of Saw tooth waveform 19. Generation of Triangular waveform 20. Generation of Square waveform 21. Generation of Sine waveform8086 Pin Diagram

8086 Pin Diagram 8086 Instruction Set 8086 Programs


22. 16-bit addition using 8086 microprocessor 23. Move contents of array 24. Sum of n consecutive numbers 25. Conversion of BCD number to decimal 26. Separating Odd and Even numbers

8051 Pin Diagram

8051 Instruction Set


8051 Programs
27. Addition of 8-bit numbers using 8051 28. Subtraction of 8-bit numbers using 8051

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

8085 Pin Diagram


---------------------------------------------------------------| | | _________ _________ | | _| \__/ |_ | | --> X1 |_|1 40|_| Vcc (+5V) | | _| |_ | | --> X2 |_|2 39|_| HOLD <-| | _| |_ | | <-- RESET OUT |_|3 38|_| HLDA --> | | _| |_ | | <-- SOD |_|4 37|_| CLK (OUT) --> | | _| |_ ________ | | --> SID |_|5 36|_| RESET IN <-| | _| |_ | | --> TRAP |_|6 35|_| READY <-| | _| |_ _ | | --> RST 7.5 |_|7 34|_| IO/M --> | | _| |_ | | --> RST 6.5 |_|8 33|_| S1 --> | | _| |_ __ | | --> RST 5.5 |_|9 32|_| RD --> | | _| |_ __ | | --> INTR |_|10 8085A 31|_| WR --> | | ____ _| |_ | | <-- INTA |_|11 30|_| ALE --> | | _| |_ | | <--> AD0 |_|12 29|_| S0 --> | | _| |_ | | <--> AD1 |_|13 28|_| A15 --> | | _| |_ | | <--> AD2 |_|14 27|_| A14 --> | | _| |_ | | <--> AD3 |_|15 26|_| A13 --> | | _| |_ | | <--> AD4 |_|16 25|_| A12 --> | | _| |_ | | <--> AD5 |_|17 24|_| A11 --> | | _| |_ | | <--> AD6 |_|18 23|_| A10 --> | | _| |_ | | <--> AD7 |_|19 22|_| A9 --> | | _| |_ | | (Gnd) Vss |_|20 21|_| A8 --> | | |______________________| | | | | | | | | Copyright (C) J.P.Bowen 1985|

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

8085 Instruction Set


Instructions can be categorized according to their method of addressing the hardware registers and/or memory. Implied Addressing: The addressing mode of certain instructions is implied by the instructions function. For example, the STC (set carry flag) instruction deals only with the carry flag, the DAA (decimal adjust accumulator) instruction deals with the accumulator. Register Addressing: Quite a large set of instructions call for register addressing. With these instructions, you must specify one of the registers A through E, H or L as well as the operation code. With these instructions, the accumulator is implied as a second operand. For example, the instruction CMP E may be interpreted as 'compare the contents of the E register with the contents of the accumulator. Immediate Addressing: Instructions that use immediate addressing have data assembled as a part of the instruction itself. For example, the instruction CPI 'C' may be interpreted as compare the contents of the accumulator with the letter C. When assembled, this instruction has the hexadecimal value FE43. Hexadecimal 43 is the internal representation for the letter C. When this instruction is executed, the processor fetches the first instruction byte and determines that it must fetch one more byte. The processor fetches the next byte into one of its internal registers and then performs the compare operation.

Direct Addressing: Jump instructions include a 16-bit address as part of the instruction. For example, the instruction JMP 1000H causes a jump to the hexadecimal address 1000 by replacing the current contents of the program counter with the new value 1000H. Instructions that include a direct address require three bytes of storage: one for the instruction code, and two for the 16-bit address

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Register Indirect Addressing: Register indirect instructions reference memory via a register pair. Thus, the instruction MOV M,C moves the contents of the C register into the memory address stored in the H and L register pair. The instruction LDAX B loads the accumulator with the byte of data specified by the address in the B and C register pair. Combined Addressing Modes: Some instructions use a combination of addressing modes. A CALL instruction, for example, combines direct addressing and register indirect addressing. The direct address in a CALL instruction specifies the address of the desired subroutine; the register indirect address is the stack pointer. The CALL instruction pushes the current contents of the program counter into the memory location specified by the stack pointer. Timing Effects of Addressing Modes: Addressing modes affect both the amount of time required for executing an instruction and the amount of memory required for its storage. For example, instructions that use implied or register addressing, execute very quickly since they deal directly with the processors hardware or with data already present in hardware registers. Most important, however is that the entire instruction can be fetched with a single memory access. The number of memory accesses required is the single greatest factor in determining execution timing. More memory accesses therefore require more execution time. A CALL instruction for example, requires five memory accesses: three to access the entire instruction and two more to push the contents of the program counter onto the stack. The processor can access memory once during each processor cycle. Each cycle comprises a variable number of states. (See below and the appendix of USING THE SDK-85 MICROPROCESSOR TRAINER). The length of a state depends on the clock frequency specified for your system, and may range from 480 nanoseconds to 2 microseconds. Thus, the timing for a four state instruction may range from 1.920 microseconds through 8 microseconds. (The 8085 have a maximum clock frequency of 5 MHz and therefore a minimum state length of 200 nanoseconds.)
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Instruction Naming Conventions: The mnemonics assigned to the instructions are designed to indicate the function of the instruction. The instructions fall into the following functional categories: Data Transfer Group: The data transfer instructions move data between registers or between memory and registers. MOV MVI LDA STA LHLD SHLD Move Move Immediate Load Accumulator Directly from Memory Store Accumulator Directly in Memory Load H & L Registers Directly from Memory Store H & L Registers Directly in Memory

An 'X' in the name of a data transfer instruction implies that it deals with a register pair (16-bits); LXI LDAX STAX XCHG XTHL Load Register Pair with Immediate data Load Accumulator from Address in Register Pair Store Accumulator in Address in Register Pair Exchange H & L with D & E Exchange Top of Stack with H & L

Arithmetic Group: The arithmetic instructions add, subtract, increment, or decrement data in registers or memory. ADD ADI ADC ACI SUB SUI SBB SBI Add to Accumulator Add Immediate Data to Accumulator Add to Accumulator Using Carry Flag Add Immediate data to Accumulator Using Carry Subtract from Accumulator Subtract Immediate Data from Accumulator Subtract from Accumulator Using Borrow (Carry) Flag Subtract Immediate from Accumulator Using Borrow (Carry) Flag

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INR DCR INX DCX DAD

Increment Specified Byte by One Decrement Specified Byte by One Increment Register Pair by One Decrement Register Pair by One Double Register Add; Add Content of Register Pair to H & L Register Pair

Logical Group: This group performs logical (Boolean) operations on data in registers and memory and on condition flags. The logical AND, OR, and Exclusive OR instructions enable you to set specific bits in the accumulator ON or OFF. ANA ANI ORA OR XRA XRI Logical AND with Accumulator Logical AND with Accumulator Using Immediate Data Logical OR with Accumulator Logical OR with Accumulator Using Immediate Data Exclusive Logical OR with Accumulator Exclusive OR Using Immediate Data

The Compare instructions compare the content of an 8-bit value with the contents of the accumulator; CMP CPI Compare Compare Using Immediate Data

The rotate instructions shift the contents of the accumulator one bit position to the left or right: RLC RRC RAL RAR Rotate Accumulator Left Rotate Accumulator Right Rotate Left Through Carry Rotate Right Through Carry

Complement and carry flag instructions:


DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CMA CMC STC

Complement Accumulator Complement Carry Flag Set Carry Flag

Branch Group: The branching instructions alter normal sequential program flow, either unconditionally or conditionally. The unconditional branching instructions are as follows: JMP CALL RET Jump Call Return

Conditional branching instructions examine the status of one of four condition flags to determine whether the specified branch is to be executed. The conditions that may be specified are as follows: NZ Z NC C PO PE P M Not Zero (Z = Zero (Z = 1) No Carry (C = Carry (C = 1) Parity Odd (P Parity Even (P Plus (S = 0) Minus (S = 1) 0) 0) = 0) = 1)

Thus, the conditional branching instructions are specified as follows: Jumps JC INC JZ JNZ JP JM JPE JP0 Calls CC CNC CZ CNZ CP CM CPE CPO Returns RC RNC RZ RNZ RP RM RPE RPO

(Carry) (No Carry) (Zero) (Not Zero) (Plus) (Minus) (Parity Even) (Parity Odd)

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Two other instructions can affect a branch by replacing the contents or the program counter: PCHL RST Move H & L to Program Counter Special Restart Instruction Used with Interrupts

Stack I/O, and Machine Control Instructions: The following instructions affect the Stack and/or Stack Pointer: PUSH POP XTHL SPHL Push Two bytes of Data onto the Stack Pop Two Bytes of Data off the Stack Exchange Top of Stack with H & L Move content of H & L to Stack Pointer

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

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

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

---------------------------------------------------------------|Mnemonic |Op|SZAPC|~s|Description |Notes | |---------+--+-----+--+--------------------------+-------------| |ACI n |CE|*****| 7|Add with Carry Immediate |A=A+n+CY | |ADC r |8F|*****| 4|Add with Carry |A=A+r+CY(21X)| |ADC M |8E|*****| 7|Add with Carry to Memory |A=A+[HL]+CY | |ADD r |87|*****| 4|Add |A=A+r (20X)| |ADD M |86|*****| 7|Add to Memory |A=A+[HL] | |ADI n |C6|*****| 7|Add Immediate |A=A+n | |ANA r |A7|****0| 4|AND Accumulator |A=A&r (24X)| |ANA M |A6|****0| 7|AND Accumulator and Memory|A=A&[HL] | |ANI n |E6|**0*0| 7|AND Immediate |A=A&n | |CALL a |CD|-----|18|Call unconditional |-[SP]=PC,PC=a| |CC a |DC|-----| 9|Call on Carry |If CY=1(18~s)| |CM a |FC|-----| 9|Call on Minus |If S=1 (18~s)| |CMA |2F|-----| 4|Complement Accumulator |A=~A | |CMC |3F|----*| 4|Complement Carry |CY=~CY | |CMP r |BF|*****| 4|Compare |A-r (27X)| |CMP M |BF|*****| 7|Compare with Memory |A-[HL] | |CNC a |D4|-----| 9|Call on No Carry |If CY=0(18~s)| |CNZ a |C4|-----| 9|Call on No Zero |If Z=0 (18~s)| |CP a |F4|-----| 9|Call on Plus |If S=0 (18~s)| |CPE a |EC|-----| 9|Call on Parity Even |If P=1 (18~s)| |CPI n |FE|*****| 7|Compare Immediate |A-n | |CPO a |E4|-----| 9|Call on Parity Odd |If P=0 (18~s)| |CZ a |CC|-----| 9|Call on Zero |If Z=1 (18~s)| |DAA |27|*****| 4|Decimal Adjust Accumulator|A=BCD format | |DAD B |09|----*|10|Double Add BC to HL |HL=HL+BC | |DAD D |19|----*|10|Double Add DE to HL |HL=HL+DE | |DAD H |29|----*|10|Double Add HL to HL |HL=HL+HL | |DAD SP |39|----*|10|Double Add SP to HL |HL=HL+SP | |DCR r |3D|****-| 4|Decrement |r=r-1 (0X5)| |DCR M |35|****-|10|Decrement Memory |[HL]=[HL]-1 | |DCX B |0B|-----| 6|Decrement BC |BC=BC-1 | |DCX D |1B|-----| 6|Decrement DE |DE=DE-1 | |DCX H |2B|-----| 6|Decrement HL |HL=HL-1 | |DCX SP |3B|-----| 6|Decrement Stack Pointer |SP=SP-1 | |DI |F3|-----| 4|Disable Interrupts | | |EI |FB|-----| 4|Enable Interrupts | | |HLT |76|-----| 5|Halt | | |IN p |DB|-----|10|Input |A=[p] | |INR r |3C|****-| 4|Increment |r=r+1 (0X4)| |INR M |3C|****-|10|Increment Memory |[HL]=[HL]+1 | |INX B |03|-----| 6|Increment BC |BC=BC+1 | |INX D |13|-----| 6|Increment DE |DE=DE+1 | |INX H |23|-----| 6|Increment HL |HL=HL+1 | |INX SP |33|-----| 6|Increment Stack Pointer |SP=SP+1 | |JMP a |C3|-----| 7|Jump unconditional |PC=a | |JC a |DA|-----| 7|Jump on Carry |If CY=1(10~s)| |JM a |FA|-----| 7|Jump on Minus |If S=1 (10~s)| |JNC a |D2|-----| 7|Jump on No Carry |If CY=0(10~s)| |JNZ a |C2|-----| 7|Jump on No Zero |If Z=0 (10~s)| |JP a |F2|-----| 7|Jump on Plus |If S=0 (10~s)|

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

|JPE a |EA|-----| 7|Jump on Parity Even |If P=1 (10~s)| |JPO a |E2|-----| 7|Jump on Parity Odd |If P=0 (10~s)| |JZ a |CA|-----| 7|Jump on Zero |If Z=1 (10~s)| |LDA a |3A|-----|13|Load Accumulator direct |A=[a] | |LDAX B |0A|-----| 7|Load Accumulator indirect |A=[BC] | |LDAX D |1A|-----| 7|Load Accumulator indirect |A=[DE] | |LHLD a |2A|-----|16|Load HL Direct |HL=[a] | |LXI B,nn |01|-----|10|Load Immediate BC |BC=nn | |LXI D,nn |11|-----|10|Load Immediate DE |DE=nn | |LXI H,nn |21|-----|10|Load Immediate HL |HL=nn | |LXI SP,nn|31|-----|10|Load Immediate Stack Ptr |SP=nn | |MOV r1,r2|7F|-----| 4|Move register to register |r1=r2 (1XX)| |MOV M,r |77|-----| 7|Move register to Memory |[HL]=r (16X)| |MOV r,M |7E|-----| 7|Move Memory to register |r=[HL] (1X6)| |MVI r,n |3E|-----| 7|Move Immediate |r=n (0X6)| |MVI M,n |36|-----|10|Move Immediate to Memory |[HL]=n | |NOP |00|-----| 4|No Operation | | |ORA r |B7|**0*0| 4|Inclusive OR Accumulator |A=Avr (26X)| |ORA M |B6|**0*0| 7|Inclusive OR Accumulator |A=Av[HL] | |ORI n |F6|**0*0| 7|Inclusive OR Immediate |A=Avn | |OUT p |D3|-----|10|Output |[p]=A | |PCHL |E9|-----| 6|Jump HL indirect |PC=[HL] | |POP B |C1|-----|10|Pop BC |BC=[SP]+ | |POP D |D1|-----|10|Pop DE |DE=[SP]+ | |POP H |E1|-----|10|Pop HL |HL=[SP]+ | |POP PSW |F1|-----|10|Pop Processor Status Word |{PSW,A}=[SP]+| ------------------------------------------------------------------------------------------------------------------------------|Mnemonic |Op|SZAPC|~s|Description |Notes | |---------+--+-----+--+--------------------------+-------------| |PUSH B |C5|-----|12|Push BC |-[SP]=BC | |PUSH D |D5|-----|12|Push DE |-[SP]=DE | |PUSH H |E5|-----|12|Push HL |-[SP]=HL | |PUSH PSW |F5|-----|12|Push Processor Status Word|-[SP]={PSW,A}| |RAL |17|----*| 4|Rotate Accumulator Left |A={CY,A}<| |RAR |1F|----*| 4|Rotate Accumulator Righ |A=->{CY,A} | |RET |C9|-----|10|Return |PC=[SP]+ | |RC |D8|-----| 6|Return on Carry |If CY=1(12~s)| |RIM |20|-----| 4|Read Interrupt Mask |A=mask | |RM |F8|-----| 6|Return on Minus |If S=1 (12~s)| |RNC |D0|-----| 6|Return on No Carry |If CY=0(12~s)| |RNZ |C0|-----| 6|Return on No Zero |If Z=0 (12~s)| |RP |F0|-----| 6|Return on Plus |If S=0 (12~s)| |RPE |E8|-----| 6|Return on Parity Even |If P=1 (12~s)| |RPO |E0|-----| 6|Return on Parity Odd |If P=0 (12~s)| |RZ |C8|-----| 6|Return on Zero |If Z=1 (12~s)| |RLC |07|----*| 4|Rotate Left Circular |A=A<| |RRC |0F|----*| 4|Rotate Right Circular |A=->A | |RST z |C7|-----|12|Restart (3X7)|-[SP]=PC,PC=z| |SBB r |9F|*****| 4|Subtract with Borrow |A=A-r-CY | |SBB M |9E|*****| 7|Subtract with Borrow |A=A-[HL]-CY | |SBI n |DE|*****| 7|Subtract with Borrow Immed|A=A-n-CY | |SHLD a |22|-----|16|Store HL Direct |[a]=HL |

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

|SIM |30|-----| 4|Set Interrupt Mask |mask=A | |SPHL |F9|-----| 6|Move HL to SP |SP=HL | |STA a |32|-----|13|Store Accumulator |[a]=A | |STAX B |02|-----| 7|Store Accumulator indirect|[BC]=A | |STAX D |12|-----| 7|Store Accumulator indirect|[DE]=A | |STC |37|----1| 4|Set Carry |CY=1 | |SUB r |97|*****| 4|Subtract |A=A-r (22X)| |SUB M |96|*****| 7|Subtract Memory |A=A-[HL] | |SUI n |D6|*****| 7|Subtract Immediate |A=A-n | |XCHG |EB|-----| 4|Exchange HL with DE |HL<->DE | |XRA r |AF|**0*0| 4|Exclusive OR Accumulator |A=Axr (25X)| |XRA M |AE|**0*0| 7|Exclusive OR Accumulator |A=Ax[HL] | |XRI n |EE|**0*0| 7|Exclusive OR Immediate |A=Axn | |XTHL |E3|-----|16|Exchange stack Top with HL|[SP]<->HL | |------------+-----+--+----------------------------------------| | PSW |-*01 | |Flag unaffected/affected/reset/set | | S |S | |Sign (Bit 7) | | Z | Z | |Zero (Bit 6) | | AC | A | |Auxilary Carry (Bit 4) | | P | P | |Parity (Bit 2) | | CY | C| |Carry (Bit 0) | |---------------------+----------------------------------------| | a p |Direct addressing | | M z |Register indirect addressing | | n nn |Immediate addressing | | r |Register addressing | |---------------------+----------------------------------------| |DB n(,n) |Define Byte(s) | |DB 'string' |Define Byte ASCII character string | |DS nn |Define Storage Block | |DW nn(,nn) |Define Word(s) | |---------------------+----------------------------------------| | A B C D E H L |Registers (8-bit) | | BC DE HL |Register pairs (16-bit) | | PC |Program Counter register (16-bit) | | PSW |Processor Status Word (8-bit) | | SP |Stack Pointer register (16-bit) | |---------------------+----------------------------------------| | a nn |16-bit address/data (0 to 65535) | | n p |8-bit data/port (0 to 255) | | r |Register (X=B,C,D,E,H,L,M,A) | | z |Vector (X=0H,8H,10H,18H,20H,28H,30H,38H)| |---------------------+----------------------------------------| | + |Arithmetic addition/subtraction | | & ~ |Logical AND/NOT | | v x |Logical inclusive/exclusive OR | | <- -> |Rotate left/right | | <-> |Exchange | | [ ] |Indirect addressing | | [ ]+ -[ ] |Indirect address auto-inc/decrement | | { } |Combination operands | | ( X ) |Octal op code where X is a 3-bit code | | If ( ~s) |Number of cycles if condition true |

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Experiment No:

8-BIT ADDITION USING ACCUMULATOR


AIM: To perform 8-bit Addition of two hexadecimal numbers using accumulator in 8085 PROGRAM: Address Program
LDA 9000 MOV B,A LDA 9001 ADD B STA 9002 JC Loc1 MVI A,00 STA 9003 HLT Loc 1: MVI A,01 STA 9003 HLT

Explanation
Load contents of address 9000 (Input 1) into the accumulator Shift contents of accumulator to register B Load contents of address 9001(Input 2) into the accumulator Add data in B to accumulator & store in the accumulator Store the (Result) contents of accumulator to address 9002 Jump to Loc1 if carry is 1 Store value 00 in accumulator Store the (Carry) contents of accumulator to address 9003 End of Program Store value 01 in accumulator Store the (Carry) contents of accumulator to address 9003 End of Program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART
START

GETDATA1INTO ACCUMULATOR

MOVECONTENTS OFATOB

GETDATA2INTO ACCUMULATOR

ADDBTOA

STORERESULT

IF CARRY=1

no

yes A=01 A=00

STORECARRY DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

STOP

Microprocessor&MicrocontrollerLabManual

MNEMONICS:
ADDRESS 8000 8003 8004 8007 8008 800B 800E 8010 8013 8014 8016 8019 OPCODE 3A 47 3A 80 32 DA 3E 32 76 3E 32 76 01 03 90 Loc 1 02 90 14 80 00 03 90 01 90 OPERAND 00 90 LOCATION COMMAND LDA 9000 MOV B,A LDA 9001 ADD B STA 9002 JC Loc1 MVI A,00 STA 9003 HLT MVI A,01 STA 9003 HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: Location 9000 9001 9002 9003 INPUT 1 INPUT 2 RESULT CARRY Values 42 35 77 00

Location 9000 9001 9002 9003 INPUT 1 INPUT 2 RESULT CARRY

Values A8 F6 9E 01

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION:
i) Data 1 Data 2 Sum Carry ii) Data 1 Data 2 Sum Carry : 42 - 0100 0010 : 35 - 0011 0101 : 77 0111 0111 : 00 : A8 - 1010 1000 : 35 - 1111 0110 : 9E - 1001 1110 : 01

RESULT: The program for adding two 8-bit hexadecimal numbers using accumulator & registers has been performed with different sets of data.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

8-BIT ADDITION WITH MEMORY POINTER


AIM: To perform 8-bit Addition of two hexadecimal numbers using memory pointer in 8085 PROGRAM: Address Program
LXI H, 8201 MVI C, 00 MOV A, M INX H ADD M

Explanation
Setting pointer for getting data Clearing register C for carry Getting Data 1 into the accumulator from memory Increment pointer to the next memory location Add second data to Accumulator and store it in accumulator If carry is '0' , go to location 'Ahead' If carry is '1' , Increment register C to 1 Increment pointer to the next memory location Store Sum in memory Increment pointer to the next memory location Store Carry in memory End of Program

JNC Ahead INR C Ahead INX H MOV M,A INX H MOV M,C HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART
START SETCARRYCTO00 SETPOINTERTOGETDATA FROM MEMORY

GETDATA1INTO ACCUMULATOR

INCREMENT POINTER

ADDDATA2IN MEMORY TO A

IF CARRY==1 YES NO C=01

STORESUM

STORECARRY

STOP DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS 8000 8003 8005 8006 8007 8008 800B 800C 800D 800E 800F 8010 OPCODE OPERAND 21 0E 7E 23 86 D2 0C 23 77 23 71 76 Ahead 0C 80 01 82 00 LOCATION COMMAND LXI H, 8201 MVI C, 00 MOV A, M INX H ADD M JNC Ahead INR C INX H MOV M,A INX H MOV M,C HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: Location 8200 8201 8202 8203 INPUT 1 INPUT 2 RESULT CARRY Values 54 A1 F5 00

Location 8200 8201 8202 8203 INPUT 1 INPUT 2 RESULT CARRY

Values B3 69 1C 01

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION:
i) Data 1 Data 2 Sum Carry ii) Data 1 Data 2 Sum Carry : 54 - 0101 0100 : A1 - 1010 0001 : F5 - 1111 0101 : 00 : B3 - 1011 0011 : 69 - 0110 1001 : 1C - 0001 1100 : 01

RESULT: The program for adding two 8-bit hexadecimal numbers using memory pointer has been performed with different sets of data.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

8-BIT SUBTRACTION USING ACCUMULATOR


AIM: To perform 8-bit Subtraction of two hexadecimal numbers using accumulator in 8085 PROGRAM: LDA 8201 MOV B, A LDA 8200 MVI C, 00 SUB B JNC Ahead INR C CMA ADD 01 Ahead STA 8202 MOV A,C STA 8203 HLT Load the first data in the accumulator Move contents of Accumulator to B Load the second data in the accumulator Set C = '0' for carry Subtract B from Accumulator & Store in Accumulator If carry is not set go Ahead if carry = '1' , increment register C to 01 Get 2's complement for Accumulator Add one to accumulator Store result in given location Move carry to Accumulator Store Carry in given location End of Program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START

GETDATA1INTO ACCUMULATOR

MOVECONTENTS OF A TO B

GETDATA2INTO ACCUMULATOR

SETREGISTERC FOR CARRY SUBTRACTDATA2 FROM DATA 1

IF CARRY=0

NO

YES

SETCARRYAS 01 GET2S COMPLEMENTOF RESULT

STORERESULTIN MEMORY STORECARRYIN MEMORY

STOP DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS 8000 8003 8004 8007 8009 800A 800D 800E 800F 8011 8014 8015 8018 OPCODE OPERAND LOCATION COMMAND 3A 47 3A 0E 90 D2 0C 2F C6 32 79 32 76 03 82 1 02 82 Ahead 11 80 00 82 0 01 82 LDA 8201 MOV B, A LDA 8200 MVI C, 00 SUB B JNC Ahead INR C CMA ADD 01 STA 8202 MOV A,C STA 8203 HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: i) 8200 8201 8202 ii) 8203 INPUT 1 INPUT 2 55 32

DIFFERENCE 23 BORROW 0

8200 8201 8202 8203

INPUT 1 INPUT 2

11 AA

DIFFERENCE 99 BORROW 1

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: i) Data 1 : Data 2 : Difference: Borrow: ii) Data 1 : Data 2 : Difference: Borrow: 55 32 23 00 11 AA 99 01 -0101 0101 -0011 0010 -0010 0011 -0001 0001 -1010 1010 -1001 1001

RESULT: The program for subtracting two 8-bit hexadecimal numbers using 8085 was executed.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

8-BIT SUBTRACTION WITH MEMORY POINTER


AIM: To perform 8-bit Subtraction of two hexadecimal numbers using memory pointer in 8085

PROGRAM: Address Program LXI H, 8201 MVI C, 00 MOV A, M INX H SUB M JNC Ahead INR C CMA ADI 01 Ahead INX H Explanation Setting pointer for data Clear register C to account for Carry Get Data 1 into Accumulator Increment the memory pointer Subtract Data 2 from Data 1 and store in Accumulator If carry==0 , go Ahead If carry==1, Increment register C by 1 Get 2's complement for Accumulator data Add 1 to accumulator content Increment the memory pointer

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MOV M,A INX H MOV M,C HLT

Store Accumulator content (Result) to memory Increment the memory pointer Store Register C (Carry) content to memory End of program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START SETCARRYCTO00 SETPOINTERTOGETDATA FROM MEMORY

GETDATA1INTO ACCUMULATOR

INCREMENT POINTER

SUBTRACTDATA2 FROM DATA 1

IF CARRY=0

NO

SETCARRYAS 01 GET2S COMPLEMENTOF RESULT SETCARRYAS 01

YES

STORERESULTIN MEMORY STORECARRYIN MEMORY STOP DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS OPCODE OPERAND LOCATION COMMAND 8000 8003 8005 8006 8007 8008 800B 800C 800D 800F 8010 8011 8012 8013 21 0E 7E 23 96 D2 0C 2F C6 23 77 23 71 76 01 Ahead 0F 80 01 82 00 LXI H, 8201 MVI C, 00 MOV A, M INX H SUB M JNC Ahead INR C CMA ADI 01 INX H MOV M,A INX H MOV M,C HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: i) 8200 8201 8202 8203 INPUT 1 INPUT 2 11 11

DIFFERENCE 00 BORROW 00

ii) 8200 8201 8202 8203 INPUT 1 INPUT 2 33 55

DIFFERENCE 22 BORROW 01

CALCULATION: i) Data 1 Data 2 : : 11 11 00 00 -0001 0001 -0001 0001 -0010 0011

Difference: Borrow:

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

ii)

Data 1 Data 2

: :

33 55

-0011 0011 -0101 0101

2 complement of 55: 1010 1010 + 1 : 1010 1011 + Data 1 (0011 0011): 1101 1110 2s complement of the above number : 0010 0001 + 01 : Difference: Borrow: 22 01 -0010 0010 0010 0010 = 22

RESULT: The program for subtracting two 8-bit hexadecimal numbers using memory pointer in 8085 was executed.
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

8-BIT BCD ADDITION


AIM: To perform addition of two 8-bit BCD numbers using 8085 microprocessor. PROGRAM: Address Program LDA 8200 MOV B,A LDA 8201 MVI C, 00 ADD B DAA JNC Ahead INR C Ahead STA 8203 MOV A,C Explanation Load Data 1 into accumulator Move Accumulator contents to Register B Load Data 2 into accumulator Clear register C to account for Carry Add Data 2 to Data 1 and store in Accumulator Convert the accumulator value to BCD value If carry==0 , go Ahead If carry==1, Increment register C by 1 Store Accumulator content (Result) to memory Move contents of Register C to Accumulator

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

STA 8204 HLT

Store Register C (Carry) content to memory End of program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
START

FLOWCHART
GETDATA1INTO ACCUMULATOR

MOVECONTENTS OF A TO B

GETDATA2INTO ACCUMULATOR

SETREGISTERC FOR CARRY ADDDATA1TODATA2,AND STORE IN ACCUMULATOR

CONVERT ACCUMULATOR CONTENT TO BCD YES

IF CARRY=0 NO STORERESULTIN MEMORY STORECARRYIN MEMORY STOP

SETCARRYAS 01

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS 8000 8003 8004 8007 8009 800A 800B 800E 800F 8012 8013 8016 OPCODE OPERAND LOCATION COMMAND 3A 47 3A 0E 86 27 D2 0C 32 79 32 76 03 82 02 82 Ahead 0F 80 01 82 0 00 82 LDA 8200 MOV B,A LDA 8201 MVI C, 00 ADD B DAA JNC Ahead INR C STA 8203 MOV A,C STA 8204 HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: i) 8200 8201 8202 ii) 8203 INPUT 1 INPUT 2 SUM CARRY 13 4A 63 0

8200 8201 8202 8203

INPUT 1 INPUT 2 SUM CARRY

13 16 29 0

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: 13 0001 0011 4A 0100 1010 Gives 0101 1101 After adding 06 0000 0110 Result: 63 0110 0011 Carry: 00 Note: If hexadecimal number is in units place 06 is added, if hexadecimal is in tens place 60 is added to sum by the DAA command. i) Data 1: Data 2:

RESULT: Program to add two BCD 8-bit numbers was performed using DAA command with 8085 microprocessor
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Date:

Experiment No:

16 BIT ADDITION USING ACCUMULATOR


AIM: To add two 16 bit numbers ( 4 digits) using the accumulator with 8085 microprocessor. PROGRAM: Address Program LDA 8201 MOV B,A LDA 8203 ADD B STA 8205 MVI C, 00 LDA 8202 MOV B,A LDA 8204 ADC B STA 8206 Explanation Get Data 1 (lower byte) into accumulator Move Data to Register B from Accumulator Get Data 2 (lower byte) into accumulator Add Lower Bytes of Data 1 & Data 2 Store content of Accumulator , Lower Byte Result in Memory Set C = '0' for carry Get Data 1 (higher byte) into accumulator Move Data to Register B from Accumulator Get Data 2 (higher byte) into accumulator Add Higher Bytes of Data 1 & Data 2 with carry of Lower Bytes Store content of Accumulator , Lower Byte

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Result in Memory JNC Ahead INR C Ahead MOV A,C STA 8207 HLT If carry is not set go Ahead if carry = '1' , increment register C to 01 Move contents of Register C to Accumulator Store Register C (Carry) content to memory End of program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
START

FLOWCHART

GETLOWERBYTEOFDATA1INTOACCUMULATOR MOVECONTENTSOFATOB

GETLOWERBYTEOFDATA2INTOACCUMULATOR

ADDLOWERBYTESOFDATA1TODATA2,AND STOREINACCUMULATOR STORERESULTINMEMORY SET REGISTER C FOR CARRY GETHIGHERBYTEOFDATA1 INTOACCUMULATOR MOVECONTENTSOFATOB GETHIGHERBYTEOFDATA2INTOACCUMULATOR

ADDHIGHERBYTESOFDATA1TODATA2WITHCARRYOF LOWERBYTEADDITIONANDSTOREINACCUMULATOR STORERESULTINMEMORY NO SETCARRYAS 01

IFCARRY=0 YES MOVECONTENTSOFATOB STORECARRYINMEMORY STOP

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS 8000 8003 8004 8007 8008 800B 800D 8010 8011 8014 8015 8018 801B 801C 801D 8020 OPCODE OPERAND LOCATION COMMAND 3A 47 3A 80 32 0E 3A 47 3A 88 32 D2 0C 79 32 76 07 82 Ahead 06 82 1C 80 04 82 05 82 0 02 82 03 82 01 82 LDA 8201 MOV B,A LDA 8203 ADD B STA 8205 MVI C, 00 LDA 8202 MOV B,A LDA 8204 ADC B STA 8206 JNC Ahead INR C MOV A,C STA 8207 HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: i) INPUT 1 4283 INPUT 2 2931 SUM 6BB4 CARRY 00 8201 83 Lower Byte of Data 1 8202 8203 8204 8205 8206 8207 ii)
INPUT 1 INPUT 2 SUM CARRY 9312 8856 1B68 1

42 31 29 B4 6B 0

Higher Byte of Data 1 Lower Byte of Data 2 Higher Byte of Data 2 Lower Byte of Sum Higher Byte of Sum Carry

Lower Byte of Data 1 Higher Byte of Data 1 Lower Byte of Data 2 Higher Byte of Data 2

8201 8202 8203 8204

12 93 56 88

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Lower Byte of Sum Higher Byte of Sum Carry

8205 8206 8207

68 1B 1

CALCULATION: Lower Byte of Data 1: Lower Byte of Data 2: Lower Byte of Sum : Higher Byte of Data 1: Higher Byte of Data 2: Higher Byte of Sum : Carry: 00 83 31 B4 42 29 6B 1000 0011 0011 0001 1011 0100 0100 0010 0010 1001 0110 1011

RESULT:Program to add two 16 bit numbers (4 digits) using the accumulator with 8085 microprocessor was executed

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

16 BIT ADDITION USING REGISTER PAIR


AIM: To add two 16 bit numbers (4 digits) using the register pairs in 8085 microprocessor.

PROGRAM: Address Program LHLD 8201 XCHG LHLD 8203 MVI A, 00 DAD D JNC Ahead INR A Ahead SHLD 8205 Explanation Load HL register pair with data in 8201 & 8202 Exchange contents of HL with DE Register Pair Load HL register pair with data in 8203 & 8204 Set Accumulator , A = '0' for carry Double Addition If carry is not set go Ahead if carry = '1' , increment Accumulator to 01 Store contents of HL Register pair in Memory

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

STA 8207 HLT

Store Register C (Carry) content to memory End of program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START

GETDATA1INTOHLREGISTERPAIR

EXCHANGE:MOVEDATA1TODE REGISTERPAIR

GETDATA2INTOHLREGISTERPAIR

SETACCUMULATORFORCARRY

DOUBLEADDITIONOFDATA1WITHDATA2

IFCARRY==0

NO INCEMENTCARRY

YES

STORECONTENTOFHLREGISTERPAIR(RESULT)IN MEMORY

STOREACCUMULATORCONTENT(CARRY) TOMEMORY DepartmentofBiomedicalEngineering ,SRMUniversity, Kattankulathur STOP

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS 8000 8003 8004 8007 8009 800A 800D 800E 8011 8014 OPCODE OPERAND LOCATION COMMAND 2A E3 2A 3E 19 D2 3C 22 32 76 05 82 07 82 Ahead 0E 80 03 82 0 01 82 LHLD 8201 XCHG LHLD 8203 MVI A, 00 DAD D JNC Ahead INR A SHLD 8205 STA 8207 HLT

INPUT & OUTPUT:


INPUT 1 INPUT 2 SUM CARRY 9437 7259 0690 01 8201 37

Lower Byte of Data 1

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Higher Byte of Data 1 Lower Byte of Data 2 Higher Byte of Data 2 Lower Byte of Sum Higher Byte of Sum Carry

8202 8203 8204 8205 8206 8207

94 59 72 90 6 1

RESULT:Program to add two 16 bit numbers (4 digits) using the Register pairs in 8085 microprocessor was executed

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

16 BIT HEXADECIMAL SUBTRACTION


AIM: To subtract two 16-bit hexadecimal numbers using Accumulator with 8085 Microprocessor

PROGRAM: Program LDA 8202 MOV B,A LDA 8200 SUB B STA 8204 LDA 8203 MOV B,A LDA 8201 Explanation Load contents of Accumulator with Lower byte of Data 2 Move contents of Accumulator to Register B Load contents of Accumulator with Lower byte of Data 1 Subtract contents of B from Accumulator Store Accumulator content (Lower byte of difference) to Memory Load contents of Accumulator with Higher byte of Data 2 Move contents of Accumulator to Register B Load contents of Accumulator with Higher byte of Data 1

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

SBB B STA 8205 HLT

Subtract contents of B from Accumulator along with Borrow, if any Store Accumulator content (Higher byte of difference) to Memory End of Program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START

GETLOWERBYTEOFDATA2INTOACCUMULATOR

MOVECONTENTSOFATOB

GETLOWERBYTEOFDATA1INTOACCUMULATOR

SUBTRACTLOWERBYTESOFDATA1TODATA2, ANDSTOREDIFFERENCEINACCUMULATOR

STOREDIFFERENCEINMEMORY

GETHIGHERBYTEOFDATA2INTOACCUMULATOR

MOVECONTENTSOFATOB

GETHIGHERBYTEOFDATA1INTOACCUMULATOR

SUBTRACTHIGHERBYTEOFDATA1ANDDATA2WITH BORROWOFLOWERBYTEANDSTOREINACCUMULATOR

STORERESULTINMEMORY

STOP DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS 8000 8003 8004 8007 8008 800B 800E 800F 8012 8013 8016 OPCODE 3A 47 3A 90 32 3A 47 3A 98 32 76 05 82 01 82 04 82 03 82 00 82 OPERAND 02 82 COMMAND LDA 8202 MOV B,A LDA 8200 SUB B STA 8204 LDA 8203 MOV B,A LDA 8201 SBB B STA 8205 HLT

INPUT & OUTPUT: i) INPUT 1 4398 INPUT 2 2931 Difference 5522 BORROW 00
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

8200 8201 8202 8203 8204 8205 8206 ii)

98 43 21 46 22 55 0

Lower Byte of Data 1 Higher Byte of Data 1 Lower Byte of Data 2 Higher Byte of Data 2 Lower Byte of Difference Higher Byte of Sum BORROW

INPUT 1 INPUT 2 SUM BORROW

4531 9576 AFB7 00

Lower Byte of Data 1 Higher Byte of Data 1 Lower Byte of Data 2 Higher Byte of Data 2 Lower Byte of Difference Higher Byte of Difference BORROW

8200 8201 8202 8203 8204

31 45 76 95 B8

8205 8206

AF 01

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: Lower Byte of Data 1 Lower Byte of Data 2 Lower Byte of Difference Higher Byte of Data 1 Higher Byte of Data 2 Higher Byte of Difference Borrow : 00 : : : : : : 43 21 22 98 46 55 0100 0011 0010 0001 0010 0010 1001 1000 0100 0110 0101 0101

RESULT:Program to subtract two 16 bit numbers (4 digits) using the accumulator with 8085 microprocessor was executed

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

8 BIT MULTIPLICATION
AIM: To multiply two 8-bit hexadecimal numbers using memory pointer with 8085 microprocessor

PROGRAM: Address Program LXI H, 8201 MVI C, 00 XRA A MOV B,M INX H MOV D,M Repeat ADD D JNC Ahead INR C Ahead DCR B JNZ Repeat Explanation Setting pointer for data Clear register C to account for Carry Set Accumulator to '0' to account for product Move Data 1 to Register B from Memory Increment the memory pointer Move Data 2 to Register D from Memory Add contents of Register D to Accumulator If carry==0 , go Ahead If carry==1, Increment register C by 1 Decrement Register B content by 1 If B is not Zero, got back to Repeat

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INX H MOV M,A INX H MOV M,C HTL

Increment the memory pointer Store Accumulator content (Product) to memory Increment the memory pointer Store Register C (Carry) content to memory End of program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START SETTINGMEMORYPOINTERFORDATA GATHERING AND STORAGE SET REGISTER C FOR CARRY CLEARACCUMULATOR MOVEDATA1FROMMEMORYTOB INCREMENT POINTER MOVE DATA2 FROM MEMORY TO D

ADD Reg D TO REGISTER B NO

IFCARRY=0 YES YES DECREMENTREGISTERB

INCREMENT C

IF ZERO FLAG SET NO INCREMENT POINTER STORERPODUCTINMEMORY INCREMENT POINTER STOREQUOTIENTINMEMORY STOP

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS 8000 8003 8005 8006 8007 8008 8009 800A 800D 800E 800F 8012 8013 8014 8015 8016 OPCODE OPERAND 21 0E AF 46 23 56 82 D2 0C 5 C2 23 77 23 71 76 09 80 Ahead 0E 80 Repeat 01 82 0 LOCATION COMMAND LXI H, 8201 MVI C, 00 XRA A MOV B,M INX H MOV D,M ADD D JNC Ahead INR C DCR B JNZ Repeat INX H MOV M,A INX H MOV M,C HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: 8201 8202 8203 8204 INPUT 1 INPUT 2 PRODUCT CARRY 5 3 F 0

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: 05 + 05 - 0000 0101 -0000 0101 - 0000 1010 -0000 0101 - 0000 1111

----- 0A + = 05 0F

RESULT: The program to multiply two 8-bit hexadecimal numbers using 8085 was executed.
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

8-BIT DIVISION
AIM: To divide two 8-bit hexadecimal numbers using 8085 microprocessor PROGRAM: Address Program LDA 8201 MOV B,A LDA 8200 Explanation Load contents of Accumulator with Divisor from memory Move contents of Accumulator to Register B Load contents of Accumulator with Dividend from memory

MVI C, 00 Clear register C to account for Carry Again CMP B JC Store SUB B INR C Compare Register B with Accumulator If carry==1, jump to Store If carry==0, subtract Register B from Accumulator Increment register C by 1

JMP Again Jump to Again , unconditionally Store STA 8203 Store Accumulator content (Reminder) to

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Memory MOV A,C STA 8202 HLT Move contents of Register C to Accumulator Store Accumulator content (Quotient) to Memory End of Program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START

GETDIVISORINTOACCUMULATOR,THENMOVEITTO REGISTER B

GETDIVIDENDINTOACCUMULATOR

SETCARRYTO0

COMPAREACCUMULATORTO REGISTER B INCREMENTC

SUBTRACTBFROM ACCUMULATOR

NO

IFCARRY=1

STOREREMINDER YES MOVEQUOTIENTFROMCTO

STOREQUOTIENTIN MEMORY STOP

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS OPCODE OPERAND LOCATION COMMAND 8000 8003 8004 8007 8009 800A 800D 800E 800F 8012 8015 8016 8019 3A 47 3A 0E B8 DA 90 0C C3 32 79 32 76 02 82 09 80 03 82 Store 12 80 00 82 0 Again 01 82 LDA 8201 MOV B,A LDA 8200 MVI C, 00 CMP B JC Store SUB B INR C JMP Again STA 8203 MOV A,C STA 8202 HLT

INPUT & OUTPUT: i)


DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

8200 8201 8202 8203 ii) 8200 8201 8202 8203

DIVIDEND DIVISOR

6 3

REMINDER 2 QUOTIENT 0

DIVIDEND DIVISOR

15 5

REMINDER 4 QUOTIENT 1

CALCULATION: i) Dividend A=06 ; Divisor B=03 A B = 06 -03 = 03 : While A>B , C = C+1 A B= 03 03=00 : C=C+1

Reminder = 0 , Carry=02

RESULT: Thus program for dividing two hexadecimal numbers using 8085 Microprocessor has been executed
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

ADDITION OF n NUMBERS IN ARRAY


AIM: To add n numbers in array and find the sum of those numbers using 8085 Microprocessor with memory pointer.

PROGRAM: Address Program LXI H, 8201 MOV B,M MVI C, 00 XRA A Repeat INX H ADD M JNC Ahead INR C Ahead DCR B Explanation Setting pointer for data Move number of data to Register B from Memory Clear register C to account for Carry Set Accumulator to '0' to account for product Increment the memory pointer Add Contents of Memory to Accumulator & store in Accumulator If carry==0 , go Ahead Increment register C by 1, If carry ==1 Decrement Register B content by 1

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

JNZ Repeat STA 8300 MOV A,C STA 8301 HLT

If B is not Zero, got back to Repeat Store Accumulator content (Sum) to Memory Move contents of Register C to Accumulator Store Accumulator content (Carry) to Memory End of Program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START SETMEMORYPOINTER MOVETHEnVALUETOREGISTERB FROM MEMORY SETCFORCARRY

CLEARACCUMULATOR

INCREMENTPOINTERGETNEXTDATA

ADDCOMTENTSOFMEMORYTO ACCUMULATOR

IF CARRY=0 YES DECREMENTB NO B==0? YES STORESUMOFNNUMBERS

NO INCREMENTC

STORECARRYINMEMORY

STOP DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS OPCODE OPERAND LOCATION COMMAND 8000 8003 8004 8006 8007 8008 8009 800C 800D 800E 8011 8014 8015 8018 21 46 0E AF 23 86 D2 0C 5 C2 32 71 32 76 01 83 780 00 83 Ahead 0D 80 Repeat 0 01 82 LXI H, 8201 MOV B,M MVI C, 00 XRA A INX H ADD M JNC Ahead INR C DCR B JNZ Repeat STA 8300 MOV A,C STA 8301 HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: 8200 8201 8202 8203 8204 8205 8206 No. of Elements DATA 1 DATA 2 DATA 3 DATA 4 DATA 5 DATA 6 6 2 4 6 8 0A 0C

8300 8301

TOTAL CARRY

2A 0

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: DATA 1 : DATA 2 : + DATA 3 : + DATA 4 : + DATA 5 : + DATA 6 : TOTAL CARRY : : 02 04 06 06 0C 08 14 0A 1E 0C 2A 00 - 0000 0010 - 0000 0100 - 0000 0110 - 0000 0110 - 0000 1100 - 0000 1000 - 0001 0100 - 0000 1010 - 0001 1110 - 0000 1100 - 0010 1010

RESULT: Program to add n numbers in array and find the sum of those numbers using 8085 Microprocessor with memory pointer was executed.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

SMALLEST IN ARRAY
AIM: To find the smallest element in an array of size n using 8085 Microprocessor.

PROGRAM: Address Program LXI H, 8200 MOV B,M INX H MOV A,M DCR B Loop INX H CMP M JC Ahead MOV A,M Explanation Setting pointer for data Move number of data to Register B from Memory Increment the memory pointer Move contents of memory to Accumulator Decrement Register B content by 1 Increment the memory pointer Compare contents of memory with Accumulator If carry==1 , go Ahead i.e., number is larger Move contents of memory to Accumulator

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Ahead

DCR B JNZ Loop STA 8300 HLT

Decrement Register B content by 1 If Register B is not equal to '0', go to Loop Store Accumulator content (Smallest No) to Memory End of Program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START SETMEMORYPOINTER MOVETHEnVALUETOREGISTERB FROMMEMORY INCREMENTPOINTERGETNEXTDATA MOVEDATATOAVVUMULATOR FROM MEMORY DECREMENTB

INCREMENTPOINTERGETNEXTDATA ADDCOMTENTSOFMEMORYTO ACCUMULATOR

IF CARRY=1 YES DECREMENTB NO B==0? YES STORESMALLESTOFN NUMBERSINTOMEMORY

NO

MOVECONTENT OFMTOA

STOP DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS OPCODE OPERAND LOCATION COMMAND 8000 8003 8004 8005 8006 8007 8008 8009 800C 800D 800E 8011 8014 21 46 23 7E 5 23 BE DA 7E 5 C2 32 76 07 80 00 83 Ahead 0D 80 Loop 00 82 LXI H, 8200 MOV B,M INX H MOV A,M DCR B INX H CMP M JC Ahead MOV A,M DCR B JNZ Loop STA 8300 HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: 8200 8201 8202 8203 8204 8205 8206 No. of Elements DATA 1 DATA 2 DATA 3 DATA 4 DATA 5 DATA 6 6 04 03 01 02 05 0C

8300

TOTAL

01

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: B =6 i) A=04 ; B=5 ii) M=03 , Compare M with A: Carry=0 A=03 ; B=4 iii) M=01, Compare M with A: Carry=0 A=01; B=3 iv)M=02, Compare M with A: Carry=1, B=2 v) M=05, Compare M with A: Carry=1, B=1 vi)M=0C, Compare M with A: Carry=1, B=0 Hence, A=01 Smallest number

RESULT: Program to find the smallest element in an array of size n using 8085 Microprocessor has been executed.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

LARGEST IN ARRAY
AIM: To find the Largest element in an array of size n using 8085 Microprocessor.

PROGRAM: Address Program LXI H, 8200 MOV B,M INX H MOV A,M DCR B Loop INX H CMP M JNC Ahead MOV A,M Explanation Setting pointer for data Move number of data to Register B from Memory Increment the memory pointer Move contents of memory to Accumulator Decrement Register B content by 1 Increment the memory pointer Compare contents of memory with Accumulator If carry==0, go Ahead i.e., number is smaller Move contents of memory to Accumulator

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Ahead

DCR B JNZ Loop STA 8300 HLT

Decrement Register B content by 1 If Register B is not equal to '0', go to Loop Store Accumulator content (Sum) to Memory End of Program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START SETMEMORYPOINTER MOVETHEnVALUETOREGISTERB FROM MEMORY INCREMENTPOINTERGETNEXTDATA MOVEDATATOAVVUMULATOR FROM MEMORY DECREMENTB

INCREMENTPOINTERGETNEXTDATA ADDCOMTENTSOFMEMORYTO ACCUMULATOR IF CARRY=0 YES DECREMENTB NO B==0? YES STORELARGESTOFN NUMBERSINTOMEMORY

NO

MOVECONTENT OF M TO A

STOP DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS: ADDRESS OPCODE 8000 8003 8004 8005 8006 8007 8008 8009 800C 800D 800E 8011 8014 21 46 23 7E 5 23 BE D2 7E 5 C2 32 76 07 80 00 83 Ahead 0D 80 Loop OPERAND LOCATION COMMAND 00 82 LXI H, 8200 MOV B,M INX H MOV A,M DCR B INX H CMP M JNC Ahead MOV A,M DCR B JNZ Loop STA 8300 HLT

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: 8200 8201 8202 8203 8204 8205 8206 No. of Elements DATA 1 DATA 2 DATA 3 DATA 4 DATA 5 DATA 6 6 04 03 01 22 05 0C

8300

TOTAL

01

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: B =6 i) A=04 ; B=5 ii) M=03 , Compare M with A: Carry=1 B=4 iii) M=01, Compare M with A: Carry=1 ; B=3 iv)M=22, Compare M with A: Carry=0, A=22, B=2 v) M=05, Compare M with A: Carry=1, B=1 vi)M=0C, Compare M with A: Carry=1, B=0 Hence, A=22 Largest number

RESULT: Program to find the Largest element in an array of size n using 8085 Microprocessor has been executed
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Date:
Experiment No:

SORTING IN ASCENDING ORDER


AIM: To Sort an array of n element in ascending order PROGRAM:
LXI H, 8200 MOV E,M MOV B,M Next MOV C,E INX H DCR C Compare MOV A,M INX H CMP M JC Ahead MOV D,M MOV M,A DCX H MOV M,D INX H Ahead DCR C JNZ Compare DCR B JNZ Next HLT Setting pointer for data Move contents of memory(size of array) to Register E Move number of data to Register B from Memory Move register E content to Register C Increment the memory pointer Decrement Register C by 1 Move contents of memory to Accumulator Increment the memory pointer Compare contents of memory with Accumulator Jump on Carry to Ahead Move contents of Memory to Register D Move contents of Accumulator to Memory Decrement the memory pointer Move contents of Register D to Memory Increment the memory pointer Decrement Register C by 1 If Register C is not equal to '0', go to Compare Decrement Register B content by 1 If Register B is not equal to '0', go to Next End of Program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START SET MEMORY POINTER FOR DATA GETNUMBEROFELEMENTSIN ARRAY MOVE TO E B(ref) MOVCONTENTSOFETOC INCREMENTPOINTERFORDATA DECREMENTC MOVEDATAFROMMTOA

INCREMENTPOINTERFORNEXTDATA COMPAREMWITHACCUMULATOR YES

CARRY??? NO SWAPDATABETWEEN MEMORY AND ACCUMUL;ATOR DECREMENTC YES

C==0? NO DECREMENTB YES B==0? NO STOP

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS:
ADDRESS 8000 8003 8004 8005 8006 8007 8008 8009 800A 800B 800E 800F 8010 8011 8012 8013 8014 8017 8018 801B OPCODE 21 5E 46 4B 23 0D 7E 23 BE DA 56 77 2B 72 23 0D C2 05 C2 76 OPERAND 00 82 LOCATION COMMAND LXI H, 8200 MOV E,M MOV B,M Next MOV C,E INX H DCR C Compare MOV A,M INX H CMP M JC Ahead MOV D,M MOV M,A DCX H MOV M,D INX H Ahead DCR C JNZ Compare DCR B JNZ Next HLT

13 80

08 80 05 80

INPUT & OUTPUT:


8200 8201 8202 8203 8204 8205 8206 No.ofElements DATA1 DATA2 DATA3 DATA4 DATA5 DATA6 6 5 8 3 6 7 15

AfterSorting 8201 DATA1 3 DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
8202 8203 8204 8205 8206 DATA2 DATA3 DATA4 DATA5 DATA6 5 6 7 8 15

8200 8201 8202 8203 8204 8205

No.ofElements DATA1 DATA2 DATA3 DATA4 DATA5

05 1A 0A 5C 18 23

AfterSorting 8200 No.ofElements 8201 DATA1 8202 DATA2 8203 DATA3 8204 DATA4 8205 DATA5

05 0A 1A 18 23 5C

RESULT: Program to Sort an array of n element in ascending order using 8085 Microprocessor was executed.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

SORTING IN DESCENDING ORDER


AIM: To Sort an array of n element in ascending order using 8085 Microprocessor

PROGRAM: Address Program


LXI H, 8200 MOV E,M MOV B,M Next MOV C,E INX H DCR C Compare MOV A,M INX H CMP M JNC Ahead MOV D,M MOV M,A DCX H MOV M,D INX H Ahead DCR C

Explanation
Setting pointer for data Move contents of memory(size of array) to Register E Move number of data to Register B from Memory Move register E content to Register C Increment the memory pointer Decrement Register C by 1 Move contents of memory to Accumulator Increment the memory pointer Compare contents of memory with Accumulator Jump on NO Carry to Ahead Move contents of Memory to Register D Move contents of Accumulator to Memory Decrement the memory pointer Move contents of Register D to Memory Increment the memory pointer Decrement Register C by 1

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

JNZ Compare DCR B JNZ Next HLT

If Register C is not equal to '0', go to Compare Decrement Register B content by 1 If Register B is not equal to '0', go to Next End of Program

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START SETMEMORYPOINTERFORDATA GETNUMBEROFELEMENTSIN ARRAY MOVE TO E B(ref) MOVCONTENTSOFETOC INCREMENTPOINTERFORDATA DECREMENTC MOVEDATAFROMMTOA

INCREMENTPOINTERFORNEXTDATA COMPAREMWITHACCUMULATOR YES

CARRY=0? NO SWAPDATABETWEEN MEMORY AND ACCUMUL;ATOR DECREMENTC YES

C==0? NO DECREMENTB YES

B==0? NO STOP

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS:
ADDRESS 8000 8003 8004 8005 8006 8007 8008 8009 800A 800B 800E 800F 8010 8011 8012 8013 8014 8017 8018 801B OPCODE 21 5E 46 4B 23 0D 7E 23 BE D2 56 77 2B 72 23 0D C2 05 C2 76 OPERAND 00 82 LOCATION COMMAND LXI H, 8200 MOV E,M MOV B,M Next MOV C,E INX H DCR C Compare MOV A,M INX H CMP M JC Ahead MOV D,M MOV M,A DCX H MOV M,D INX H Ahead DCR C JNZ Compare DCR B JNZ Next HLT

13 80

08 80 05 80

INPUT & OUTPUT:


8200 8201 8202 8203 8204 8205 8206

No. of Elements DATA 1 DATA 2 DATA 3 DATA 4 DATA 5 DATA 6

6 06 18 1B 2C 1A 15

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

After Sorting 8201 DATA 1 8202 DATA 2 8203 DATA 3 8204 DATA 4 8205 DATA 5 8206 DATA 6

2C 1B 1A 18 15 06

8200 8201 8202 8203 8204 8205

No. of Elements DATA 1 DATA 2 DATA 3 DATA 4 DATA 5

05 1A 0A 5C 18 23

After Sorting 8200 No. of Elements 8201 DATA 1 8202 DATA 2 8203 DATA 3 8204 DATA 4 8205 DATA 5

05 5C 23 1A 18 0A

RESULT: Program to Sort an array of n element in descending order using 8085 Microprocessor was executed.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

FIBONACCI SERIES
AIM: To display n elements of the Fibonacci series using 8085 Microprocessor

PROGRAM: Address Program


LXI H, 8300 LDA 8200 CPI 00 JZ End MOV C,A MVI B, 01 MVI A,00 MOV M,A INX H DCR C JZ End MOV D,A ADD B MOV B,D MOV M,A INX H DCR C JNZ Again RST 1

Explanation
Setting pointer for storing/ displaying data Load contents of Accumulator with no. of numbers to be generated Check if 00 If Zero , end program - no display Move contents of Accumulator to Register C Move '01' (second number in Fibonacci Series) to Register B Move '00' (First number in Fibonacci Series) to Accumulator Move contents of Accumulator to Memory Increment the memory pointer Decrement Register C by 1 If Zero , end program Move contents of Accumulator to Register D Add contents of Register B to Accumulator Move contents of Register D to Register B Move contents of Accumulator to Memory Increment the memory pointer Decrement Register C by 1 If Register C is not equal to '0', go to Again Reset command

Again

end

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
START

FLOWCHART

SETMEMORYPOINTERFORDATA GETNUMBEROFELEMENTSTOBE DISPLAYED TO ACCUMULATOR

YES

ACCU=0? NO

MOVEATOC B=01ANDACCUMULATOR=00

MOVEACCUMULATORCONTENTTOMEMORY INCREMENTMEMORYPOINTER

DECREMENTC YES NO SWAPDATABETWEEN REGISTER B & ACCUMUL;ATOR MOVEACCUMULATORTOMEMORY

C==0

INCREMENTMEMORYPOINTER,DECREMENTC YES

CNOTZERO NO
STOP

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS:
ADDRESS 8000 8003 8006 8008 800B 800C 800E 8010 8011 8012 8013 8016 8017 8018 8019 801A 801B 801C 801F OPCODE 21 3A FE CA 4F 0B 3E 77 23 0D CA 57 80 42 77 23 0D C2 CF OPERAND LOCATION COMMAND 00 83 LXI H, 8300 00 82 LDA 8200 00 CPI 00 1F 80 JZ End MOV C,A 01 MVI B, 01 00 MVI A,00 MOV M,A INX H DCR C 1F 80 JZ End Again MOV D,A ADD B MOV B,D MOV M,A INX H DCR C 16 80 JNZ Again end RST 1

INPUT & OUTPUT: NO. of elements (8200)=06 8201 8202 8203 8204 8205 8206

0 1 1 2 3 5

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: Number of Elements in Series =06 00 01 + 01 01 + 02 01 + 03 02 + 05

RESULT: Program to display n elements of the Fibonacci series using 8085 Microprocessor was executed
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

I/O INTERFACING WITH 8085


I/O STRUCTURE OF A TYPICAL MICROCOMPUTER:

There are three major types of data transfer between the microcomputer and art I/O device. They are,

Programmed I/O : In programmed I/O the data transfer is accomplished through an I/O port and controlled by software. Interrupt driven I/O : In interrupt driven I/O, the I/O device will interrupt the processor, and initiate data transfer. Direct memory access (DMA) : In DMA, the data transfer between memory and I/O can be performed by bypassing the microprocessor.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INTERFACING I/O AND PERIPHERAL DEVICES:


1. For data transfer from input device to processor the following operations are performed.

The input device will load the data to the port. When the port receives a data, it sends message to the processor to read the data. The processor will read the data from the port. After a data have been read by the processor the input device will load the next data into the port.

2. For data transfer from processor to output device the following operations are performed.

The processor will load the data to the port. The port will send a message to the output device to read the data. The output device will read the data from the port. After the data have been read by the output device the processor can load the next data to the port. The various INTEL 110 port devices are 8212, 8155/8156, 8255, 8355 and 8755.

8156:

It has two numbers of 8-bit parallel I/O port (port-A and B) One number of 6-bit parallel 1 port (port-C). It has 14 bit timer (operating in 4 modes). It has six internal addresses. It has one chip select pin CS (low).

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Fig - Internal address of 8156

8255:

It has 3 numbers of 8-bit parallel I/O ports (port A, B and C). Port-A can be programmed in mode-0 mode-1 or mode-2 as input or output port. Port-B can be programmed in mode-1 and mode-2 as 1/Oport. When ports A and B are in mode-0, the port-C can be used as I/O port. One logic low chip select (CS) pin. It requires four internal addresses

Fig - Internal address of 8255

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Experiment No:

GENERATE SAWTOOTH WAVEFORM


AIM: To generate Sawtooth waveform using 8085 microprocessor

PROGRAM:
Start Loop MVI A,00 OUT C0 INR JNZ Loop JMP Start Make Accumulator '0' Display Accumulator content at Port Increment Accumulator by '1' If Accumulator is not equal to '0', go to Loop Jump to Start unconditionally, for continuous wave form

MNEMONICS:
ADDRESS 4100 4102 4104 4105 4108 OPCODE 3E D3 3C C2 C3 OPERAND LOCATION COMMAND 00 Start MVI A,00 C0 Loop OUT C0 INR 02 41 JNZ Loop 00 41 JMP Start

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START

MOVE00INTOACCUMULATOR

DISPLAYVALUEATPORT

INCREMENTA

A!=0

WAVEFORM:

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: Amplitude: Time Period:

RESULT: The Sawtooth Waveform was generated and wave was plotted.
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Date: Experiment No:

GENERATE TRIANGULAR WAVEFORM


AIM: To generate Triangular waveform using 8085 Microprocessor.

PROGRAM:
Start Loop 1 MVI L,00 MOV A,L OUT C8 INR L JNZ Loop1 MVI L,FF Loop 2 MOV A,L OUT C8 DCR L JNZ Loop2 JMP Start Set Register L equal to '0' -minimum Move contents of Register L to Accumulator Display Accumulator content at Port Increment Register L by '1' If Register L is not '0' jump to Loop1 Set Register L equal to 'FF' - maximum Move contents of Register L to Accumulator Display Accumulator content at Port Decrement Register L by '1' If Register L is not '0' jump to Loop2 Jump to Start unconditionally, for continuous wave form

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

START

FLOWCHART
MOVE00INTOREGISTERL

MOVECONTENTOFLINTOACCUMULATOR

DISPLAYVALUEATPORT

INCREMENTL

YES

L!=0

NO MOVEFFINTOREGISTERL

MOVECONTENTOFLINTOACCUMULATOR

DISPLAYVALUEATPORT

DECREMENTL

YES

L!=0 NO

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS:
ADDRESS OPCODE OPERAND LOCATION COMMAND 4100 4102 4103 4105 4106 4109 410B 410C 410E 410F 4112 2E 7D D3 2C C2 2E 7D D3 2D C2 C3 0C 41 00 41 C8 03 41 FF Loop 2 C8 0 Start Loop 1 MVI L,00 MOV A,L OUT C8 INR L JNZ Loop1 MVI L,FF MOV A,L OUT C8 DCR L JNZ Loop2 JMP Start

WAVEFORM:

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: Amplitude: Time Period:

RESULT: The Triangular Waveform was generated and wave was plotted.
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Date: Experiment No:

GENERATE SQUARE WAVEFORM


AIM: To generate Square waveform using 8085 Microprocessor

PROGRAM:
Start MVI A,00 OUT C8 CALL DELAY MVI A,FF OUT C8 CALL DELAY JMP Start MVI B,05 MVI C,FF DCR C JNZ Loop2 DCR B JNZ Loop1 RET Move '0' into Accumulator Display 0 at port Call the DELAY subroutine Move 'FF' into Accumulator Display at port Call the DELAY subroutine Jump to start Move 05 to Register B to give delay Move FF to Register C Decrement Register C by 1 If C NOT '0' , decrement C again Decrement Register B by 1 If B NOT '0', go to Loop1 Return to the main program

Return

DELAY Loop 1 Loop 2

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START

MOVE0TOACCUMULATOR

DISPLAYATPORT CALLDELAY

MOVEFFTOACCUMULATOR

DISPLAYATPORT CALLDELAY

MOVE05TOREGISTERB

MOVEFFTOREGISTER

DECREMENTCBY1

C==0? YES DECREMENTBBY1

NO

YES

B==0?

NO

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS:
ADDRESS 4100 4102 4104 4107 4109 410B 410E 4120 4122 4124 4125 4128 4129 412C OPCODE 3E D3 CD 3E D3 CD C3 6 0E 0D C2 5 C2 C9 OPERAND 0 C8 2041 FF C8 1141 2041 5 FF 2441 2241 LOCATION Start COMMAND MVIA,00 OUTC8 CALLDELAY MVIA,FF OUTC8 CALLDELAY JMPStart MVIB,05 MVIC,FF DCRC JNZLoop2 DCRB JNZLoop1 RET

Return

DELAY Loop1 Loop2

WAVEFORM:

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: Amplitude: Time Period:

RESULT: The Square Waveform was generated and wave was plotted.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

GENERATING SINE WAVE


AIM: To generate Sine Waveform using 8085 Microprocessor PROGRAM:
Set pointer to get data from Look-up table Set Register C for number of data in look up MVI C, 46 table Loop MOV A, M Move contents of memory into Accumulator OUT C0 Display out put at port INX H Increment memory pointer to next data DCR C Decrement register C JNZ Loop If C is not '0' , go to Loop JMP Start Start again Look -Up Table : Starting Address : 4110 74 8A BF E7 FC FA E0 B5 7F 49 1D 04 07 25 53 84 95 C8 ED FE F7 D9 AA 74 3F 17 01 0B 2D 5F 95 A0 D1 F2 FF F2 D1 A0 69 36 10 00 10 36 69 A0 AA D9 F7 FE ED C8 95 5F 2D 0B 01 17 3F 74 7F B5 E0 FA FC E7 BF 8A 53 25 07 04 1D 49 Start LXI H, 4110

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

FLOWCHART

START

SETTINGPOINTERFORDATATO LOOKUPTABLE

MOVE46(ARRAYSIZE)TO REGISTERC MOVECONTENTOFMEMORYTO ACCUMULATOR

DISPLAYATPORT

INCREMENT MEMORYPOINTER

DECREMENTC

NO C==0?

YES

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MNEMONICS:
ADDRESS 4100 4103 4105 4106 4108 4109 410A 410D OPCODE 21 0E 7E D3 23 0D C2 C3 05 41 00 41 C0 OPERAND 10 41 46 Loop LOCATION COMMAND Start LXI H, 4110 MVI C, 46 MOV A, M OUT C0 INX H DCR C JNZ Loop JMP Start

WAVEFORM:

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

CALCULATION: Amplitude: Time Period:

RESULT: The Sine Waveform was generated and wave was plotted.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

8086 Pin Diagram

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

8086 Instruction Set Summary


Data Transfer Instructions
MOV IN, OUT LEA LDS, LES PUSH, POP XCHG XLAT Move byte or word to register or memory Input byte or word from port, output word to port Load effective address Load pointer using data segment, extra segment Push word onto stack, pop word off stack Exchange byte or word Translate byte using look-up table

Logical Instructions
NOT AND OR XOR TEST Logical NOT of byte or word (one's complement) Logical AND of byte or word Logical OR of byte or word Logical exclusive-OR of byte or word Test byte or word (AND without storing)

Shift and Rotate Instructions


SHL, SHR SAL, SAR ROL, ROR RCL, RCR Logical shift left, right byte or word by 1 or CL Arithmetic shift left, right byte or word by 1 or CL Rotate left, right byte or word by 1 or CL Rotate left, right through carry byte or word by 1 or CL

Arithmetic Instructions
ADD, SUB ADC, SBB INC, DEC NEG CMP MUL, DIV IMUL, IDIV CBW, CWD Add, subtract byte or word Add, subtract byte or word and carry (borrow) Increment, decrement byte or word Negate byte or word (two's complement) Compare byte or word (subtract without storing) Multiply, divide byte or word (unsigned) Integer multiply, divide byte or word (signed) Convert byte to word, word to double word (useful before multiply/divide)

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

Adjustments after arithmetic operations: AAA, AAS, AAM, AAD ASCII adjust for addition, subtraction, multiplication, division (ASCII codes 30-39) DAA, DAS Decimal adjust for addition, subtraction (binary coded decimal numbers)

Transfer Instructions
JMP Unconditional jump (short 127/8, near 32K, far between segments) Conditional jumps: JA (JNBE) Jump if above (not below or equal) +127, -128 range only JAE (JNB) Jump if above or equal(not below) +127, -128 range only JB (JNAE) Jump if below (not above or equal) +127, -128 range only JBE (JNA) Jump if below or equal (not above) +127, -128 range only JE (JZ) Jump if equal (zero) +127, -128 range only JG (JNLE) Jump if greater (not less or equal) +127, -128 range only JGE (JNL) Jump if greater or equal (not less) +127, -128 range only JL (JNGE) Jump if less (not greater nor equal) +127, -128 range only JLE (JNG) Jump if less or equal (not greater) +127, -128 range only JC, JNC Jump if carry set, carry not set +127, -128 range only JO, JNO Jump if overflow, no overflow +127, -128 range only JS, JNS Jump if sign, no sign +127, -128 range only JNP (JPO) Jump if no parity (parity odd) +127, -128 range only JP (JPE) Jump if parity (parity even) +127, -128 range only Loop control: LOOP Loop unconditional, count in CX, short jump to target address LOOPE (LOOPZ) Loop if equal (zero), count in CX, short jump to target address LOOPNE (LOOPNZ) Loop if not equal (not zero), count in CX, short jump to target address JCXZ Jump if CX equals zero (used to skip code in loop)

Subroutine and Interrupt Instructions


CALL, RET

Call, return from procedure (inside or outside current segment)

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INT, INTO IRET

Software interrupt, interrupt if overflow Return from interrupt

String Instructions
MOVS Move byte or word string MOVSB, MOVSW Move byte, word string CMPS Compare byte or word string SCAS Scan byte or word string (comparing to A or AX) LODS, STOS Load, store byte or word string to AL or AX Repeat instructions (placed in front of other string operations): REP Repeat REPE, REPZ Repeat while equal, zero REPNE, REPNZ Repeat while not equal (zero)

Processor Control Instructions


Flag manipulation: STC, CLC, CMC STD, CLD STI, CLI LAHF, SAHF PUSHF, POPF Set, clear, complement carry flag Set, clear direction flag Set, clear interrupt enable flag Load AH from flags, store AH into flags Push flags onto stack, pop flags off stack

Coprocessor, multiprocessor interface: ESC Escape to external processor interface LOCK Lock bus during next instruction Inactive states: NOP WAIT HLT

No operation Wait for TEST pin activity Halt processor

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

16 BIT ADDITION USING 8086


AIM: To add two 16 bit numbers (4 digits) using the 8086 microprocessor.

PROGRAM:
Program MOV SI, 1500 LODSW MOV AX, BX LODSW ADD BX, AX MOV DI,[1520] Explanation Set source index as 1500 Load data from source memory and auto increment memory pointer Move data from AX to BX Load data from source memory Add contents of AX, BX

Set Destination index as address in 1520 Move Result in BX to location pointed by Destination MOV [DI], BX Index INT 3 Break Point

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT: INPUT 1 4283 INPUT 2 2931 SUM 6BB4 CARRY 00 1500 83 Lower Byte of Data 1 1501 1502 1503 1520 1521 42 31 29 B4 6B Higher Byte of Data 1 Lower Byte of Data 2 Higher Byte of Data 2 Lower Byte of Sum Higher Byte of Sum i)

RESULT:Program to add two 16 bit numbers (4 digits) with 8086 microprocessor was executed

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

MOVE CONTENTS OF ARRAY


AIM: To move contents of array from one memory location to another memory location.

PROGRAM:
Address Program MOV CL, 08 MOV SI, 1400 MOV DI, 1450 Loop LODSB MOV [DI], AL INC DI DEC CL JNC Loop INT 3 Explanation Set number of data i.e., count Set source index as 1400 Set Destination index as memory address 1500 Load data from source memory Move content of address pointed by destination Index to lower byte of accumulator Increment Destination index Decrement count Jump if not zero to Loop Break Point

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT:


INPUT 1400 1401 1402 1403 1404 1405 1406 1407 11 22 33 44 21 31 41 51 OUTPUT 1500 1501 1502 1503 1504 1505 1506 1507 11 22 33 44 21 31 41 51

RESULT:Program to shift contents of an array from one location to another was executed

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

SUM OF N CONSECUTIVE NUMBERS


AIM: To find the sum of N consecutive numbers with 8086 microprocessor PROGRAM:
Address Program MOV SI, 2000 MOV CL, [SI] MOV AL, 00 MOV BL, 01 ADD AL, BL INC BL DEC CL JNZ LOOP MOV DI, 2002 MOV [DI], AX INT 3 Explanation Set source index as 2000 Move content of address pointed by source index to CL Clear AL to store sum Move '1' to BL , as its the first number Add content of BL to AL increment BL Decrement the count Jump if not zero to Loop Set Destination index as memory address 2002 Move content of Register A to destination, which is the total sum Break Point

LOOP

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT:


INPUT OUTPUT 2000 2002 05 0F

1+2+3+4+5 = 15 = F (HEXADECIMAL)

RESULT: Thus program for finding sum of n consequent numbers was executed

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

CONVERSION OF BCD TO HEXADECIMAL


AIM: To convert a BCD number into hexadecimal with 8086 microprocessor PROGRAM:
Program MOV SI, 1600 MOV DI, 1500 MOV AL, [SI] MOV AH, AL AND AH, 0F MOV BL, AH AND AL, F0 MOV CL, 04 ROR AL, CL MOV BH, 0A MUL BH ADD AL, BL MOV [DI], AL INT 3 Explanation Set source index as 1600 Set Destination index as memory address 1500 Load BCD number into AL register Move content of AL to AH Mask MSD of BCD number Save LSD in BL register Mask LSD of BCD number Load 04 to counter rotate AL by counter times move 0A to BH register Multiply BH register Add AL, BL Move result to Destination Break Point

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT:


INPUT OUTPUT 1600 1500 56 38

RESULT: Thus program for converting BCD to Hexadecimal number was executed.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

SEPARATE ODD & EVEN


AIM: To separate odd and even numbers using 8086 microprocessor

PROGRAM:
Address Program MOV CL, 06 MOV SI, 1600 MOV DI, 1500 Loop LODSB ROR AL, 01 JB Loop ROL AL,01 MOV [DI], AL INC DI DEC CL JNZ Loop INT 3 Explanation Set counter in CL register Set source index as 1600 Set Destination index as memory address 1500 Load data from source memory Rotate AL once to right If bit is one Jump to Loop Rotate AL once to left Move result to Destination Increment Destination index Decrement the count Jump if not zero to Loop Break Point

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT:


INPUT 1600 1601 1602 1603 1604 1605 1500 1501 1503 2 5 7 6 12 15 5 7 15

OUTPUT

RESULT: Thus program for separating Odd & Even numbers was executed.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

8051 Pin Diagram

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

8051 Instruction Set


ARITHMETIC OPERATIONS Mnemonic Description ADD A,Rn Add register to Accumulator ADD A,direct Add direct byte to Accumulator ADD A,@Ri Add indirect RAM to Accumulator ADD A,#data Add immediate data to Accumulator ADDC A,Rn Add register to Accumulator with Carry ADDC A,direct Add direct byte to Accumulator with Carry ADDC A,@Ri Add indirect RAM to Accumulator with Carry ADDC A,#data Add immediate data to Acc with Carry SUBB A,Rn Subtract Register from Acc with borrow SUBB A,direct Subtract direct byte from Acc with borrow SUBB A,@Ri Subtract indirect RAM from ACC with borrow SUBB A,#data Subtract immediate data from Acc with borrow INC A Increment Accumulator INC Rn Increment register INC direct Increment direct byte INC @Ri Increment direct RAM DEC A Decrement Accumulator DEC Rn Decrement Register DEC direct Decrement direct byte DEC @Ri Decrement indirect RAM INC DPTR Increment Data Pointer MUL AB Multiply A & B DIV AB Divide A by B DA A Decimal Adjust Accumulator LOGICAL OPERATIONS Mnemonic Description ANL A,Rn AND Register to Accumulator ANL A,direct AND direct byte to Accumulator ANL A,@Ri AND indirect RAM to Accumulator ANL A,#data AND immediate data toAccumulator ANL direct,A AND Accumulator to direct byte
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

ANL direct,#data ORL A,Rn

AND immediate data to direct byte OR register to Accumulator

LOGICAL OPERATIONS (continued) Mnemonic Description ORL A,direct OR direct byte to Accumulator ORL A,@Ri OR indirect RAM to Accumulator ORL A,#data OR immediate data to Accumulator ORL direct,A OR Accumulator to direct byte ORL direct,#data OR immediate data to direct byte XRL A,Rn Exclusive-OR register to Accumulator XRL A,direct Exclusive-OR direct byte to Accumulator XRL A,@Ri Exclusive-OR indirect RAM to Accumulator XRL A,#data Exclusive-OR immediate data to Accumulator XRL direct,A Exclusive-OR Accumulator to direct byte XRL direct,#data Exclusive-OR immediate data to direct byte CLR A Clear Accumulator CPL A Complement Accumulator RL A Rotate Accumulator Left RLC A Rotate Accumulator Left through the Carry RR A Rotate Accumulator Right RRC A Rotate Accumulator Right through the Carry SWAP A Swap nibbles within the Accumulator DATA TRANSFER Mnemonic MOV A,Rn MOV A,direct MOV A,@Ri MOV A,#data MOV Rn,A MOV Rn,direct MOV Rn,#data MOV direct,A MOV direct,Rn MOV direct,direct MOV direct,@Ri

Description Move register to Accumulator Move direct byte to Accumulator Move indirect RAM to Accumulator Move immediate data to Accumulator Move Accumulator to register Move direct byte to register Move immediate data to register Move Accumulator to direct byte Move register to direct byte Move direct byte to direct Move indirect RAM to direct byte

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

MOV direct,#data MOV @Ri,A MOV @Ri,direct MOV @Ri,#data MOV DPTR,#data16

Move immediate data to direct byte Move Accumulator to indirect RAM Move direct byte to indirect RAM Move immediate data to indirect RAM Load Data Pointer with a 16-bit constant

DATA TRANSFER (continued) Mnemonic Description MOVC A,@A+DPTR Move Code byte relative to DPTR to Acc MOVC A,@A+PC Move Code byte relative to PC to Acc MOVX A,@Ri Move External RAM (8- bit addr) to Acc MOVX A,@DPTR Move Exernal RAM (16- bit addr) to Acc MOVX @Ri,A Move Acc to External RAM (8-bit addr) MOVX @DPTR,A Move Acc to External RAM (16-bit addr) PUSH direct Push direct byte onto stack POP direct Pop direct byte from stack XCH A,Rn Exchange register with Accumulator XCH A,direct Exchange direct byte with Accumulator XCH A,@Ri Exchange indirect RAM with Accumulator XCHD A,@Ri Exchange low-order Digit indirect RAM with Acc BOOLEAN VARIABLE MANIPULATION Mnemonic Description CLR C Clear Carry CLR bit Clear direct bit SETB C Set Carry SETB bit Set direct bit CPL C Complement Carry CPL bit Complement direct bit ANL C,bit AND direct bit to CARRY ANL C,/bit AND complement of direct bit to Carry ORL C,bit OR direct bit to Carry ORL C,/bit OR complement of direct bit to Carry MOV C,bit Move direct bit to Carry MOV bit,C Move Carry to direct bit JC rel Jump if Carry is set JNC rel Jump if Carry not set
DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

JB bit,rel JNB bit,rel JBC bit,rel

Jump if direct Bit is set Jump if direct Bit is Not set Jump if direct Bit is set & clear bit

PROGRAM BRANCHING Mnemonic Description ACALL addr11 Absolute Subroutine Call LCALL addr16 Long Subroutine Call RET Return from Subroutine PROGRAM BRANCHING(continued) Mnemonic Description RETI Return from interrupt AJMP addr11 Absolute Jump LJMP addr16 Long Jump SJMP rel Short Jump (relative addr) JMP @A+DPTR Jump indirect relative to the DPTR JZ rel Jump if Accumulator is Zero JNZ rel Jump if Accumulator is Not Zero CJNE A,direct,rel Compare direct byte to Acc and Jump if Not Equal CJNE A,#data,rel Compare immediate to Acc and Jump if Not Equal CJNE Rn,#data,rel Compare immediate to register and Jump if Not Equal CJNE @Ri,#data,rel Compare immediate to indirect and Jump if Not Equal DJNZ Rn,rel Decrement register and Jump if Not Zero DJNZ direct,rel Decrement direct byte and Jump if Not Zero NOP No Operation
Source : Atmel 8051 Microcontrollers Hardware Manual

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

8 BIT ADDITION
AIM: To perform 8-bit addition using 8051 microcontroller PROGRAM:
Address Program MOV a,#23 MOV r1,#11 MOV r2, #00 ADD a,r1 JNC ahead INC r2 ahead Explanation Move data 1 to a Move data 2 to register 1 Set r2 for carry Add a, r1 Jump on no carry to ahead If carry is '1' increment r2

MOV DPTR,#9200 Set datapointer to location 9200 move a contents to location pointed by data MOVX @ DPTR,a pointer (DPTR) INC DPTR MOV a,r2 Increment pointer Move r2 to a move a contents to location pointed by data MOVX @ DPTR,a pointer (DPTR) LCALL 00BB End

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT:


Data 1 Data 2 9200 9201 23 11 34 0

RESULT: Thus program for adding two 8 bit numbers had been executed.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual
Date: Experiment No:

8 BIT SUBTRACTION
AIM: To perform 8-bit subtraction using 8051 microcontroller PROGRAM:
Address Program MOV a,#23 MOV r1,#11 MOV r2, #00 SUBB a,r1 JNC ahead INC r2 ahead Explanation Move data 1 to a Move data 2 to register 1 Set r2 for carry Subtract r1 from a and store in a Jump on no carry to ahead If carry is '1' increment r2

MOV DPTR,#9200 Set datapointer to location 9200 move a contents to location pointed by data MOVX @ DPTR,a pointer (DPTR) INC DPTR MOV a,r2 Increment pointer Move r2 to a move a contents to location pointed by data MOVX @ DPTR,a pointer (DPTR) LCALL 00BB End

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Microprocessor&MicrocontrollerLabManual

INPUT & OUTPUT:


Data 1 Data 2 9200 9201 23 11 12 0

RESULT: Thus program for subtracting two 8 bit numbers had been executed.

DepartmentofBiomedicalEngineering,SRMUniversity,Kattankulathur

Вам также может понравиться