Sie sind auf Seite 1von 179

SRI MANAKULA VINAYAGAR ENGINEERING COLLEGE

DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EE P62 Microprocessors Laboratory


LABORATORY MANUAL

ACADEMIC YEAR 2012-2013

Prepared By

C.Kalaivani

INDEX
S.No. Date Name of the Experiment Page No. Marks Remarks

S.No.

Date

Name of the Experiment

Page No.

Marks

Remarks

8085 ARCHITECTURE:

STUDY OF MICROPROCESSOR KIT


AIM: To study the entire structure parts and application of 8085 microprocessor trainer kit. BASIC FEATURE: 24 TTL lines Hardware single stepping and software Single stepping of user program EB-2 Rs 232-c compatible serial port Bus expansion for inter facing VbMb series of for add-ox cards and 24TTL input-output times. HARDWARE SPECIFICATION: 1. Processor clock features: Intel 8085A at 6.144MHz. 2.Memory: Monitor EPROM EPROM expansions System RAM Monitor data area User RAM data area Ram expansion - 0000 to 1FFF - 2000 to 3FFF & C000 to FFFF - 4000 to 5FFF - 4000 to 40FF - 4100 to 5FFF - 6000 to BFFF
7

2. INPUT/OUTPUT: Parallel: 48TTL I/O lines using two no.s of 8255 Series: One no.of Rs 232C compatible serial interfaces using 8251A VSARI Timer : 3-channel 16 bit programmable timer using 8253 . channel - 0 : Banel rate clock generater for 8251 A 5 . USARI . Channel - 1 : Single stepping user program Channel - 2 : Hardware single stepping user programming . 4. DISPLAY : 6 digit , 0.3, 7 segment RED ( E1 ) display with filter . 4 - digit - address display 2 - digit - data display 5 . DISPLAY KEYBOARD : 21 keys ( soft keys including command keys and hexadecimal keys ) 6.POWER SUPPLY : 5V @ 1A
8

5V @ 500 ma - EB1 + 12 V @ 200 ma - EB2 - 12 V @ 100 ma 7 . POWER SUPPLY CONNECTION : ( EXTERNAL ) EB2 i/p - 230 v AC @ 50 HZ o/p - 5v @ 3A EB1 230 V AC @ 50 HZ 5V @ 600 mA . SOFTWARE SPECIFICATION : Moniter program - 8 K Hex key function 1. Hex key . 2. Register key 3. Command key . 21 KEYS : 16 keys - hex , command , register keys remaining are stored alone keys . KEY : 1 . Hex keys 0 , 1 ,2 , . F 2 . SUB - substituting the memory contents . when NEXT key is pressed , immediately press after this key it makes the user program . ( user RAM 4100 )
9

3 . Register key E Examine 8085 register keys . TW - Writes data from memory on to the audio tape . TR - Retries data from an audio tape to memory . BLOC - Block serch for a byte . FILL - Fill a block of RAM memory with desired data. SER - Transmit / receive data to/ from the serial port . F2 Function key. GO Start running a particular program. SNG Single step a program instruction by instruction PL Register key PCL. PH - Register key PCH. PC program counter. H high L low F3 Function key F[0] Input a byte from a port. F[1] - Output a byte from a port. F3 with SNG For hardware single steeping Sl Register key SPL Sh - Register key SPL. Bc-check a particular block for blank. Sp Stack pointer MOV Move a block of memory to another block CMP-Compare 2 memory blocks INS Insert a byte with memory DEL- Delete a byte with memory
10

INPUT OUTPUT ALLOCATION TABLE: USER DEVELOPMENT 2nd parallel port (8255) 1st parallel port (8255) 8253 HARDWARE SINGLE STEP CONTROL KEYBOARD/DISPLAY CONTROLLER JUMPER KEYS: J3 &J4 RAM J5 EPROM

11

BATTERY BACK UP: 3.6V @ 60mA Nickel cadmium battery is used which provides power to RAM during power OFF and gets charged during power -ON. The data in RAM can be retained to a maximum of 12 hours if the battery has been charged to its maximum extent.

1.SUBSTITUTE MEMORY COMMAND :


Used to examine the contents of selected memory location and modify its content if desired . Reset - sub - add - next - data - . - INT INT - press INT to terminate the sub command . Pressing the NEXT after entry of desired data will put the entered data to memory location desired them .

2. REGISTER COMMAND :
To examine the register content . Reset - reg - b - 45 - NEXT - . - INT

3. GO AND EXECUTE COMMAND :


GO - used to run a program . This command transfer to control of 8085 MPU , from keypad moniter to user program . GO - address - EXEC

4. GO AND EXECUTE COMMAND WITH BREAK POINT :

12

This command execute a block of program whose start address are specified . It is equivalent to pressing INTR key while the program is being executed . GO - starting address - NEXT - break point address - EXEC - content will be displayed - reg - b ( or ) - content will be displayed

5. SINGLE STEP:
This command helps the user to execute programs in steps ( ie ., ) instruction by instruction Useful while debugging SNG - address - NEXT

6. FILL COMMAND :
FILL - starting address - NEXT - final address - data - INT This command moves permits a block of RAM memory to be filled with desired data type .

7. BLOCK MOVE COMMAND :


This command moves the content of a specified block of memory to another block of memory whose starting address is specified . MOV - starting add - NEXT - ending add - NEXT - destination add NEXT - INT

8. COMPARE COMMAND :
This command compares the contents of two blocks of memory locations and display address whose contents are not identical

13

CMP - starting add - NEXT - ending add - NEXT - destination address - NEXT - INT

9. INSERT COMMAND :
This command inserts the specified bytes in desired memory location INS - ending add - NEXT - insert add - NEXT - data - NEXT - INT

10. DELETE COMMAND :


This command delete byte from memory . DEL - block start address NEXT - block and address - NEXT - program end address - NEXT The block starting from ( block and address + 1 ) to the program end address will be moved to the block starting address from block start address .

11. INPUT COMMAND :


This command inputs data from desired port . F3 - 0 - port add - NEXT - data - NEXT - INT .

12. OUTPUT COMMAND :


This command outputs data to the desired port . F3 - 1 - port add - NEXT - data - NEXT - INT

13. BLOCK SEARCH COMMAND:


This command search a block of memory for a particular

14

byte . BLOC - starting add - NEXT - end add -b NEXT - byte - NEXT INT

14. BLACK CHECK COMMAND :


To check a block of memory for location that do not contain FF . BC - starting address - NEXT - ending address - NEXT Brief instruction to 8085 microprocessor: A microprocessor is a multipurpose kit programmable clock drivers, register based electronic device called memory storage that reads binary instruction code from memory & accept binary data as input & processes those data according to those instructions & provides result as output. The 8085 is a microprocessor with 8 bit length its instruction set is designed by using various combination of these 8 bits. The 8085 is an improved version of earlier processor 8080A. The process of data manipulation & communication is determined by the logic design of the Microprocessor called the architecture. The various function performed by the 1. Microprocessor initiated operation 2. Internal operation 3. Peripheral operation 8085 microprocessor is capable of addressing 64 K of memory. It is 40 pins package. It is a dual pin package of very large scale integration
15

microprocessor can be classified into three categories.

technology using TTL & comprises of 1130,000 transistor. 8085 microprocessor consists of a 1. 16 bit address bus. 2. 8 bit data bus. The sped of 8085 microprocessor is 3.07 MHz. SIGNAL: ADDRESS BUS: The 8085 has 8 signal lines. A15-A8 which are unidirectional & are used as higher order address bus. MULTIPLEXED ADDRESS/DATA BUS: The signals AD7-AD0 are bidirectional. They are used for both lower order address bus as well as data bus which is separated using a latch. CONTROL & STATUS SIGNALS; The signals read & write are control signal and io/m, S0,S1 are status signal. ALT is a special signal that indicates if the AD7-AD0 is a data /address lines. TIMING & CONTROL UNIT: This unit synchronizes all the microprocessor operation with the clock & generates the control signal necessary for the communication between microprocessor and peripherals . A RITHMETIC AND LOGIC UNIT :

16

ALU performs the computing function .It includes the accumulator and temporary register held data during the calculations . Accumulator stores the result obtained . It is a 8 bit register . FLAGS : SIGN FLAGS : The flag is reset if the result in the accumulator is negative . If it is reset to zero the result is positive . ZEROFLAG : The flag is set if the result is zero else result is not zero . AUXILLIARY CARRY : If it is set , if the carry exists for D3 digits to be passed to the D4 digit . Otherwise the AC flag is result to zero . PARITY FLAG : It is set if there are even nos of ones in the result else the flag is reset . REGISTERS : There are 6 general purpose register storing 8 bit of data . They are combined in pair to store 16 bits of data . There are two temporary registers W & Z . They are internal registers and not available to the user . PROGRAM COUNTER :

17

This 16 bit of register deals with the sequencing of execution . It is a memory pointer to memory location from which the next byte is to be fetched . STACK POINTER : It is also a 16 bit registers which is a memory pointes to the memory location called stack . It defines where the program has to continue after the call of a subroutine. DISPLAY DRIVE: The segment drive output of 8279 from a signal 8 bit parallel output driving the display element segments . The correspondence between the data bus segment outputs of 8279 and the display element is shown . DISPLAY POSITION : To display character in the address field 8279 must be instructed to start from display positions O and to display character in the data field . 8279 must be instructed to start from display position by sending 94H to the command port of 8279. KEY BOARD: Keyboard display interface is responsible for all the operations. The keyboard is of a alphanumeric type. The input is sent to the process through the keyboard. First is the control keyboard which has control keys. The hexadecimal keys are of 16 that is from 0 to 9 & from A to F keys. Some of control keys are given. RES:

18

This key allows to terminate any present activity and to return to SDA to the initial state. CRYSTAL OSCILATOR: It is basically a tuned oscillator. The crystal is made of quartz material and provides a high degree of frequency stability & accuracy. Therefore, the crystal oscillator is used where frequency stability is needed. INTERUPTS CONTROLLER: It is a programmable interrupts managing device specifying designed for use with the interrupt signal of 8085 microprocessor. PROGRAMMABLE PERIPHERAL INTERFACE: The 8255 has 3 parts A,B & C. The ports A&B are 8 bit parallel ports. Port A can be programmed to work in any one of the three operating modes as input or output port . CONTROL LOGIC : The control section has six lines . Their functions and connections are as follows : READ This control signal enables the read operation when the signal is low , the MPU reads data from a selected I/O port of the 8255A WRITE This control signal enables the write operation when the signal goes low , the MPU write into a selected IO port or the control register.
19

RESET : This is an active high signal , it clears the control register and sets all ports in the input mode . CS , AO AND A1 : These are devices select signals . CS is connected to a decoded address , and AO& A1.. The CS signals in the master chip select , AO& A1 specify one port or the control register . CONTROL WORD : To communicate with peripherals through the 8255, three steps are necessary Determine the addresses of port A , B and C & of the control register according to the chip select logic and address lines AO & A1 . Write a control word in the control register . Write I/O instructions to communicate with peripherals through ports A , B and C . KEYBOARD DISPLAYINTERFACE ( 8279 ) The keyboard / display section of the MPs 85.3 is controlled by 8279 . The 8279 is configured for the following operation . Encode scan keyboard with 2 keys lock out 8 digits , 8 bits , left entry display . KEYBOARD SECTION : This section has eight lines ( RL0 RL7 ) That can be connected to eight columns of a key board .
20

SCAN SECTION : The scan section has a scan counter and four scan lines can ( SL0 SL3 ) .These four scan lines can be decoded using 4 to 16 decoder to generate 16 lines for scanning . DISPLAY SECTION: The display section has eight output lines divided unto two groups A0-A3 & B0-B3. These lines can be used, either a group of eight lines or two groups of four,in conjuction with the scan lines for a multiplexed display. PROGRAMMING THE 8279: The initialization commands can specify: left or right entry & key rollover. Clock frequency prescaler Starting address &incrementing mode of FIFO RAM Blanking formate BLOCK DIAGRAM OF 8253: DATA BUS BUFFER: This tri-state,8-bit,bidirectional buffer is connected buffer is connected to the data bus of the MPU. CONTROL LOGIC: The control section has five signals: Read
21

Write Chip select A0-A1 In the peripheral I/O mode,the read &write signal are peripheral I/O mode, connected to IOR respectively. CONTROL WORD REGISTER: This register is accessed when lines A0&A1 are at logic1.It is used to write a common word which specifies the counter to be used its mode and either a read or a write operation. 8251A(USART) The function requirements for the software approach are summarized below: An input port & an output port are required for interfacing .In data transmission, the MPU converts a parallel word into a stream of serial ports. READ WRITE AND CONTROL LOGIC: This selection includes R/W control logic six input signals, control logic and these buffer register Data register Control register Status register INPUT SIGNALS: CHIP SELECT: When this signal goes low, the 8251A is selected by the MPU for communication. CONTROL DATA:
22

When this signal is high, the control register or the status register is addressed. READ: When this signal goes low, the microprocessor either reads a status from the status register accepts data from the data buffer. RESET A high on this input resets the 8251A & forces it into idle mode. CLOCK: This is the clock input usally connected to the system clock. This clock does not control either the transmission or the reception rate.

DATA BUFFER: This bidirectional register can be addressed as an input port and an output port when the C/D pin . TRANSMITTER CLOCK: This input signal controls the rate at which bits are transmitted by the USART. The clock frequency can be 1,16 or 64 times the band. RECEIVER DATA Bits are received serially in this line and converted into a parallel byte in the receiver input register. RECEVIER CLOCK: This is a clock signal the convert the rate at which bits are received by the USART. The asynchronous mode, the clock can be set to 1,16 or 64 timer the band. POWER SUPPLY:
23

5V, 3A +12V, 250mA -12V, 100mA 30V, 100mA BATTERY OPTION: Holder is backed up by an optional battery, holder is provided for two A A type cells with quick charges circuit . User may use Ni cd or dry cells. Carie must be taken to remove the discharged cells

RESULT : Thus the entire structure , port 2IC of the microprocessor kit has been studied .

24

25

26

27

Exp.No:1.a Date:

Simple Arithmetic Operations

Aim: To write assembly language programs for Intel 8085 microprocessor to perform the following
functions; (a) (b) (c) (d) (e) (f) 8 bit addition with carry 8 bit addition without carry 8 bit subtraction with carry 8 bit subtraction without carry 8 bit multiplication and 8 bit by 8 bit division.

To check the above programs by executing using 8085 trainer.

Apparatus Required:
1.8085 Trainer 2. Operation Code sheet

(a) 8 bit addition with carry Algorithm:


STEP 1: Start program. STEP 2: Loading the first data to an Accumulator. STEP 3: moving the data from Accumulator to one Register. STEP 4: Again loading the second data to an Accumulator. STEP 5: Moving the data immediately to one Register to check whether if there is any carry are not. STEP 6: Then adding the two data first and second value. STEP 7: If there are no carry then the loop will jump to the statement which it process. STEP 8: End the program.

28

FLOW CHART:

START

Load the accumulator 1 Move accumulator to B

YES

If zero NO Store the accumulator NOthe content of D to C Move Store the accumulator

NO

Load the accumulator Move accumulator to C Move data to accumulator Move data to register C YES Add A to B NO 1

STOP

NO If Carry YES NO Increment the value of D NO Decrement value of D

A 29

source code:
ADDRESS 8100 8103 8106 8107 8109 810B 810E 810F 8112 8113 8116 LABEL MNEMONICS LDA 9001 MOV B, A LDA 9002 ADD B MVI D, 00 JNC LOOP INR D OPCODE COMMENT

3A, 01, 90 Load the first 8 bit data in the accumulator 47 Move the 8 bit data in the accumulator to register B

3A, 02, 90 Load the second 8 bit data in the accumulator 80 16,00 Add the two 8 bit datas. Initialize a register for carry

D2, 0F, 81 Jump to store the result if there is no carry 14 32,10,90 7A 32,11,90 76 Else increment the carry register Store the result in memory. Move the carry in the register D to accumulator. Store carry bit in memory. Stop the program.

LOOP

STA 9010 MOV A, D STA 9011 HLT

30

Input and output: Before Execution Address Data 9000 8C 9001 9E 9002 00 9003 00 After Execution Address 9000 9001 9002 9003

Data 8C 9E 2A 01

31

(b) 8 bit addition without carry Algorithm:


STEP 1: Start program. STEP 2: Loading the first data to an Accumulator. STEP 3: moving the data from Accumulator to one Register. STEP 4: Again loading the second data to an Accumulator. STEP 5: Moving the data immediately to one Register to check whether if there is any carry are not. STEP 6: Then adding the two data first and second value. STEP 7: If there are no carry then the loop will jump to the statement which it process. STEP 8: End the program.

Program code:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS

32

8000 8003 8004 8007 8008 800B

LDA 9000 MOV B, A LDA 9001 ADD B STA 9002 HLT

3A 00 90 47 3A 01 90 80 32 02 90 76

Load first 8-bit data to accumulator. Move the 8-bit number to B register. Load second 8-bit data to accumulator. Add the two 8 bit data. Store the result in memory. Stop the program

33

Input and output: Before Execution After Execution

Address 9000 9001 9002

Data 2A 5B 00

Address 9000 9001 9002

Data 2A 5B 85

(c) 8 bit subtraction with borrow Algorithm:


STEP 1: Start the program. STEP 2: Loading the first data value to accumulator. STEP 3: Loading the second data value to the accumulator. STEP 4: Then clear one Register as zero. STEP 5: Subtract the value second data from first data value. STEP 6: Jump with no carry is the result is not having carry, then gotostep8. STEP 7: Increment the value of third Register as 1. STEP 8: Go to step 6. STEP 9: Moving third register value to accumulator. STEP 10: Then store the subtracted value in one address. 34

STEP 11: End of the program.

35

FLOW CHART:

START

Load the accumulator

Move C to accumulator

Move accumulator to B

Store the accumulator

Load the accumulator Move data to register C

STOP

Increment the value of C

Subtract B form accumulator

NO If carry YES Add B with accumulator NO Decrement the value of D NO

Store the accumulator

A 36

Program code:
ADDRESS 8000 8002 8005 8006 8009 800A 800D 800E 800F 8011 8014 8015 8018 LOOP LABEL MNEMONICS MVI D, 00 LDA 9000 MOV B, A LDA 9001 SUB B JNC LOOP INR D CMA ADI 01 STA 9000 MOV A, D STA 9003 HLT OPCODE 16 00 3A 00 90 47 3A 01 90 90 D2 80 11 14 2F C6 01 32 00 90 7A 32 03 90 76 COMMENTS Initialize a register for borrow Load the accumulator with minuend Move the 8 bit data in the accumulator to register B. Load the subtrahend data in the accumulator. Subtract the two 8 bit numbers. Jump to LOOP if no carry is set. Increment the accumulator content to obtain 2s Complement the accumulator content. Increment by 01 Store the result in address. Move the borrow bit in the register D to the accumulator. Store the borrow in memory. Stop the program

37

INPUT &OUTPUT

Before Execution Address Data 9000 04 9001 06 9002 00 9003 00

After Execution Address 9000 9001 9002 9003

Data 04 06 0E 01

38

(d) 8 bit subtraction without borrow Algorithm:


STEP 1: Start the program. STEP 2: Loading the first data value to accumulator. STEP 3: Loading the second data value to the accumulator. STEP 4: Then clear one Register as zero. STEP 5: Subtract the value second data from first data value. STEP 6: Jump with no carry is the result is not having carry, then gotostep8. STEP 7: Increment the value of third Register as 1. STEP 8: Go to step 6. STEP 9: Moving third register value to accumulator. STEP 10: Then store the subtracted value in one address. STEP 11: End of the program

Program code:
ADDRESS 8000 8003 8004 LABEL MNEMONICS LDA 9000 MOV B, A LDA 9001 OPCODE 3A 00 90 47 3A 01 90 COMMENTS Load the first subtrahend data in the accumulator. Move the 8-bit data to B register. Load the minuend data to the accumulator.

39

8007 8008 800B

SUB B STA 9002 HLT

90 32 02 90 76

Subtract the two 8 bit numbers. Store the result in memory. Stop the Program

Input and output: Before Execution After Execution

40

Address 9000 9001 9002

Data 09 05 00

Address 9000 9001 9002

Data 09 05 04

(e) 8 bit multiplication Algorithm:


STEP1: Start the program. STEP 2: Load the first data to the accumulator. STEP 3: Move the first data from Accumulator to one register. STEP 4: Load the second data value to accumulator. STEP 5: Then keep the Accumulator value as zero. STEP 6: And then again keep another one register as zero. STEP 7: Add the first value to the accumulator. STEP 8: In above step if there is no carry then go to step 10. STEP 9: Increment the value of third register. STEP 10: Decrement the value of second Register. STEP 11: Go to step 7. STEP 12: Store the result value in one address. STEP 13: Move the data from third register to accumulator. STEP 14: Store the above data value to one address. STEP 15: End of the program.

41

FLOW CHART:

Programcode:

42

ADDRESS 8000 8003 8004 8007 8008 8009 800B 800C 800F 8010 8011 8014 8017 8018 801B

LABEL

MNEMONICS LDA 9000 MOV B, A LDA 9001 MOV C, A MVI A, 00 MVI D, 00 ADD B JNC LOOP INR D DCR C JNZ LOOP1

OPCODE 3A 00 90 47 3A 01 90 4F 3E 00 16 00 80 D2 10 80 14 0D C2 0B 80 32 02 90 7A 32 03 90 76

COMMENTS Load the first 8-bit number in accumulator. Move the 8-bit number to B register. Load the second 8-bit number in accumulator. Move the second 8-bit number to C register. Clear the contents of A register. Clear the contents of D register. Add the first 8-bit number to accumulator. Jump, decrement the count C if no carry. Else increment carries register by 1. Decrement counter register. Add the number again if count is not zero. Store the result in address. Move the carry to accumulator. Store the carry in address. Stop the program.

LOOP1

STA 9002 MOV A, D STA 9003

LOOP

HLT

43

FLOW CHART:

Load the accumulator

Move accumulator to B Load the accumlator Move data to register C

Add B with accumulator

If carry YES Increment the value of C NO

NO

NO

Store the accumulator

Move C to accumulator

Store the accumulator

44

INPUT &OUTPUT

Before Execution Address Data 9000 04 9001 06 9002 18 9003 00

After Execution Address 9000 9001 9002 9003

Data 04 06 18 00

45

Algorithm:
STEP 1: Start the program. STEP 2: Load the accumulator from a specified address. STEP 3: Move the content of accumulator to register B. STEP 4: Then again load the accumulator from a specified address. STEP 5: Move immediately the content of register C to zero. STEP 6: Then increment the content of register B. STEP 7: Then subtract the content of register B from the accumulator. STEP 8: Then check for carry. STEP 9: If carry is not present then add the content of B with the accumulator. STEP10: If carry is present the content of register c is increased and the process repeated. STEP 11: Then decrement the content of register C. STEP12: Store the content of accumulator to a address. STEP 13: Then move the content of register C to accumulator A. STEP 14: Then store the content of accumulator in address. STEP 15: Stop the program.

46

Program code:
ADDRESS 8000 8002 8005 8006 8009 800A 800B 800E 800F 8010 8013 8014 8017 INPUT &OUTPUT LOOP LABEL MNEMONICS MVI D, 00 LDA 9000 MOV B, A LDA 9001 SUB B INR D JNC LOOP ADD B DCR D STA 9002 MOV A, D STA 9003 HLT OPCODE 16 00 3A 00 90 47 3A 01 90 90 14 D2 09 80 80 15 32 02 90 7A 32 03 90 76 COMMENTS Clear the contents of C register to store quotient. Load the first 8-bit number into accumulator. Move the 8-bit number to B register. Load the second 8-bit number into accumulator. Subtract 8 bit data from accumulator. Increment quotient register by 1 Subtract repeatedly till carry is set. Add the content of B register. Decrement the quotient by 1. Store the remainder in address. Move the quotient in C register to accumulator. Store the quotient to address. End of program.

Before Execution

After Execution

47

Address 9000 9001 9002 9003

Data 02 08 00 00

Address 9000 9001 9002 9003

Data 02 08 00 04

48

Result:Thus assembly language programs are written for Intel 8085 microprocessor to perform
the following functions; (a) (b) (c) (d) (e) (f) 8 bit addition with carry 8 bit addition without carry 8 bit subtraction with carry 8 bit subtraction without carry 8 bit multiplication and 8 bit division.

49

Exp.No:1.b Date:

Simple Arithmetic Operations

Aim:To write assembly language programs for Intel 8085 microprocessor to perform the
following functions; (a) (b) (c) (d) 16 bit addition 16 bit subtraction 16 bit multiplication and 16 bit division.

To check the above programs by executing using 8085 trainer.

Apparatus Required:
1.8085 Trainer 2. Operation Code sheet

(a) 16 bit addition Algorithm:


STEP 1: Start the program. STEP 2: Move the immediate data to the E register. STEP 3: Load the accumulator from the specified address. STEP 4: Move the content of accumulator to register C. STEP 5: Load the accumulator from specified address . STEP 6: Move the content of accumulator to B register . STEP 7: Load the accumulator from the specified address. 50

STEP 8: Move the content of accumulator to register L. STEP 9: Load the accumulator from specified address . STEP 10: Move the content of accumulator to H register . STEP 11: Move the content of C register to accumulator. STEP 12: Add L register to the content of accumulator. STEP 13: Store the accumulator in specified address. STEP 14: Move the content of B register to accumulator. STEP 15: Add register H to the content of accumulator in to carry. STEP 16: Store the accumulator in specified address. A STEP 17: Jump on no carry to LOOP. STEP 28: Increment the register E. Move data to E register STEP 19: Move the content of E register to accumulator. FLOW CHART: Store the accumulator STEP 20: Store the content of accumulator. STEP 21: Stop the program. Load the accumulator Move B to accumulator Move accumulator to C A=A+H+CARRY Load the accumulator Store the accumulator

Move accumulator to B

Load the accumulator Move accumulator to C

YES

If no carry NO E=E+1

NO

Load the accumulator

Move accumulator to H

NO Move the value of E to accumulator Increment the value of D

Move accumulator to C A=A+I

STOP 51 A

ADDRESS 8000 8003 8004 8007 8008 800B 800D 800F 8012

LABEL

MNEMONICS OPCODE LHLD 9000 XCHG LHLD 9002 DAD D SHLD 9004 MVI A, 00 ACI 00 STA 9006 HLT 2A 00 90 EB 2A 02 90 19 22 04 90 3E 00 CE 32 06 90 76

COMMENTS Load the first 16 bit data to HL register pair. Exchange the contents of HL and DE register pairs. Load the second 16 bit data to HL register pair. Add the two 16 bit numbers and store in HL. Store the result in address. Clear the contents of A register to store carry. Add the carry bit if available, to accumulator with 00 H. Store the carry bit in address. End of program.

INPUT &OUTPUT

52

Before Execution

After Execution

Address 9000 9001 9002 9003 9004 9005 9006 9007

Data AE EB AC 6B 00 00 00 00

Address 9000 9001 9002 9003 9004 9005 9006 9007

Data AE EB AC 6B 56 5B 01 00

(b) 16 bit subtraction Algorithm:


STEP 1: Start the program. STEP 2: Move the immediate data to the E register. STEP 3: Load the accumulator from the specified address. STEP 4: Move the content of accumulator to register C. STEP 5: Load the accumulator from specified address . STEP 6: Move the content of accumulator to B register . STEP 7: Load the accumulator from the specified address. STEP 8: Move the content of accumulator to register L. STEP 9: Load the accumulator from specified address . 53

STEP 10: Move the content of accumulator to H register . STEP 11: Move the content of C register to accumulator. STEP 12: Subtract L register to the content of accumulator. STEP 13: Store the accumulator in specified address. STEP 14: Move the content of B register to accumulator. STEP 15: Subtract register H to the content of accumulator with carry. STEP 16: Store the accumulator in specified address. STEP 17: Jump on no carry to LOOP. STEP 28: Move immediate data to register E. STEP 19: Move the content of E register to accumulator. STEP 20: Store the content of accumulator. STEP 21: Stop the program.

54

FLOW CHART:

A Move data to E register Store the accumulator Load the accumulator Move B to accumulator Move accumulator to C A= A-H-Carry Load the accumulator

Move accumulator to B

Store the accumulator

Load the accumulator Move accumulator to L

YES

If no carry NO Move E to accumulator

NO

Load the accumulator

Move accumulator to H

NO Move the value of E to accumulator

Move accumulator to C Store the accumulator A=A-I STOP A

55

ADDRESS 8000

LABEL

MNEMONICS LHLD 9000

OPCODE 2A 00 90 EB 2A 02 90 7B 95 6F 7A 9C 67 0E 00 D2 1A 80 7D 2F 6F 7C 2F 67 23 0C 56

COMMENTS Load the first 16 bit data to HL register pair. Exchange the contents of HL and DE register pairs. Load the second 16 bit data to HL register pair. Move lower order bit to accumulator. Subtract the lower order bit of second number. Move the result in L register. Move the higher order bit to accumulator. Subtract the higher order bit of second number. Store the result in H register. Clear the C register for storing carry register. Jump to storing the result if no carry. Move the lower order bit to accumulator. Complement accumulator. Move the complemented bit to L register. Move the higher order bit to accumulator. Complement accumulator. Move the complemented bit to H register. Add one to the HL register pair. Increment Carry register.

JUMP 8003 8004 8007 8008 8009 800A 800B 800C 800D 800F 8012 8013 8014 8015 8016 8017 8018 8019 XCHG LHLD 9002 MOV A, E SUB L MOV L, A MOV A, D SBB H MOV H, A MVI C, 00 JNC JUMP MOV A, L CMA MOV L, A MOV A, H CMA MOV H, A INX H INR C

801A 801B 801C 801D

SHLD 9005 MOV A, C STA 9007 HLT

22 05 90 79 32 07 90 76

Store the result in address Move the carry bit to accumulator. Store the carry bit in address. End of program

INPUT &OUTPUT

Before Execution Address Data 9000 78 9001 65 9002 51 9003 43 9004 00 9005 00 9006 00 9007 00
57

After Execution Address Data 9000 78 9001 65 9002 51 9003 43 9004 27 9005 22 9006 00 9007 00

(c) 16 bit multiplication Algorithm:


STEP 1: Start the program. STEP 2: Load the HL register pair from the specified address. STEP 3: Copy the content of HL register pair to stack pointer. STEP 4: Load the HL register pair from the specified address. STEP 5: Exchange the content of HL register pair to DE register pair. STEP 6: Move the immediate data to HL register pair. STEP 7: Move the immediate data to BC register pair. STEP 8: Add the stack pointer with HL register pair. STEP 9: Jump on carry to loop. STEP 10: Increment the register pair BC. STEP 11: Jump on zero to step. STEP 12: Store the HL register pair. STEP 13: Move the content of register B to H. STEP 14: Move the content of register C to L. STEP 15: Store the HL register pair. STEP 16: Stop the program.

58

59

FLOW CHART:

START

A Move E to accumulator OR D with accumulator

Load the HL reg pair

Copy HL to stack pointer

Load the HL reg pair Exchange the HL to DE Load immediate data to HL reg pair Load immediate data to BC reg pair

YES NO

If no zero

NO

Store the HL reg pair NO Move the value of H to B

Add SP to HL reg pair

Move the value of C to L YES

If no carry NO Increment the BC reg pair

Store HL reg pair NO STOP

NO Decrement the DE reg pair

A 60

Program code:
ADDRESS LABEL MNEMONICS 8000 8003 8006 8007 800A 800B 800E 800F 8012 8013 8014 8015 8016 8019 801C 801D 801E 8021 STEP LOOP LXI B, 0000 LHLD 9000 XCHG LHLD 9002 SPHL LXI H, 0000 DAD SP JNC STEP INX B DCX D MOV A, E ORA D JNZ LOOP SHLD 9004 MOV L, C MOV H, B SHLD 9006 HLT OPCODE 01 00 00 2A 00 90 EB 2A 02 90 F9 23 00 00 39 D2 13 80 03 1B 7B B2 D2 0E 80 22 04 90 69 60 22 06 90 76 COMMENTS Clear the contents of B register to store carry. Load the first 16-bit number to accumulator. Exchange the contents of HL and DE register pairs. Load the second 16-bit number to accumulator. Store the 16 bit data in SP. Clear the contents of HL register pairs. Add the contents of SP with HL register pair. Jump to decrement the count if no carry Else increment carry register. Decrement counter Move the lower order bit in E register to accumulator. Perform OR with higher order bit in D register to check for zero count. Add SP again to HL if count in not zero. Store the result in address Move the lower order carry bit to accumulator. Move the higher order carry bit to accumulator. Store the carry in address. End of program.

61

INPUT &OUTPUT

Before Execution Address Data 9000 11 9001 12 9002 11 9003 12 9004 00 9005 00 9006 00 9007 00
62

After Execution Address Data 9000 11 9001 12 9002 11 9003 12 9004 21 9005 65 9006 46 9007 01

(d) 16 bit division Algorithm:


STEP 1: Load the immediate data to the register pair BC. STEP 2: Load the HL register pair. STEP 3: Move the content of H to accumulator. STEP 4: Jump on zero to the result. STEP 5: Exchange the content of HL register pair to DE register pair. STEP 5: Load the HL register pair. STEP 6: Move the content H to A. STEP 7: Jump on zero to the result. STEP 8 : Increment the register pair to BC. STEP 9: Move the content of L to A. STEP 10: Subtract E with the accumulator. STEP 11: Move the content A to L register. STEP 9: Move the content of H to A. STEP 9: Subtract with borrow to D register. STEP 11: Move the content A to H register. STEP 9: Jump on carry to loop. STEP 9: Add the content of two register pair. STEP 12: Decrement the register pair BC. STEP 13: Store the HL register pair directly. STEP 14: Move the B to L register. 63

STEP 15: Move the C to H register. STEP 16: Store the HL register pair. STEP 17: Stop the program. Get immediate value of BC reg pair FLOW CHART: Load the HL reg pair A=A-D-Carry Move the value of H to accumulator Move accumulator to H OR L with accumulator YES NO NO Exchange the HL content to DE pair Load the HL reg pairNO Move the value of H to accumulator Store the HL reg pair content YES If zero NO Move the value of B to H If zero carry YES Move accumulator to L Move H to accumulator

If no carry NO Add DE to HL pair NO Decrement the BC pair

NO

OR L with accumulator

Move the value of C to L Store the HL reg pair content

NO Increment the BC reg pair

NO Move L to accumulator STOP A =A-E 64 A

Program code:
ADDRESS 8100 8103 8104 8105 8108 8109 810C 810D 810E 8111 8114 8115 8116 LOOP LABEL MNEMONICS LHLD 9100 MOV A, L ORA H JZ STEP XCHG LHLD 9102 MOV A, L ORA H JZ STEP LXI B, 0000 MOV A, L SUB E MOV L, A OPCODE 2A 00 91 7D B4 CA 21 81 EB 2A 02 91 7D B4 CA 21 81 01 00 00 7D 93 6F 65 COMMENTS Load the 16 bit divisor in HL register pair Move the lower order bit to accumulator. Perform OR operation with higher order bit to check if the divisor is zero Jump to store the result if zero flag is set Exchange the contents of HL and DE register pairs. Load the 16 bit dividend into HL register pair. Move the lower order bit to accumulator. Perform OR operation with higher order bit to check for zero. Jump to store the result if zero flag is set. Clear the BC register pair for storing the quotient. Move the lower order bit of dividend to accumulator. Subtract the lower order bit of divisor. Move the result to L register.

8117 8118 8119

MOV A, H SBB D MOV H, A

7C 9A 67

Move the higher order bit of dividend to accumulator. Subtract the higher bit of divisor with borrow if present. Move the result to H register.

INPUT &OUTPUT

Before Execution Address Data 9100 22 9101 22 9102 44 9103 44 9104 00 9105 00 9106 00 9107 00

After Execution Address Data 9100 22 9101 22 9102 44 9103 44 9104 00 9105 00 9106 02 9107 00

66

Result: Thus assembly language programs are written for Intel 8085 microprocessor to perform
the following functions; (a) (b) (c) (d) 16 bit addition 16 bit subtraction 16 bit multiplication and 16 bit division

67

Exp.No:2 Date:

BCD Arithmetic Operations

Aim:To write assembly language programs for Intel 8085 microprocessor to perform the following
functions; (a) (b) BCD addition BCD subtraction

To check the above programs by executing using 8085 trainer.

Apparatus Required:
1.8085 Trainer 2. Operation Code sheet

(a) BCD addition Algorithm:


STEP 1: Start the program STEP 2: Load the data to Accumulator STEP 3: Move immediate 00 to c reg STEP 4: Add the B value to Accumulator STEP 5: Decimal adjust Accumulator STEP 6: Jump on no carry go to step 9 STEP 7: Increment the C register STEP 8: Store the data to Accumulator STEP 9: Move the data A to C STEP 10: Store the data to Accumulator STEP 11: Stop the program

68

Program Code:
ADDRESS 8000 8003 8004 8007 8009 800A 800B 800E 800F 8012 8013 8016 LOOP LABEL MNEMONICS LDA 9000 MOV B, A LDA 9001 MVI C, 00 ADD B DAA JNC LOOP INR C STA 9002 MOV A, C STA 9003 HLT OPCODE 3A, 00,90 47 3A, 01,90 0E, 00 80 27 D2, 0F, 80 0C 32,02,90 79 32,03,90 76 COMMENTS Load the first BCD number into accumulator Move the 8 bit BCD to B register. Load the second BCD number to accumulator. Clear the contents of C register to store carry. Add the two BCD numbers. Convert the unpacked BCD to packed BCD form Jump to store the result if no carry. Increment carry register. Store the result in address. Move the Carry bit to accumulator. Store the carry bit in address. End of program.

69

(b) BCD subtraction Algorithm:


STEP 1: Start the program STEP 2: Load the data to Accumulator STEP 3: Move the data from A to B STEP 4: Load the data to Accumulator STEP 5: Move the data A to D STEP 6: Move immediate data to A register STEP 7: Subtract the D reg STEP 8: Move immediate data to A register STEP 9: Add the D register STEP 10: Add the B register STEP 11: Decimal adjust Accumulator STEP 12: Store the data to Accumulator STEP 13: Stop the program

70

FLOW CHART:

Start

A
Load the accumulator WITH THE SUBTRAHEND Move the ACCUMULATOR CONTENTto B Load the accumulator WITH MINUEND Move the accumulator to C register CLEAR THE e FOR COUNT CHECK FOR CARRY

NO

YES
Increment the regISTER E TO COUNT THE CARRY

Store the accumulator CONTENT TO MEMORY

MOVE THE ACCUMULATOR WITH 99 TO FIND 99S COMPLEMENT. Subtract REGISTER C from accumulator Move THE RESULT TO REGISTERC Add reg C with accumulator

Stop

Decimal adjust accumulator TO CONVERT THE RESULT TO PACKED BCD

Result: ThusA assembly language programs are written for Intel 8085 microprocessor to perform
the following functions; (a) Bcd addition (b) Bcd subtraction 71

72

Exp.No:3 Code Conversion Date:

Aim:To write assembly language programs for Intel 8085 microprocessor to perform the
following functions; (a) (b) (c) (d) BCD to Binary Binary to BCD Binary to octal Octal to Binary.

To check the above programs by executing using 8085 trainer.

Apparatus Required:
1.8085 Trainer 2. Operation Code sheet

(a) BCD to Binary Algorithm:


Step 1: Start the program Step 2: Load the contents of the accumulator from the sp.address Step 3: Move the content of the accumulator to B reg Step 4: Move the immediate data to C reg Step 5: Logical AND with content of C reg Step 6: Rotate the contents of the accumulator towards right four times Step 7: Move the content of the accumulator toward D reg Step 8: Move immediate data to C reg 73

Step 9: Move the content of b reg to acc Step 10: Logical and Operation with C reg Step 11: Move the content of the accumulator to reg E Step 12: Then Move immediate data to acc Step 13: Then Move immediate data to reg C Step 14: Start a loop Step 15: Add the content of reg D to accumulator Step 16: Decrement the content of reg C Step 17: Jump on no zero to loop Step 18: Add the content of reg E to acc Step 19: Store the contents of the accumulator Step 20: Stop the program

74

FLOW CHART:

75

Program code:
ADDRESS 8000 8002 8004 8007 8009 800A 800B 800E 800F 8012 8013 8014 8016 8017 8018 801B STEP LABEL JUMP MNEMONIC MVI E,0A MVI C,04 LDA 9000 ANI F0 RRC DCR C JNZ JUMP MOV B,A LDA 9000 ANI 0F MOV D,A MVI A,00 ADD B DCR E JNZ STEP ADD D OP CODE 1E OA OE 04 3A 00 90 E6 F0 0F 0D C2 09 80 47 3A 00 90 E6 0F 57 3E 00 80 10 C2 16 80 82 COMMENTS Move 0A to E register to multiply the upper nibble of BCD number by 10. Move 04 to C register to rotate the upper nibble four times. Load the BCD number to acc. Perform AND operation with 0F to separate upper nibble. Rotate content to right side without carry. Decrement the value of C register. Rotate content to right side if copunt not zero. Else move the upper nibble to reg B. Load the original BCD number to acc. Perform AND operation with F0 to separate lower nibble. Move the lower nibble to D register. Clear the contents of accumulator. Add the upper nibble to BCD number to accumulator. Decrement the E register value by 1. Jump to add the upper nibble to accumulator if count not zero. Add the lower nibble of BCD number with accumulator.

76

801C 801F

STA 9001 HLT

32 01 90 76

Store the binary value in address. Stop the program.

INPUT &OUTPUT Before Execution

After Execution

Address 9000 9001

Data 56 00

Address 9000 9001

Data 56 38

77

(b) Binary to BCD Algorithm:


Step 1: Start the program Step 2: Load the accumulator from the specified address Step 3: Move the content of accumulator to reg B Step 4: Move the immediate data present to D register Step 5: Move the immediate data in accumulator to C register Step 6: Subtract content of D from the accumulator Step 7: Jump on carry to loop Step 8: Move the content of B to accumulator Step 9: Increment the content of C reg Step 10: Subtract the content of D reg to accumulator Step 11: Jump on necessary to loop Step 12: Add the content of A to B reg Step 13: Decrement the content of C reg Step 14: Move the content of A to B reg Step 15: Move the content of C to accumulator Step 16: Stop the content of accumulator to sp.address Step 17: Move the content of B reg to accumulator Step 18: Move the immediate data to D reg Step 19: Increment the content of C reg 78

Step 20: Subtract the content of D reg Step 21: Jump on no carry to loop 2 Step 22: Add the content of accumulator with D reg Step 23: Decrement the content of C reg Step 24: Store the content of accumulator Step 25: Move the content of C reg to accumulator Step 26: Store the content of acc in specified address. Step 27: Stop the program.

79

FLOW CHART:

Program code:
ADDRESS 8050 8052 8053 8056 8058 805B 805D 805E 8061 UNIT 8063 8066 8068 8069 806C 806D JC UNIT SUI 0A INR D JMP TEN MOV C,A MOV A,D DA 6C 80 D6 0A 14 C3 61 80 4F 7A 80 Jump to check the units place if carry is set. Subtract 0A immediately from binary number. Increment the value of tens digit. Jump to check again if number is less than 10. Move content of accumulator with register C. Move the number of tens to accumulator. TEN HUND LABEL MNEMONIC MVI E,00 NIV D,E LDA 9050 CPI 9050 JC TEN SUI 64 INR E JMP HUND CPI 0A OP CODE 1E OO 53 3A 50 90 FE 64 DA 61 80 D6 64 1C C3 56 80 FE 0A COMMENTS Clear the contents of E register. Clear the contents of D register. Load the binary number to accumulator. Check if binary number is less than 100. Jump to check the tens place if carry is set. Subtract 64 immediately from binary number. Increment the value of hundreds digit. Jump to check if number is less than hundred. Check if the binary number is less than ten.

806E 806F 8070 8071 8072 8073 8076 8077 807A

RLC RLC RLC RLC ADD C STA 9051 MOV A,E STA 9052 HLT

07 07 07 07 81 32 51 90 7B 32 52 90 76

Rotate the content of acc to left without carry. Rotate the content of acc to left without carry. Rotate the content of acc to left without carry. Rotate the content of acc to left without carry. Add the units place to the tens place. Store the content of accumulator. Move the content of register E with acc. Store the content of accumulator. Stop the program

INPUT &OUTPUT Before Execution

After Execution

Address 9000 9001

Data 45 00

Address 9000 9001 9002


81

Data 45 69 00

(c) Binary to Octal Algorithm:


Step 1: Start the program Step 2: Move the immediate data to the reg Step 3: Move the content of reg B to accumulator Step 4: Move the immediate data to reg C Step 5: Logical and Operation with reg C Step 6: Store the content of accumulator in sp.address Step 7: Move the immediate to reg C Step 8: Move the content of reg B to accumulator Step 9: Logical and Operation with C reg Step 10: Rotate the content of accumulator right three times Step 11: Store the content of the accumulator Step 12: Move the content of the reg B to accumulator Step 13: Move the immediate data to reg C Step 14: Rotate the content of accumulator left three Step 15: Logical and Operation with reg C Step 16: Store the content of accumulator 82

Step 17: Stop the program

FLOW CHART:

83

Program code:
84

ADDRESS 8000 8003 8004 8006 8009 800A 800C 800D 800E 800F

LABEL

MNEMONIC LDA 9000 MOV B,A ANI 07 STA 9001 MOV A,B ANI 38 RRC RRC RRC

OP CODE 3A,00, 90 47 EB,07 32,01,90 78 E6,38 0F 0F 0F

COMMENTS Load the binary number to be converted into A register. Move the original binary number to B register. Perform AND Operation of acc with 07. Store the first digit of octal number to address. Move the original binary number to accumulator. Perform AND operation of accumulator with 38. Rotate content of accumulator to right side without carry. Rotate content of accumulator to right side without carry. Rotate content of accumulator to right without carry. Store the second digit of octal number to memory address. Move the original binary number to accumulator. Perform AND operation of accumulator with C0. Rotate the content of accumulator to left without carry. Rotate the content of accumulator to left without carry.

STA 9002 8012 MOV A,B 8013 8015 8016 ANI C0 RLC RLC

32,02,90 78 E6,C0 07 07

8017

STA 9003

32,03,90 85

Store the third digit of octal number to

memory address. 801A HLT 76 Stop the program .

INPUT &OUTPUT Before Execution

After Execution

Address 9000 9001

Data 57 00

Address 9000 9001 9002

Data 7 2 1

86

(d) Octal to Binary Algorithm:


Step 1: Start the program Step 2: Load the accumulator directly to a address Step 3: Move the content from A to B Step 4: Move immediate data on C reg as Step 5: Increment the C reg Step 6: Subtract the immediate data with accumulator Step 7: Jump on no carry to loop Step 8: Decrement the reg C Step 9: Add immediate data with accumulator Step10: Rotate the content of the accumulator towards left without carry Step 11: Rotate the contents of the accumulator without carry Step 12: Move the content from A to C reg Step 13: Load the accumulator directly Step 14: Rotate the contents of accumulator towards right without carry Step 15: Rotate the contents of accumulator towards right without carry Step 16: Perform OR operation between reg D and accumulator Step 17: Perform OR operation between reg C and accumulator Step 18: Stop the program

87

FLOW CHART:
Start

READ THEoctal number Perform AND operation with 07 & store in C regISTER

Move ORIGINAL OCTAL number to accumulator

Perform AND operation with 10H and rotate accumulator right once

Add content of C register & Store in address

Move original number to accumulator

Perform AND operation 60H and rotate accumulator right once

Add content of D register & Store in address

STOP

88

INPUT &OUTPUT Before Execution

After Execution

Address 9050

Data 45

Address 9050 9052

Data 45 25

(e) Binary to Ascii Algorithm:


Step 1: Start the program

89

Step 2: Load the contents of accumulator from the specified address Step 3: Add the content of accumulator with immediate data Step 4: Compare the content of accumulator with the immediate data Step 5: Jump on no carry to loop Step 6: Start a loop Step 7: Store the contents of accumulator Step 8: Stop the program

FLOW CHART:

90

(f)Ascii to Binary Algorithm:


Step 1: Start the program Step 2: Load the content of the accumulator from the specified. address Step 3: Subtract the content of accumulator from the immediate data Step 4: Compare the content of accumulator with immediate data Step 5: Jump on no carry to loop Step 6: Subtract the content of the accumulator with the immediate data Step 7: Start a loop Step 8: Store the content of accumulator Step 9: Stop the program

91

FLOW CHART:

92

ADDRESS LABEL 8100 8103 8105 8107 810A 810C 810F Loop

MNEMONICS LDA 9100 SUI 30 CPI 0A JC LOOP SUI 07 STA 9101 HLT

OPCODE 3A 00 91 D6 30 FE 0A DA 0C 81 D6 07 32 01 91 76

COMMENTS Load the ASCII value to accumulator. Subtract 30 H immediately both for the Numbers 0-9 as well as characters A-F. Check if result is less than 0A H. If the value is less than 0A i.e. if the Numerals are between 0-9 store the result in address. Else subtract 07 H immediately with Accumulator for characters A-F. Store the corresponding binary value in address. Stop the program.

Program code:

93

Result: Thus assembly language programs are written for Intel 8085 microprocessor to perform
the following functions; (a) (b) (c) (d) (e) (f) BCD to Binary Binary to BCD Binary to octal Octal to Binary Binary to Ascii Ascii to Binary

94

95

Exp.No:4Generating series Date: Aim: To interface the following peripherals with 8085 microprocessor and perform simple operations;
(a) Fibonacci series

Apparatus Required:
1. 8085 Trainer 2. Operation Code sheet

Algorithm:
Step 1: Get the count up to which the series has to be generated and also the starting memory address where the series has to stored. Step 2: Initialize the first and second values in registers. Step 3: Store the content of accumulator in memory. Step 4: Add the second number with the first number. Step 5: Increment memory pointer. Step 6: Interchange values in the register. Step 7: Decrement count by 1 Step 8: Check for zero, if zero flag is set, go to next step. Else go to step 3. Step 9: Stop execution.

96

FLOW CHART:

START

GET THE COUNT UPTO WHICH THE SERIES HAS TO BE GENERATED

LOAD THE STARTING MEMORY ADDRESS WHERE THE SERIES HAS TO BE STORED.

INITIALISE THE FIRST VALUE AS 00 AND SECOND VALUE AS 01 IN ANY REGISTER.

STORE THE CONTENT OF ACCUMULATOR TO MEMEORY POINTED BY THE REGISTER PAIR.

ADD THE SECOND NUMBER WITH THE FIRST NUMBER

INCREMENT THE MEMORY POINTER

INTERCHANGE THE VALUES IN REGISTER.

DECREMENT THE COUNT

CHEC K FOR ZERO

NO

YES
STOP

97

program code:

ADDRESS 8000 8003 8005 8007 800A 800B 800C 800D 800E 800F 8010 8011 8012 8015

LABEL

MNEMONIC LXI D,FA02 MVI B,00 MVI C,01 LDA FAOO MOV H,A MOV A,B

OPCODE 11 02 FA 06 00 0E 01 3A 00 00 67 78 12 13 81 41 4F 25 C2 0C 80 76

COMMENTS LoadDE pair immediately Move immediate 00 to B register Move immediate 01 to C register Directly load accumulator Move content of acc. To H register Move content of B register to acc. Store accumulator indirect IncrementDE pair by 01 Add content of C register to acc. Move content of C to B register Move content of acc. To C register Decrement H register by 01 Jump on no zero loop Stop the program

LOOP

STAX D INX D ADD C MOV B,C MOV C,A DCR H JNZ LOOP HLT

98

Result: Thus assembly language programs are written for Intel 8085 microprocessor to perform
the following functions; (a) Fibonacci series

99

Exp.No:5Sorting Date: Aim:To interface the following peripherals with 8085 microprocessor and perform simple
operations; (a) (b) Ascending Descending

Apparatus Required:
1. 8085 Trainer 2. Operation Code sheet

(a)Ascending Algorithm:
1. Start the program 2. Move immediate data to C register 3. Move the data C to B register. 4. Load HL register pair to accumulator. 5. Move the data M to D register 6. Jump on no carry. 7. Move the data M to D register. 8. Decrement the HL registers pair. 9. Increment the HL registers pair. 10. Decrement the B register. 11. Jump on no carry. 12. Decrement the C register. 13. Jump on no zero. 14. Stop the program.

100

101

FLOW CHART:

START

LOAD THE STARTING ADDRESS OF THE BLOCK INTO REGISTER PAIR AND THAT OF A COUNT TO A REGISTER

MOVE THE CONTENT OF MEMORY POINTED BY HL REGISTER TO ANY REGISTER INCREMENT THE MEMORY POINTER

MOVE THE CONTENT OF MEMORY POINTED BY HL REGISTER PAIR TO A

COMPARE THE CONTENTS OF REGISTER WITH ACCUMULATOR

CHEC K FOR CARR Y

NO

YES

INTERCHANGE THE COMPARED VALUES

DECREMENT THE COUNT REGISTER.

NO

CHEC K FOR ZERO

YES
DECREMENT THE OUTER COUNT REGISTER.

YES STOP

CHE CK FOR 102 ZER O

NO

Program code:
ADDRESS 8000 8002 8003 8006 8007 8008 8009 800A 800D 800E 800F 8010 8011 8012 8015 8016 8019 CONT INX H DCR B JNZ LOOP DCR C JNZ LOOP1 HLT 23 05 C2 04 80 0D C2 02 80 76 JNC CONT MOV M, D DCX H MOV M, A D2 0F 80 72 2B 17 LOOP MOV D, M INX H MOV A, M CMP D 56 23 7E BA LOOP1 MOV B, C LXI H, 9100 41 21 00 91 LABEL MNEMONICS MVI C, OA OPCODE OE OA COMMENTS Move immediate data to C register. Move the data C to B register Load HL register pair to accumulator Move the data D to M register. Increment the H register pair Move the data A to M register. Compare D register to accumulator. Jump on no carry Move the data M to D register Decrement the HL register pair. Move the data M to accumulator. Increment the HL register pair. Decrement the B register. Jump on no zero. Decrement the C register. Jump on no zero. Stop the program.

103

(b)Descending Algorithm:
1. Start the program. 2. Move the immediate data to c register. 3. Move the data C to B register. 4. Load HL register pair to accumulator. 5. Move the data D to M register. 6. Increment the H register pair. 7. Move the data A to M register. 8. Compare D register to Accumulator. 9. Jump on carry. 10. Move the data M to D register. 11. Decrement the HL register pair. 12. Increment the HL register pair. 13. Jump on no zero. 14. Decrement the C register. 15. Jump on no zero. 16. Stop the program.

104

FLOW CHART:
START

LOAD THE STARTING ADDRESS OF THE BLOCK INTO REGISTER PAIR AND COUNT TO A REGISTER MOVE THE CONTENT OF MEMORY POINTED BY HL REGISTER TO ANY REGISTER INCREMENT THE MEMORY POINTER

MOVE THE CONTENT OF MEMORY POINTED BY HL REGISTER PAIR TO A

COMPARE THE CONTENTS OF REGISTER WITH ACCUMULATOR

CHEC K FOR CARR Y

YES

NO

INTERCHANGE THE COMPARED VALUES

DECREMENT THE COUNT REGISTER.

NO

CHEC K FOR ZERO

YES
DECREMENT THE OUTER COUNT REGISTER.

YES STOP

CHE CK FOR ZER O

NO 105

Program code: ADDRESS LABEL 8000 8002 8003 LOOP 8006 8007 8008 LOOP1

MNEMONICS MVI C, OA MOV B, C LXI H, 9100

OPCODE OE OA 41 21 00 91

COMMENTS Move immediate data to C register. Move the data C to B register Load HL register pair to accumulator Move the data D to M register.

MOV D, M

56

INX H MOV A, M

23 7E

Increment the H register pair Move the data A to M register.

CMP D 8009 800A 800D 800E MOV M, A 800F INX H 8010 8011 8012 8015 8016 8019 CONT DCR B JNZ LOOP DCR C JNZ LOOP1 HLT JNC CONT MOV M, D DCX H

BA

Compare D register to accumulator. Jump on no carry Move the data M to D register Decrement the HL register pair. Move the data M to accumulator. Increment the HL register pair. Decrement the B register. Jump on no zero. Decrement the C register. Jump on no zero. Stop the program.

D2 0F 80 72 2B

17

23

05 C2 04 80 0D C2 02 80 76

106

Result: Thus assembly language programs are written for Intel 8085 microprocessor to perform the following functions; (a) (b) Ascending Descending

107

108

Exp.No:6Message Display Date: Aim:


To develop an assembly language program to perform the running & blinking operations of LEDs.

Apparatus Required:
1. 8085 Trainer 2. Operation Code sheet

Algorithm:
BLINKING OF LEDS Step 1: Load the control word to the accumulator to indicate that 8255 is in I/O mode and port A is enabled. Step 2: Send the control word to the control port of 8255. Step 3: Load the accumulator with FF to make all the LEDs glow. Step 4: Send the accumulator content to the port A of 8255. Step 5: Call the delay program to have time delay between change in output state. Step 6: Complement the accumulator content to change the state of output. Step 7: Repeat the step 4 to 6 to obtain continuous blinking of LEDs. MOVING LEDS Step 1: Load the control word to the accumulator to indicate that 8255 is in I/O mode and port A is enabled. Step 2: Send the control word to the control port of 8255. Step 3: Load the accumulator with high value for the bit whose corresponding LED has to glow. For making the left most LED to glow load the accumulator with 80. Step 4: Send the accumulator content to the port A of 8255. Step 5: Call the delay program to have time delay between change in output state. 109

Step 6: Rotate the accumulator content left to right without carry according to the sequence required. DELAY: STEP 1: Load the outer loop count to any register. STEP 2: Load the first inner loop count. STEP 3: Load the second inner loop count. STEP 4: Decrement the second inner loop count. STEP 5: Check for zero. If zero is reached go to next step else go to step 4. STEP 6: Decrement the first inner loop count. STEP 7: Check for zero, if zero is reached go to next step else go to step 3. STEP 8: Decrement the outer loop count. STEP 9: Check for zero. If Zero is set go to next step else go to step 2. STEP 10: Return to main program.

110

FLOW CHART: DELAY:

START

LOAD THE COUNT TO REGISTER PAIR

DECREMENT THE COUNT

CHEC K FOR ZERO

NO

YES
RETURN

111

DISPLAY:
START

LOAD THE NUMBER OF CHARACTERS REQUIRED TO ANY REGISTER.

LOAD THE DISPLAY FIELD ADDRESS TO REGISTER.

HAVE THE FIELD ADDRESS IN ACCUMULATOR AND MOVE IT TO CONTROL REGISTER ADDRESS OF 8279

COPY THE DISPLAY CONTROL WORD FROM MEMORY TO ACCUMULATOR.

MOVE THE DISPLAY CONTROL WORD TO DATA REGISTER ADDRESS OF 8279

INCREMENT THE MEMORY POINTER

DECREMENT THE DISPLAY FIELD ADDRESS AND NUMBER OF CHARACTERS REQUIRED

NO
CHECK FOR ZERO

YES
RETURN

112

CLEAR:

START

LOAD THE NUMBER OF CHARACTERS REQUIRED TO ANY REGISTER.

LOAD THE DISPLAY FIELD ADDRESS TO REGISTER.

HAVE THE FIELD ADDRESS IN ACCUMULATOR AND MOVE IT TO CONTROL REGISTER ADDRESS OF 8279

MOVE IMMEDIATELY THE DISPLAY CONTROL WORD AS FF TO GET OFF STATE

MOVE THE DISPLAY CONTROL WORD TO DATA REGISTER ADDRESS OF 8279

INCREMENT THE MEMORY POINTER

DECREMENT THE DISPLAY FIELD ADDRESS AND NUMBER OF CHARACTERS REQUIRED

CHECK FOR ZERO

NO

YES
RETURN

113

MAIN PROGRAM:

ADDRESS 8000

LABEL

MNEMONICS LXI H, 9100

OPCODE 21 00 91 CD 00 90 CD 00 81 CD 00 92 CD 00 81 C3 00 80

COMMENTS Load the starting address where the message display control words are stored. CALL the subroutine DISPLAY to display the characters. CALL the subroutine DELAY to display the characters for a particular time. CALL the function CLEAR to clear the display. CALL the function DELAY to display blank for particular time. Jump unconditionally to LOOP to have continuous flashing.

LOOP

8003

CALL DISPLAY

8006

CALL DELAY

8009 800C 800E DISPLAY: ADDRESS 9000 LABEL

CALL CLEAR CALL DELAY JMP LOOP

MNEMONICS MVI C, 06

OPCODE 0E 06 06 87 78 D3 D1 7E 114

DISPLAY

9002

MVI B, 87

9004 9005 9007

REPEAT

MOV A, B OUT D1 MOV A, M

COMMENTS Move immediately the count required for number of characters required to C register Move immediately the starting field address of the display device to B register Copy the content of the B register to accumulator. Move the accumulator content to 8279-control register address. Move the display control word stored in memory to

9008 900A 900B 900C 900D 9010

OUT D0 INX H DCR B DCR C JNZ REPEAT RET

D3 D0 23 05 0D C2 04 90 C9

accumulator. Move the content of accumulator to display/keyboard interface data register Increment the memory pointer. Decrement the display field address content. Decrement the count for number of characters required. Check for Zero flag, if is not set goto REPEAT. Return to main function.

CLEAR: ADDRESS 9200 LABEL MNEMONICS MVI C, 06 OPCODE 0E 06 06 87 78 D3 D1 3E FF 115 COMMENTS Move immediately the count required for number of characters required to C register Move immediately the starting field address of the display device to B register Copy the content of the B register to accumulator. Move the accumulator content to 8279-control register address. Move immediately FF to make all the segments

CLEAR

9202

MVI B, 87

9204 9205 9207

REPEAT

MOV A, B OUT D1 MVI A, FF

9209 920B 920C 920D 920E 9211

OUT D0 INX H DCR B DCR C JNZ REPEAT RET

D3 D0 23 05 0D C2 04 92 C9

dark. Move the content of accumulator to display/keyboard interface data register Increment the memory pointer. Decrement the display field address content. Decrement the count for number of characters required. Check for Zero flag, if is not set go REPEAT. Return to main function.

116

Exp.No:7Digital Clock Date: Aim:


To develop an assembly language program to create digital clock display using LED display.

Apparatus Required:
1. 8085 Trainer 2. Operation Code sheet ALGORITHM: STEP 1: Initialize the hour register with 00H. STEP 2: Store the content of hour register to input address of UPDAD FFF7 STEP 3: Call the function UPDAD to display the hour value. 117

STEP 4: Initialize the minute register with 00 H. STEP 5: Store the content of minute register to input address FFF8 of UPDAD. STEP 6: Call the function UPDAD to display the minute value. STEP 7: Initialize the second register as 00 H. STEP 8: Store the content of seconds register to input address FFF9 UPDDT. STEP 9: Call the function UPDDT to display the seconds value. STEP 10: Call the delay subroutine. STEP 11: Increment the content of seconds register. STEP 12: Check if seconds = 60, if yes go to next step else go to step 8 STEP 13: Increment the content of minute register. STEP 14: Check if minute = 60, if yes go to next step else go to step 5. STEP 15: Increment the hours register content. STEP 16: Check if hours = 24. If yes go to next step, else go to 2. STEP 17: Go to step 1.

DELAY: STEP 1: Load the outer loop count to any register. STEP 2: Load the first inner loop count. STEP 3: Load the second inner loop count. STEP 4: Decrement the second inner loop count. STEP 5: Check for zero. If zero is reached go to next step else go to step 4. STEP 6: Decrement the first inner loop count. STEP 7: Check for zero, if zero is reached go to next step else go to step 3. STEP 8: Decrement the outer loop count. STEP 9: Check for zero. If Zero is set go to next step else go to step 2. STEP 10: Return to main program.

118

119

FLOW CHART:

START E

INITIALIZE THE HOUR REGISTER COUNTER WITH 00

D
STORE THE CONTENT OF HOUR REGISTER TO INPUT ADDRESS FFF7 OF UPDAD

CALL THE FUNCTION UPDAD TO DISPLAY THE HOUR

INITIALIZE THE MINUTE REGISTER COUNTER WITH 00 C


STORE THE CONTENT OF MINUTE REGISTER TO THE INPUT ADDRESS FFF8 OF UPDAD CALL THE FUNCTION UPDAD TO DISPLAY THE MINUTE

INITIALIZE THE SECONDS REGESITER COUNT AS 00

B
STORE THE CONTENT OF SECOND REGISTER TO INPUT ADDRESS FFF9 OF UPDDT

CALL THE FUNCTION UPDDT TO DISPLAY THE SECONDS

CALL THE FUNCTION DEALY

120

INCREMENT THE CONTENT OF SECONDS REGISTER

NO
CHEC K FOR 60

B YES

INCREMENT THE CONTENT OF MINUTE COUNT REGISTER

NO
CHEC K FOR 60

YES
INCREMENT THE CONTENT OF HOUR COUNT REGISTER

NO
CHECK FOR 24

YES E

121

ADDRESS 8000 8002 8003 8006 8009 800B 800C 800F 8012 8014 8015 8018 801B 801E

LABEL

MNEMONICS MVI D, 00 MOV A, D STA FFF8 CALL 06BC MVI C, 00

OPCODE 16 00 7A 32 F8 FF CD BC 06 0E 00 79 32 F7 FF CD BC 06 06 00 78 32 F9 FF CD D3 06 CD 00 90 3A F9 FF 122

COMMENTS Clear the D register for having the hour count. Move the hour count to the accumulator. Store the hour value in the input address of UPDAD utility subroutine CALL the function UPDAD to display the hour value. Clear the minute count register C. Copy the minute count to the accumulator. Store the minute value in the input address of UPDAD utility subroutine CALL the function UPDAD to display the minute value. Clear the seconds count register contents. Copy the content of the seconds register to accumulator. Store the seconds value in the input address of UPDDT utility subroutine. CALL the function UPDDT to display the seconds value. CALL the delay function to have a 1 second delay in seconds count. Load the accumulator with the previous count of seconds register.

LOOP 3
LOOP2

LOOP 1

MOV A, C STA FFF7 CALL 06BC MVI B, 00

LOOP

MOV A, B STA FFF9 CALL 06D3 CALL DELAY LDA FFF9

8021

ADI 01

C6 01

Add immediate 01 to accumulator to increment the count.

8023 8024 8025 8027 802A 802D 802F 8030 8031 8033 8036 8039 803B 803C 803D 803F

DAA MOV B, A CPI 60 JNZ LOOP LDA FFF7 ADI 01 DAA MOV C, A CPI 60 JNZ LOOP 1 LDA FFF8 ADI 01 DAA MOV D, A CPI 24 JNZ LOOP 2

27 47 FE 60 C2 14 80 3A F7 FF C6 01 27 4F FE 60 C2 OB 80 3A F8 FF C6 01 27 57 FE 24 C2 123

Decimal adjust the accumulator to convert the count to packed BCD. Copy the accumulator to seconds register. Compare the count with terminal count 60 to start the minutes count. Check for zero flag; if it is not set goto increment the second again If 60 is reached in seconds count, load the previous count of minute to accumulator. Add immediately the content by 01 to increment the minute. Decimal adjust the accumulator to convert the count to packed BCD. Copy the content of minute register to accumulator. Compare it with 60 the terminal count. If 60 is not reached goto LOOP1 seconds initialization step. If 60 is reached in minute count, Load the previous value of hour to accumulator. Add immediately the content by 01 to increment the hour. Decimal adjust the accumulator to convert the count to packed BCD. Copy the content of hour register to accumulator. Compare immediate it with 24 the terminal count. Check for zero flag, if it is not

8042

JMP LOOP

02 80 C3 00 80

set goto minute initialization step. Jump unconditionally to hour initialization step i.e. clear the count and restart the clock.

1 SECOND DELAY:

ADDRESS 9000 9002 9005 9006 9007 9008 900B 900C 900F

LABEL

MNEMONICS MVI D, 02 LXI B, FFFF DCX B MOV A C ORA B JNZ LOOP DCR D JNZ LOOP 1 RET

OPCODE 16 02 01 FF FF 0B 79 B0 C2 05 90 15 C2 02 90 C9

COMMENTS Move the outer count required to the D register. Load the inner loop count to the BC register pair. Decrement the inner loop count. Move the content of C register to accumulator. OR the content of B register with Accumulator content. Check for the Zero flag if it is not set goto LOOP. Decrement the outer loop count. Check for Zero flag, if it is not set goto LOOP 1 (the initialization of inner loop) Return to calling main program.

LOOP 1 LOOP

124

Exp.No:8Counter Date: Aim:


To develop an assembly language program to perform the counter operation.

Apparatus Required:
1. 8085 Trainer 2. Operation Code sheet

125

FLOW CHART:

START

Load the initial count of the counter to the accumulator.

Store the content of accumulator TO INPUT address fff9 of UPDdT.

CALL the function UPDdT to display the count.

CALL the function DELAY to have the required time delay between the counts.

Increment the count i.e. the accumulator content.

check FOR TC

NO

YES

126

DELAY:

START

LOAD THE OUTER LOOP COUNT TO ANY REGISTER

LOAD THE INNER LOOP COUNT TO ANOTHER REGISTER

DECREMENT THE INNER LOOP COUNT

NO

CHECK FORZE RO

YES
DECREMENT THE OUTER LOOP COUNT

CHEC K FOR ZERO

NO

YES
RETURN

127

PROGRAM: MOD 9 COUNTER ADDRESS 8000 8002 8005 8008 800B 800E 8010 8012 8015 LABEL MNEMONICS MVI A, 00 STA FFF9 CALL 06D3 CALL DELAY LDA FFF9 ADI 01 CPI 0A JNZ LOOP JMP LOOP 1 OPCODE 3E 00 32 F9 FF CD D3 06 CD 00 90 3A F9 FF C6 01 FE 0A C2 02 80 C3 00 80 COMMENTS Move immediately the value 00 to accumulator to initialize the count. Store the content of accumulator to input address of UPDDT. CALL the function update data field (UPDDT) to display the count in data field LED. CALL the function delay to have a 1-second delay between the counts. Load the accumulator with previous count value from the memory. Add 01 to the accumulator content. Compare the terminal count 0A with the accumulator content. If the terminal count is not reached continue to display the count. Else, jump unconditionally to LOOP to reinitialize the count

LOOP 1
LOOP

1 SECOND DELAY: ADDRESS 9000 LABEL MNEMONICS MVI D, 02 LXI B FFFF DCX B OPCODE 16 02 01 FF FF 0B 128 COMMENTS Move the outer count required to the D register. Load the inner loop count to the BC register pair. Decrement the inner loop count.

9002 9005

LOOP1

LOOP 9006 9007 9008 900B 900C 900F MOV A C ORA B JNZ LOOP DCR D JNZ LOOP 1 RET 79 B0 C2 05 90 15 C2 02 90 C9 Move the content of C register to accumulator. OR the content of B register with Accumulator content. Check for the Zero flag if it is not set go to LOOP. Decrement the outer loop count. Check for Zero flag, if it is not set go to LOOP 1 (the initialization of inner loop) Return to main program.

Exp.No:9Digital Calculator Date: Aim:


To develop an assembly language program to simulate a digital calculator using 8085 Microprocessor. Apparatus Required: 1. 8085 Trainer 2. Operation Code sheet ALGORITHM: STEP 1: Load the accumulator with the hex equivalent to choose the operation to be performed. STEP 2: Compare whether the loaded value is equivalent to addition operation, is so go to step 4, else go to next step. STEP 3: Compare whether the loaded value is equivalent to subtraction operation, if so go to step 6, else exit the program. STEP 4: Load the numbers to be added into the registers from the memory. 129

STEP 5: Add the two numbers. Convert them into packed BCD and store in the input address of UPDAD & UPDDT and go to step 8 STEP 6: Load the numbers to be added into the registers from the memory. STEP 7: Perform BCD subtraction and store in the input address of UPDAD & UPDDT STEP 8: Call the utility subroutines UPDAD and UPDDT to display the result. STEP 9: Stop execution

130

FLOW CHART:
START

A
Load the accumulator with hex equivalent of the operation to be performed. STORE THE RESULT IN MEMEORY COMPARE THE LOADED VALUE WITH ADDITION EQUIVALENT. MOVE THE STORED RESULTS TO REGISTERS AND STORE THEM TO THE INPUT ADDRESS OF DATA UPDATE AND ADDRESS UPDATE SUBROUTINES YES CHECK FOR ZERO CALL THE UPDAD AND NO UPDDT SUBROUTINES TO DISPLAY THE VALUES. COMPARE THE LOADED VALUE WITH SUBTRACTION EQUIVALENT. STOP

YES
CHECK FOR ZERO

NO
PERFORM THE BCD ADDITION OF ENTERED NUMBERS WITH CARRY

STORE THE RESULTS IN MEMORY TO BE DISPLAYED IN LED DISPLAY.

PERFORM THE BCD SUBTRACTION OF ENTERED NUMBERS WITH CARRY

131

PROGRAM: ADDRESS 8000 8003 8005 8008 800A 800D 8010 8012 8015 8016 8019 801B 801C 801D 8020 LABEL MNEMONIC LDA 9000 CPI 0B JZ ADD CPI 0C JZ SUB JMP END MVI A, 00 LDA 9100 MOV B, A LDA 9101 MVI C, 00 ADD B DAA JNC LOOP 1 INR C OPCODE 3A 00 90 FE 0B CA 10 80 FE 0C CA 2B 80 C3 69 80 3E 00 3A 00 91 47 3A 01 91 0E 00 80 27 D2 21 80 0C COMMENTS Load the accumulator with hex equivalent to choose the operation to be performed. Compare whether the loaded value is equivalent to that of addition operation. Check for zero flag, if it is set goto loop ADD to perform addition. Compare whether the loaded value is equivalent to that of subtraction operation. Check for zero flag, if it is set goto loop SUB to perform subtraction. If no related hex equivalent is loaded jump unconditionally to END. Clear the content of accumulator to load the numbers Load the first number to be added from memory to accumulator. Copy the number to B register Load the second number to be added from memory to accumulator. Clear the content of C register to hold the carry. Add the numbers. Decimal adjust the accumulator to convert the answer into packed BCD. Check for the carry flag, if it is not set goto LOOP 1. Else increment the content of C register to hold the carry.

ADD

132

ADDRESS 8021 8024 8025 8028 802B 802D 802F 8032 8033 8036 8037 8039 803A 803D 803E 803F 8042

LABEL

MNEMONIC STA 9102 MOV A, C STA 9103 JMP DISPLAY MVI A, 00 MVI D, 00 LDA 9100 MOV C, A LDA 9101 MOV B, A MVI A, 99 SUB B ADI 01 ADD C DAA JC OUT 1 MOV B, A

OPCODE 32 02 91 79 32 03 91 C3 52 80 3E 00 16 00 3A 00 91 4F 3A 01 91 47 3E 99 90 C6 01 81 27 DA 4B 80 47 133

COMMENTS
Store the result of addition to the memory Copy the content of carry register to accumulator. Store the carry in memory. Jump unconditionally to DISPLAY to display the result. Clear the content of accumulator to load the values. Clear the D register to hold the borrow value. Load the minuend into the accumulator from the memory. Copy the minuend accumulator to C register. Load the subtrahend into the accumulator from memory. Copy the subtrahend value to B register. Move immediately 99 to accumulator to perform 99s complement. Subtract the subtrahend value from 99. Add 01 to the subtracted value to obtain 100s complement. Add the minuend value to the 100s complement value. Decimal adjust the accumulator to obtain packed BCD of the resultant. Check for the carry (borrow). If it is set go to loop OUT 1. Copy the content of accumulator to B register.

LOOP 1

SUB

ADDRESS 8043 8045 8046 8048 8049 804B 804E 804F 8052 8055 8058 805B 805E 8061 8063

LABEL

MNEMONIC MVI A, 99 SUB B ADI 01 DAA MVI D, 01 STA 9102 MOV A, D STA 9104 LDA 9102 STA FFF9 CALL 06D3 LDA 9103 STA FFF7 MVI A, 00 STA FFF8

OPCODE 3E 99 90 C6 01 27 16 01 32 02 91 7A 32 03 91 3A 02 91 32 F9 FF CD D3 06 3A 03 91 32 F7 FF 3E 00 32 F8 FF

COMMENTS Move immediately 99 to accumulator to perform 99s complement. Subtract the subtrahend value from 99. Add 01 to the subtracted value to obtain 100s complement Decimal adjust the accumulator to obtain packed BCD of the resultant. Move immediately 01 to D register to indicate borrow. Store the subtracted value to memory. Move the borrow value to accumulator. Store the carry (borrow) to the memory. Load the accumulator with the stored value of resultant of operation performed. Store the resultant in the input address location of UPDDT utility subroutine. CALL the function UPDDT to display the result in data field LED. Load the accumulator with the stored value of carry of operation performed. Store the carry to the input address of UPDAD utility subroutine. Clear the accumulator content. Store the accumulator content to the input address of UPDAD utility subroutine..

OUT 1

DISPLAY

8066

CALL 06BC

CD 134

CALL the function UPDAD

BC 06 8069 HLT 76

to display the result in the address field LEDs. Stop execution.

Exp.No:10Square Wave Generation


135

Date: Aim:
To develop an assembly language program to produce a square wave output using Output lines of 8255 SOD lines of 8085 microprocessor. . 1. 8085 Trainer 2. Operation Code sheet ALGORITHM: USING 8255 Step 1: Load the appropriate control word to accumulator and more it to control part of 8255 Step 2: Load the appropriate control word to the generating logical high in accumulator. Step 3: Move the content the accumulator to output port of 8255. Step 4: Call the delay sub routine to generate a time delay between different states. Step 5: Complement accumulator content to get logical LOW. Step 6: Go to step 3. USING 8085 SOD LINES Step 1: Load the appropriate control word to the accumulator having HIGH values for SOD. Step 2: Using SIM instruction, move the control word to output line of 8085. Step 3: Call the delay subroutine to generate time delay between states. Step 4: Load the control word to accumulator for having low values for SOD. Step 5: Calculate the delay subroutine to generate time delay between states. Step 6: Go to step 1. DELAY 136

Apparatus Required:

Step 1: Load the outer loop count to any register. Step 2: Load the first inner loop count. Step 3: Load the second inner loop count. Step 4: Decrement the second inner loop count. Step 5: Check for zero. If zero is set, go to next step. Else, goto step 3. Step 6: Decrement the outer loop count. Step 7: Check for zero. If zero is set, go to next step. Else, goto step 2. Step 8: Return to main program.

FLOW CHART: 137

USING 8255:

START

LOAD THE CONTROL WORD TO THE ACCUMULATOR AND MOVE IT TO CONTROLPORT OF 8255

LOAD THE INITIAL CONTROL WORD TO GENERATE LOGICAL HIGH IN THE ACCUMULATOR

MOVE THE CONTENT OF ACCUMULATOR TO ANY OUTPUTPORT OF 8255

CALL THE FUNCTION DELAY

COMPLEMENT THE CONTENT OF ACCUMULATOR TO CHANGE THE STATE OF OUTPUT

138

USING 8085 SOD LINES:

START

LOAD THE CONTROL WORD TO THE ACCUMULATOR HAVING HIGH VALUE FOR SOD

USE THE SIM INSTRUCTION TO MOVE THE ACCUMULATOR CONTENT TO OUTPUTPORT OF 8085

CALL THE FUNCTION DELAY

LOAD THE CONTROL WORD TO THE ACCUMULATOR HAVING LOW VALUE FOR SOD

CALL THE FUNCTION DELAY

139

DELAY:
START

LOAD THE OUTER LOOP COUNT TO ANY REGISTER

LOAD THE INNER LOOP 1 COUNT

LOAD THE INNER LOOP 2 COUNT

DECREMENT THE INNER LOOP 2 COUNT

CHEC K FOR ZERO

NO

YES
DECREMENT THE INNER LOOP 1 COUNT

CHEC K FOR ZERO

NO

YES
DECREMENT THE OUTER LOOP COUNT

NO

CHEC K FOR ZERO

YES
RETURN

SQUARE WAVE GENERATION 140

PROGRAM: USING 8255 PORTS ADDRESS 8000 8002 8004 8006 8008 800B 800C LABEL MNEMONICS MVI A, 80 OUT F3 MVI A, FF OUT F0 CALL DELAY CMA JMP LOOP ODCODE 3E 80 C3 F3 3E FF D3 F0 CD 00 90 2F C3 06 80 COMMENTS Move the control word immediately to the accumulator to indicate 8255 is in I/O mode. Move the control word to the control port . Move FF immediately to the accumulator to activate all the lines of the selected port of 8255. Move the accumulator content to port A of 8255. CALL the delay program to generate a pulse of required width. Complement the accumulator content to change the output state. Jump unconditionally to obtain continuous square waveform.

LOOP

USING SOD LINES OF 8085 ADDRESS 8000 8002 8003 8006 8008 8009 LABEL MNEMONICS OPCODE MVI A, C0 SIM CALL DELAY MVI A, 40 SIM CALL DELAY 3E C0 30 CD 00 90 3E 40 30 CD 00 90 141 COMMENTS Move the control word immediately to the accumulator to enable a high output from the serial output data pin of 8085. Invoke the SIM instruction to have a high output at SOD. CALL the delay program to generate the pulse of required width. Move the control word immediately to the accumulator to enable a low output from the serial output data pin of 8085. Invoke the SIM instruction to have a low output at SOD. CALL the delay program to generate the time interval of required width.

LOOP

800C 10 ms DELAY: ADDRESS 9000 9002 9004 9005 9008 9009 900C LABEL

JMP LOOP

C3 00 80

Jump unconditionally to obtain a continuous square waveform.

MNEMONICS MVI E, 0A MVI C, FF DCR C JNZ LOOP DCR E JNZ LOOP1 RET

OPCODE 1E 0A 0E FF 0D C2 04 90 1D C2 09 90 C9

COMMENTS Move immediately the outer loop count 0A to the E register. Move immediately the inner loop count FF to the C register. Decrement the inner loop count i.e. C register content. Check for Zero flag, if it is not set goto Loop. Otherwise goto next step. Decrement the outer loop count i.e. the E register content. Check for Zero flag, if it is not set goto LOOP1. Otherwise goto next step. Return to the main function.

LOOP1 LOOP

Exp.No:11 Traffic Light interface


142

Date: Aim:
To develop an assembly language program for traffic light control using programmable peripheral interface 8255.

Apparatus Required:
1. 8085 Trainer 2. Operation Code sheet

ALGORITHM: MAIN PROGRAM STEP 1: Load the control word to accumulator, to indicate that the 8255 is in I/O mode. STEP 2: Send the control word to the control port of 8255. STEP 3: Call the subroutine NORTH. STEP 4: Call the subroutine EAST. STEP 5: Call the subroutine SOUTH. STEP 6: Call the subroutine WEST. STEP 7: Repeat the steps from step 3 to step 6 to control the signal. SUB- ROUTINES NORTH: STEP 1: Get the output control word for the schedule I of traffic lights. STEP 2: Move the control word to the output port of the 8255. STEP 3: Call delay program for 3 sec to change from amber to red and amber to green. STEP 4: Get the output control word for the schedule II and move to the output port of the 8255. STEP 5: Call the delay subroutine for generating a time delay of 30 sec between the schedules. STEP 6: Return to main program. EAST: 143

STEP 1: Get the output control word for the schedule III of traffic lights. STEP 2: Move the control word to the output port of the 8255. STEP 3: Call delay program for 3 sec to change from amber to red and amber to green. STEP 4: Get the output control word for the schedule IV and move to the output port of the 8255. STEP 5: Call the delay subroutine for generating a time delay of 30 sec between the schedules. STEP 6: Return to main program. SOUTH: STEP 1: Get the output control word for the schedule V of traffic lights. STEP 2: Move the control word to the output port of the 8255. STEP 3: Call delay program for 3 sec to change from amber to red and amber to green. STEP 4: Get the output control word for the schedule VI and move to the output port of the 8255. STEP 5: Call the delay subroutine for generating a time delay of 30 sec between the schedules. STEP 6: Return to main program. WEST: STEP 1: Get the output control word for the schedule VII of traffic lights. STEP 2: Move the control word to the output port of the 8255. STEP 3: Call delay program for 3 sec to change from amber to red and amber to green. STEP 4: Get the output control word for the schedule VIII and move to the output port of the 8255. STEP 5: Call the delay subroutine for generating a time delay of 30 sec between the schedules. STEP 6: Return to main program.

FLOW CHART: 144

MAIN PROGRAM:

START

CALL SUBROUTINE NORTH

CALL SUBROUTINE EAST

CALL SUBROUTINE SOUTH

CALL SUBROUTINE WEST

145

SUB-ROUTEINS:

NORT H OUTPUT THE CODE FOR SCHEDULE I

EAST

OUTPUT THE CODE FOR SCHEDULE III

CALL DELAY I

CALL DELAY 1

OUTPUT THE CODE FOR SCHEDULE II

OUTPUT THE CODE FOR SCHEDULE IV

CALL DELAY 2

CALL DELAY 2

RETURN

RETURN

146

SOUTH

WEST

OUTPUT THE CODE FOR SCHEDULE V

OUTPUT THE CODE FOR SCHEDULE VII

CALL DELAY I

CALL DELAY I

OUTPUT THE CODE FOR SCHEDULE VI

OUTPUT THE CODE FOR SCHEDULE VIII

CALL DELAY 2

CALL DELAY 2

RETURN RETURN SHEDULE FOR TRAFFIC LIGHT SWITCHING

ON/OFF STATUS OF TRAFFIC LIGHT


SCHEDULE I II III IV V VI VII VIII PB3 WG 0 0 0 0 0 0 0 1 PB2 WY 1 0 0 0 0 0 1 0 PB1 WR 0 1 1 1 1 1 0 0 PB0 SG 0 0 0 0 0 1 0 0 PA7 SY 0 0 0 0 1 0 1 0 PA6 SR 1 1 1 1 0 0 0 1 PA5 EG 0 0 0 1 0 0 0 0 PA4 EY 0 0 1 0 1 0 0 0 PA3 ER 1 1 0 0 0 1 1 1 PA2 NG 0 1 0 0 0 0 0 0 PA1 NY 1 0 1 0 0 0 0 0 PA0 NR 0 0 0 1 1 1 1 1

CONTROL WORD
PORT A 4A 4C 52 61 91 09 89 49 PORT B 04 02 02 02 02 03 04 08

MAIN PROGRAM:

147

ADDRESS

LABEL

MNEMONICS MVI A, 80 OUT F3

OPCODE 3E 80 D3 F3 CD 30 80 CD 50 80 CD 70 80 CD 90 80 C3 04 80

COMMENTS Move the control word immediately to the accumulator to indicate 8255 is in I/O mode. Send the control word through port A. Call the subroutine for North direction. Call the subroutine for East direction. Call the subroutine for South direction. Call the subroutine for West direction. Repeat the subroutine calls unconditionally.

8000 8002 8004 8007 800A 800D 8010


LOOP

CALL NORTH CALL EAST CALL SOUTH CALL WEST JMP LOOP

NORTH:

ADDRESS

LABEL

MNEMONICS

OPCODE

COMMENTS

148

8030 8032 8034 8036 8038 803B 803D 803F 8041 8043 8046

MVI A, 4A OUT F0 MVI A, 04 OUT F1 CALL DELAY 1 MVI A, 4C OUT F0 MVI A, 02 OUT F1 CALL DELAY 2 RET

3E 4A D3 F0 3E 04 D3 F1 CD 00 90 3E 4C D3 F0 3E 02 D3 F1 CD 50 90 C9

Move the appropriate control word to accumulator. Send the control word through port A. Move the appropriate control word to accumulator Send the control word through port B. Call the 3 sec delay for Amber light control. Move the appropriate control word to accumulator. Send the control word through port A. Move the control word to accumulator. Send the control word through port B. Call the 30 sec delay for green signal control. Return to main program.

EAST: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

149

8050 8052 8054 8056 8058 805B 805D 805F 8061 8063 8066

MVI A, 52 OUT F0 MVI A, 02 OUT YY CALL DELAY1 MVI A, 61 OUT F0 MVI A, 02 OUT F1 CALL DELAY 2 RET

3E 52 D3 F0 3E 02 D3 F1 CD 00 90 3E 61 D3 F0 3E 02 D3 F1 CD 50 90 C9

Move the appropriate control word to accumulator. Send the control word through port A. Move the appropriate control word to accumulator Send the control word through port B. Call the 3 sec delay for Amber light control. Move the appropriate control word to accumulator. Send the control word through port A. Move the control word to accumulator. Send the control word through port B. Call the 30 sec delay for green signal control. Return to main program.

WEST:

150

ADDRESS

LABEL

MNEMONICS MVI A, 89 OUT F0 MVI A, 04 OUT F1 CALL DELAY 1 MVI A, 49 OUT F0 MVI A, 08 OUT F1 CALL DELAY 2 RET

OPCODE 3E 89 D3 F0 3E 04 D3 F1 CD 00 90 3E 49 D3 F0 3E 08 D3 F1 CD 50 90 C9

COMMENTS Move the appropriate control word to accumulator. Send the control word through port A. Move the appropriate control word to accumulator Send the control word through port B. Call the 3 sec delay for Amber light control. Move the appropriate control word to accumulator. Send the control word through port A. Move the control word to accumulator. Send the control word through port B. Call the 30 sec delay for green signal control. Return to main program.

8090 8092 8094 8096 8098 809B 809D 809F 80A1 80A3 80A6

SOUTH: ADDRESS LABEL MNEMONICS OPCODE 151 COMMENTS

8070 8072 8074 8076 8078 807B 807D 807F 8081 8083 8086

MVI A, 89 OUT F0 MVI A, 02 OUT F1 CALL DELAY 1 MVI A, 09 OUT F0 MVI A, 03 OUT F1 CALL DELAY 2 RET

3E 91 D3 F0 3E 02 D3 F1 CD 00 90 3E 09 D3 F0 3E 03 D3 F1 CD 50 90 C9

Move the appropriate control word to accumulator. Send the control word through port A. Move the appropriate control word to accumulator Send the control word through port B. Call the 3 sec delay for Amber light control. Move the appropriate control word to accumulator. Send the control word through port A. Move the control word to accumulator. Send the control word through port B. Call the 30 sec delay for green signal control. Return to main program.

DELAY PROGRAM FOR 3 SECONDS

152

ADDRESS

LABEL

MNEMONICS

OPCODE

COMMENTS

9000 9002 9004 9006 9008 9009 900C 900D 9010 9011 9014 9015 9018 LOOP3 LOOP2 LOOP1 LOOP

MVI H, 03 MVI C, 03 MVI D, FF MVI E, FF DCR E JNZ LOOP DCR D JNZ LOOP1 DCR C JNZ LOOP 2 DCR H JNZ LOOP 3 RET

26 03 0E 03 16 FF 1E FF 1D C2 08 90 15 C2 06 90 0D C2 04 90 25 C2 02 90 C9

Initialize counter value to 03 H Initialize counter value to 03 H Load FF H to D register immediately. Load FF H to E register immediately. Decrement counter E by 1. Move to next counter if count is zero. Decrement counter D by 1 Jump to counter E if count not zero. Decrement counter C by 1. Jump to counter D if count not zero. Decrement counter H by 1. Jump to LOOP 3 if count not zero. Return to main program.

DELAY PROGRAM FOR 30 SECONDS

153

ADDRESS

LABLE

MNEMOCIS

OPCODE

COMMENTS

9050 9052 9054 9056 9058 9059 905C 905D 9060 9061 9064 9065 9068 LOOP3 LOOP2 LOOP1 LOOP

MVI H, 1E MVI C, 03 MVI D, FF MVI E, FF DCR E JNZ LOOP DCR D JNZ LOOP 1 DCR C JNZ LOOP 2 DCR H JNZ LOOP 3 RET

26 1E 0E 03 16 FF 1E FF 1D C2 58 90 15 C2 56 90 0D C2 54 90 25 C2 52 90 C9

Initialize counter value to 1E H Initialize counter value to 03 H Load FF H to D register immediately. Load FF H to E register immediately. Decrement counter E by 1. Move to next counter if count is zero. Decrement counter D by 1 Jump to counter E if count not zero. Decrement counter C by 1. Jump to counter D if count not zero. Decrement counter H by 1. Jump to counter C if count not zero. Return to main program.

Exp.No:12Stepper Motor Interface Date:

154

Aim:
To interface a stepper motor with the 8085 microprocessor to control the speed using the programmable peripheral interface 8255.

Apparatus Required:
1. 8085 Trainer 2. Operation Code sheet ALGORITHM: CLOCKWISE ROTATION: STEP 1: Load the control word to accumulator and move it to the control port of 8255 to operate in I/O mode. STEP 2: Load the initial excitation word to accumulator. STEP 3: Move the accumulator content to the output lines of 8255. STEP 4: Call the delay function. STEP 5: Rotate the accumulator right to excite the next pair of coils in clockwise direction. STEP 6: Go to step 3. ANTICLOCKWISE ROTATION: STEP 1: Load the control word to accumulator and move it to the control port of 8255 to operate in I/O mode. STEP 2: Load the initial excitation word to accumulator. STEP 3: Move the accumulator content to the output lines of 8255. STEP 4: Call the delay function. STEP 5: Rotate the accumulator left to excite the next pair of coils in clockwise direction. STEP 6: Go to step 3.

DELAY: STEP 1: Load the outer loop count to any register. STEP 2: Load the first inner loop count. 155

STEP 3: Load the second inner loop count. STEP 4: Decrement the second inner loop count. STEP 5: Check for zero. If zero is reached go to next step else go to step 4. STEP 6: Decrement the first inner loop count. STEP 7: Check for zero, if zero is reached go to next step else go to step 3. STEP 8: Decrement the outer loop count. STEP 9: Check for zero. If Zero is set go to next step else go to step 2. STEP 10: Return to main program.

FLOW CHART: CLOCKWISE ROTATION:

156

START

LOAD THE CONTROL WORD TO THE ACCUMULATOR AND MOVE IT TO CONTROL PORT OF 8255

LOAD THE INITIAL EXCITATION WORD TO THE ACCUMULATOR

MOVE THE CONTENT OF ACCUMULATOR TO OUTPUT PORT OF 8255

CALL THE FUNCTION DELAY

ROTATE THE ACCUMULATOR RIGHT TO EXCITE NEXT PAIR OF COILS IN CLOCKWISE DIRECTION.

ANTI-CLOCKWISE ROTATION:

157

START

LOAD THE CONTROL WORD TO THE ACCUMULATOR AND MOVE IT TO CONTROL PORT OF 8255

LOAD THE INITIAL EXCITATION WORD TO THE ACCUMULATOR

MOVE THE CONTENT OF ACCUMULATOR TO OUTPUT PORT ADDRESS OF 8255

CALL THE FUNCTION DELAY

ROTATE THE ACCUMULATOR LEFT TO EXCITE NEXT PAIR OF COILS IN ANTICLOCKWISE DIRECTION.

DELAY:

158

START

LOAD THE OUTER LOOP COUNT TO ANY REGISTER

LOAD THE INNER LOOP 1 COUNT TO A REGISTER

LOAD THE INNER LOOP 2 COUNT TO A REGISTER

DECREMENT THE INNER LOOP 2 COUNT

CHEC K FOR ZERO

NO

YES
DECREMENT THE INNER LOOP 1 COUNT

CHEC K FOR ZERO

NO

YES
DECREMENT THE OUTER LOOP COUNT

NO

CHEC K FOR ZERO

YES
RETURN

PROGRAM: 159

CLOCKWISE ROTATION ADDRESS 8000 8002 8004 LABEL MNEMONICS MVI A, 80 OUT F3 MVI A, 88 OPCODE 3E 80 D3 F3 3E 88 D3 F0 CD 00 90 0F C3 06 86 COMMENTS Move the control word immediately to the accumulator to indicate 8255 is in I/O mode. Move the accumulator content to the control port. Move 88 immediately to the accumulator to activate A and A poles of the motor through 8255 selected port. Move the accumulator content to port A of 8255. CALL the delay program to generate time delay before the excitation of next pair of coils Rotate accumulator content right without carry to excite next pair of coils. Jump unconditionally to obtain continuous rotation.

8006 8008 800B 800C

LOOP

OUT F0 CALL DELAY RRC JMP LOOP

ANTI-CLOCKWISE ROTATION 160

ADDRESS 8000 8002 8004

LABEL

MNEMONICS MVI A, 80 OUT F3 MVI A, 88

OPCODE 3E 80 D3 F3 3E 88 D3 F0 CD 00 90 0F C3 06 86

COMMENTS Move the control word immediately to the accumulator to indicate 8255 is in I/O mode. Move the control word to the control port . Move 88 immediately to the accumulator to activate A and A poles of the motor through 8255 selected port. Move the accumulator content to port A of 8255. CALL the delay program to generate time delay before excitation of next pair of coils. Rotate accumulator content left without carry to excite next pair of coils. Jump unconditionally to obtain continues rotation.

8006 8008 800B 800C DELAY: ADDRESS 9000 9002 9004 9005 9008 9009

LOOP

OUT F0 CALL DELAY RLC JMP LOOP

LABEL

MNEMONICS MVI E, 0A MVI C, FF DCR C JNZ LOOP DCR E JNZ LOOP1

OPCODE 1E 0A 0E FF 0D C2 04 90 1D C2 161

COMMENTS Move immediately the outer loop count 0A to the E register. Move immediately the inner loop count FF to the C register. Decrement the inner loop count i.e. C register content. Check for Zero flag, if it is not set goto Loop. Decrement the outer loop count i.e. the E register content. Check for Zero flag, if it is

LOOP1 LOOP

09 90 900C RET C9

not set goto LOOP1. Return to the main function.

Exp.No:13ADC/DAC Interface
162

Date: Aim:
To interface a digital to analog converter (DAC) to 8085 microprocessor using programmable peripheral interface 8255 to create Square Waveform. Trapezoidal Waveform. Saw tooth Waveform.

Apparatus Required:
1. 8085 Trainer 2. Operation Code sheet ALGORITHM: SQUARE WAVEFORM: STEP 1: Move the control word to the control port to operate 8255 in I/O to the accumulator. STEP 2: Send the accumulator content to the port of 8255. STEP 3: Load the binary value corresponding to the maximum digital input to the accumulator. STEP 4: Send the accumulator content to the port of 8255. STEP 5: Call the delay program to generate time delay between states. STEP 6: Complement the accumulator content to change the output state. STEP 7: Go to step 4. SAW TOOTH WAVEFORM: STEP 1: Load the control word to the control port of 8255 to operate in I/O mode. STEP 2: Load 00 and move to output lines of 8255. STEP 3: Move the content of accumulator to output port of 8255. STEP 4: Increment the digital input value, i.e., the accumulator content till it becomes FF. STEP 5: Compare with FF. Check for zero, if yes go to step 2 else step 3. TRAPEZOIDAL WAVEFORM: 163

STEP 1: Load the control word to accumulator and move to control port of 8255. STEP 2: Move the initial digital to the accumulator and out to output port of 8255. STEP 3: Increment the digital input value and move to output line of 8255. STEP 4: Compare the digital input with FF. Check for zero, if zero is set go to next step, else go to step 3. STEP 5: Call delay to generate a constant output of required width. STEP 6: Decrement the digital input value. STEP 7: Move the value to the output line of 8255. STEP 8: Check for zero, if zero is set go to step 2, else go to step 6. DELAY: STEP 1: Load the outer loop count to any register. STEP 2: Load the first inner loop count. STEP 3: Load the second inner loop count. STEP 4: Decrement the second inner loop count. STEP 5: Check for zero. If zero is reached go to next step else go to step 4. STEP 6: Decrement the first inner loop count. STEP 7: Check for zero, if zero is reached go to next step else go to step 3. STEP 8: Decrement the outer loop count. STEP 9: Check for zero. If Zero is set go to next step else go to step 2. STEP 10: Return to main program.

FLOW CHART: 164

SQUARE WAVE GENERATION:

START

LOAD THE CONTROL WORD TO THE ACCUMULATOR AND MOVE IT TO CONTROL PORT OF 8255

LOAD THE BINARY VALUE CORRESPONDING TO THE MAXIMUM DIGITAL INPUT TO THE ACCMULATOR

MOVE THE CONTENT OF ACCUMULATOR TO ANY OUTPUT PORT OF 8255

CALL THE FUNCTION DELAY

COMPLEMENT THE CONTENT OF ACCUMULATOR TH SWITCH BETWEEN HIGH AND LOW STATES OF OUTPUT WAVEFORM

SAW TOOTH: 165

START

LOAD THE CONTROL WORD TO THE ACCUMULATOR AND MOVE IT TO CONTROL PORT OF 8255

LOAD 00 TO the accumulator to RESET all the lines of 8255-SELECTED port.

MOVE THE CONTENT OF ACCUMULATOR TO ANY OUTPUT PORT ADDRESS OF 8255

INCREMENT THE DIGITAL INPUT VALUE. i.e. THE ACCUMULATOR CONTENT TILL IT BECOMES 00

CHEC K FOR ZERO

NO

YES

166

TRAPEZOIDAL:
START

LOAD THE CONTROL WORD TO THE ACCUMULATOR AND MOVE IT TO CONTROL PORT OF 8255

START

MOVE THE INITIAL DIGITAL VALUE TO ACCUMULATOR AND OUT THE CONTENT OF ACCUMULATOR TO OUTPUT PORT OF 8255

INCREMENT THE DIGITAL VALUE INPUT. i.e. THE ACCUMULATOR CONTENT.

MOVE THE CORRESPONDING DIGITAL VALUE IN THE ACCUMULATOR TO THE OUTPUT PORT OF 8255

COMPARE THE INPUT DIGITAL VALUE WITH LARGEST POSIBLE DIGITAL VALUE. i.e. FF

NO
CHEC K FOR ZERO

YES
CALL DELAY TO GENERATE A CONSTANT OUTPUT OF REQUIRED WIDTH.

DECREMENT THE DIGITAL INPUT VALUE TO GENERATE DECRESING SLOPE.

MOVE THE DIGITAL INPUT VALUE i.e. CONTENT OF ACCUMULATOR TO ANY OUTPUT PORT ADDRESS OF 8255

Delay:
YES
CHEC K FOR ZERO

167 NO

LOAD THE OUTER LOOP COUNT TO ANY REGISTER

LOAD THE INNER LOOP COUNT

DECREMENT THE INNER LOOP COUNT

NO
CHEC K FOR ZERO

YES
DECREMENT THE OUTER LOOP COUNT

NO

CHEC K FOR ZERO

YES
RETURN

PROGRAM: 168

SQUARE WAVE GENERATION ADDRESS LABEL MNEMONICS MVI A, 80 OUT F3 MVI A, FF OPCODE 3E 80 D3 F3 3E FF D3 F0 CD 00 90 2F C3 06 80 COMMENTS Move the control word immediately to the accumulator to indicate 8255 is in I/O mode. Move the control word to the control port of 8255. Move FF immediately to the accumulator to activate all the lines of selected port of 8255. Move the accumulator content to port A address of 8255. CALL the delay program to have the pulse of required width. Complement the accumulator content to change the output state. Jump unconditionally to LOOP to obtain continuous square waveform.

8000 8002 8004

8006 8008 800B 800C

LOOP

OUT F0 CALL DELAY CMA JMP LOOP

10 ms DELAY: ADDRESS 9000 9002 9004 9005 9008 LABEL MNEMONICS MVI E, 0A MVI C, FF DCR C JNZ LOOP DCR E OPCODE 1E 0A 0E FF 0D C2 04 90 1D 169 COMMENTS Move immediately the outer loop count 0A to the E register. Move immediately the inner loop count FF to the C register. Decrement the inner loop count i.e. C register content. Check for Zero flag, if it is not set goto Loop. Decrement the outer loop count i.e. the E register content.

LOOP1
LOOP

9009 900C

JNZ LOOP1 RET

C2 09 90 C9

Check for Zero flag, if it is not set goto LOOP1. Return to the main function.

SAW TOOTH WAVEFORM GENERATION ADDRESS 8000 8002 8004 8006 8008 8009 800C LABEL MNEMONICS MVI A, 80 OUT F3 MVI A, 00 OUT F0 INR A JNZ LOOP JMP LOOP1 OPCODE 3E 80 D3 F3 3E 00 D3 F0 3C C2 06 80 C3 04 80 COMMENTS Move the control word immediately to the accumulator to indicate 8255 is in I/O mode. Move the control word to the control port. Move 00 immediately to the accumulator to have low value at all the lines of 8255 selected port. Move the accumulator content to port A of 8255. Increment the content of accumulator. Check for Zero flag, if is set goto LOOP otherwise goto next instruction. Jump unconditionally to LOOP 1 to obtain continues waveform.

LOOP 1
LOOP

TRAPEZOIDAL WAVEFORM GENERATION 170

ADDRESS 8000 8002 8004 8006 8008 8009 800B

LABEL

MNEMONICS MVI A, 80 OUT F3 MVI A, 00 OUT F0

OPCODE 3E 80 D3 F3 3E 00 D3 F0 3C D3 F0 FE FF C2 08 80 CD 00 90 3D D3 F0 C2 13 80 C3 04 80

COMMENTS Move the control word immediately to the accumulator to indicate 8255 is in I/O mode. Move the control word to the control port. Move 00 immediately to the accumulator to have low value at all the lines of 8255 selected port. Move the accumulator content to port A of 8255. Increment the content of accumulator to have the increasing slope. Move the accumulator content to port A of 8255. Compare immediate the content of accumulator with the highest output voltage digital equivalent i.e. FF Check for Zero flag, if is set goto LOOP 1, otherwise goto next instruction CALL the delay to have the required width of the waveform. Decrement the accumulator content to have the decreasing slope of waveform Move the accumulator content to port A of 8255. Check for Zero flag, if is set goto LOOP 2. Jump unconditionally to LOOP 1 to obtain continuous waveform.

LOOP

LOOP 1

INR A OUT F0 CPI FF

800D 8010

JNZ LOOP 1 CALL DELAY

8013 8014 8016 8019

LOOP 2

DCR A OUT F0 JNZ LOOP 2 JMP LOOP

171

Exp.No:14Seven Segment Display


172

Date: Aim:
To interface a seven segment LED to display a MOD 9 counter using 8085 Microprocessor.

Apparatus Required:
1. 8085 Trainer 2. Operation Code sheet

ALGORITHM: MAIN PROGRAM: STEP 1: Load the control word to the accumulator and move it to control port of 8255. STEP 2: More the value of initial count to accumulator and send to output port of 8255. STEP 3: Call delay subroutine to have a time delay between counts. STEP 4: Increment the count value. STEP 5: Compare the count value with the terminal count. STEP 6: Check for zero, if zero is reached go to step 2, else go to step 4. DELAY: STEP 1: Load the outer loop count to any register. STEP 2: Load the first inner loop count. STEP 3: Load the second inner loop count. STEP 4: Decrement the second inner loop count. STEP 5: Check for zero. If zero is reached go to next step else go to step 4. STEP 6: Decrement the first inner loop count. STEP 7: Check for zero, if zero is reached go to next step else go to step 3. STEP 8: Decrement the outer loop count. STEP 9: Check for zero. If Zero is set go to next step else go to step 2. STEP 10: Return to main program.

173

FLOW CHART:

START

LOAD THE CONTROL WORD TO THE ACCUMULATOR AND MOVE IT TO CONTROLPORT OF 8255

MOVE THE INITIAL COUNT TO ACCUMULATOR

MOVE THE CONTENT OF ACCUMULATOR TO OUTPUTPORT OF 8255

CALL DELAY TO HAVE TIME DELAY BETWEEN COUNTS.

INCREMENT THE COUNT

COMPARE THE COUNT VALUE WITH THE TERMINAL COUNT.

YES
CHEC K FOR ZERO

NO

174

START

LOAD THE OUTER LOOP COUNT TO ANY REGISTER

LOAD THE INNER LOOP 1 COUNT TO A REGISTER

LOAD THE INNER LOOP 2 COUNT TO A REGISTER

DECREMENT THE INNER LOOP 2 COUNT

CHEC K FOR ZERO

NO

YES
DECREMENT THE INNER LOOP 1 COUNT

CHEC K FOR ZERO

NO

YES
DECREMENT THE OUTER LOOP COUNT

NO

CHEC K FOR ZERO

YES
RETURN

175

PROGRAM: ADDRESS 8000 8002 8004 LABEL MNEMONICS MVI A, 80 OUT F3 MVI A, 00 OPCODE 3E 80 D3 F3 3E 00 D3 F0 CD 00 90 C6 01 27 FE 0A C2 06 80 C3 04 80 COMMENTS Move the control word immediately to the accumulator to indicate 8255 is in I/O mode. Move the control word to the control port. Clear the accumulator to start count from initial value. Move the accumulator content to port A of 8255. CALL the DELAY program to have a time delay between each display. Increment the count Decimal adjust the accumulator to have packed BCD output Compare with the terminal count. Check for zero flag, if it is not set display the corresponding BCD number. Jump unconditionally to LOOP 1 to initialize the count again.

LOOP 1 LOOP

8006

OUT F0

8008 800B 800D 800E 8010

CALL DELAY ADI 01 DAA CPI 0A JNZ LOOP

8013

JMP LOOP1

176

1 SECOND DELAY:

ADDRESS 9000 9002 9004 9005 9008 9009 900C

LABEL

MNEMONICS MVI E, 0A MVI C, FF DCR C JNZ LOOP DCR E JNZ LOOP1 RET

OPCODE 1E 0A 0E FF 0D C2 04 90 1D C2 09 90 C9

COMMENTS Move immediately the outer loop count 0A to the E register. Move immediately the inner loop count FF to the C register. Decrement the inner loop count i.e. C register content. Check for Zero flag, if it is not set goto Loop. Otherwise goto next step. Decrement the outer loop count i.e. the E register content. Check for Zero flag, if it is not set goto LOOP1. Otherwise goto next step. Return to the main function.

LOOP1
LOOP

177

RESULT: Thus the program was executed and the seven segment LED interfaced successfully to display counter.

178

179

Das könnte Ihnen auch gefallen