Date post: | 18-Nov-2014 |
Category: |
Documents |
Upload: | api-19951707 |
View: | 1,087 times |
Download: | 0 times |
1. MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8085
AIM:To write an assembly language program to multiply two 8-bit numbers
using 8085 microprocessor.
APPARATUS REQUIRED:
8085 microprocessor kit
ALGORITHM:
Step 1: Load the first data into accumulatorStep 2: Move the first data from accumulator to B registerStep 3: Load the second data in accumulatorStep 4: Move the second data from accumulator to C registerStep 5: Clear the accumulator againStep 6: Add B register content with accumulatorStep 7: Decrement count valueStep 8: Store the result in accumulatorStep 9: Stop the program
FLOW CHART FOR MULTIPLICATION OF TWO 8-BIT NUMBERS
LOAD THE FIRST DATA IN ACCUMULATOR AND SAVE IT IN B REGISTER
CLEAR THE ACCUMULATOR
LOAD THE SECOND DATA IN ACCUMULATOR AND SAVE IT IN C REGISTER
A
START
ADD B REGISTER CONTENT WITH A REGISTER
B
ASSEMBLY LANGUAGE PROGRAM:
2
CHECK WHETHE
RZF=1
NO
YES
DECREMENT THE COUNT VALVEC REGISTER
A
STORE THE RESULT
STOP
B
2. DIVISION OF TWO 16-BIT NUMBERS USING 8085
AIM:
To write an assembly language program to divide two 16 bit numbers using 8085 microprocessor.
APPARATUS REQUIRED:
8085 microprocessor kit
ALGORITHM:
Step 1: Get the divisor data from memory and store the 2’s complemented value of divisor in another memory locationStep 2: Clear BC pair register for storing the quotient valueStep 3: Clear the Quotient register (BC)Step 4: Get the 2’s complemented value of divisor number and store it in DE pair Step 5: Get the dividend number from one memory location to HL pair and add this number with DE pairStep 6: Increment the Quotient register (BC)Step 7: Store the remainder value in the dividend data locationStep 8: Check whether high byte dividend is equal to high byte of divisor. If yes go to step 7 otherwise go to next step Step 9: Check whether high byte dividend is greater than high byte divisor. If yes go to step 4,otherwise go to next stepStep 10: Store the quotient value in memory location Step 11: Stop the processStep 12: Get the lower byte of dividend and divisor to microprocessor and check whether they are equal or not. If they are equal go to step 4, otherwise go to next stepStep 13: Check whether lower byte dividend is greater than lower byte divisor or not. If dividend is greater then go to step 4, otherwise go to next stepStep 14: Store the quotient value from BC register to memoryStep 15: Stop the process
3
FLOW CHART FOR DIVISION OF TWO 16-BIT NUMBERS
4
START
GET THE DIVISOR DATA FROM 4202 MEMORY AND STORE THE 2’S COMPLEMENTED VALUE OF DIVISOR IN MEMORY 4206
CLEAR BC PAIR REGISTER FOR STORING THE QUETIENT VALUE
GET THE 2’S COMPLEMENTED VALUE OF DIVISOR NUMBER AND STORE IT IN DE REGISTER PAIR
CLEAR THE QUOTIENT REGISTER (BC)
GET THE DIVIDEND NUMBER FROM 4200 TO HL REGISTER PAIR AND ADD THIS NUMBER WITH DE REGISTER PAIR
INCREMENT THE QUOTIENT REGISTER (BC)
STORE THE REMAINDER VALUE IN THE DIVIDEND DATA LOCATION
CHECK WHETHER HIGH BYTE
DIVIDEND IS EQUAL TO HIGH
BYTE OF DIVISOR
ABC
YES
NO
D
`
5
STORE THE QUOTIENT VALUE IN 4500 LOCATION
STOP
CHECK WHETHER HIGH BYTE DIVIDEND IS GREATER THAN HIGH BYTE OF DIVISOR
B
GET THE LOWER BYTE OF DIVIDEND AND LOWER BYTE OF DIVISOR
CHECKLOWER BYTE DIVIDEND >
LOWER BYTE DIVISOR
E
NO
YES
C
YES
D
NO
CHECKZF=1
C
YES
NO
ASSEMBLY LANGUAGE PROGRAM:
6
E
STORE THE QUOTIENT VALUE IN THE MEMORY LOCATION 4500
STOP
3. CONVERSION OF THE GIVEN BINARY INTO EQUIVALENT BCD
AIM:To write an assembly language program to convert the given binary
number into a BCD number using microprocessor.
APPARATUS REQUIRED:
8085 microprocessor kit
ALGORITHM:
Step 1: Clear D and E register to account for hundreds and tensStep 2: Load the binary data in A registerStep 3: Compare A register with 64H.If carry flag is set, go to step 7 otherwise go to next step.Step 4: Subtract 64H from A registerStep 5: Increment E registerStep 6: Go to Step 3Step 7: Compare A register with 0AH.If carry flag is set,go to step 11 else go to next stepStep 8: Subtract 0AH from A registerStep 9: Increment D registerStep 10: Goto step 7Step 11: Combine the units and tens to form 8-bit resultStep 12: Save the units, tens and hundreds in memoryStep 13: Stop the program
FLOW CHART FOR CONVERSION OF THE GIVEN BINARY INTO EQUIVALENT BCD
7
START
CLEAR D AND E REGISTER
FROM MEMORY LOAD THE BINARY VALUE IN A REGISTER
COMPARE THE CONTENT OF A REGISTER WITH 64H
A B
8
CHECKWHETHE
RCY=1
COMPARE THE CONTENT OF A REGISTER WITH 0AH
CHECKWHETHE
RCY=1
SAVE THE CONTENT OF A REGISTER IN C REGISTER
MOVE THE TENS DIGIT TO A REGISTER
ROTATE A REGISTER CONTENT FOUR TIMES AND ADD WITH C REGISTER
STORE THE TENS AND UNITS FROM A REGISTER TO MEMORY
C
SUBTRACT 64H FROM A REGISTER AND INCREMENT E
REGISTER
SUBTRACT OAH FROM A REGISTER AND
INCREMENT D REGISTER
NO
YES
NO
YES
AB
ASSEMBLY LANGUAGE PROGRAM:
9
MOVE THE CONTENT OF E REGISTER TO A REGISTER
STORE HUNDREDS FROM A REGISTER TO MEMORY
STOP
C
4. INTERFACING 8085 WITH 8279 (KEY BOARD DISPLAY CONTROLLER)
AIM: To write an assembly program using 8085 and interfacing with 8279 (keyboard display controller) in order to display a character.APPARATUS REQUIRED:
1. 8085 microprocessor kit2. 8279 keyboard / display
THEORY:The block diagram of 8279 given in Fig(1) consists of
1. Keyboard section2. Scan section3. Display section4. MPU interface
KEYBOARD SECTION:
It has 8 lines (RL0-RL7) that can be connected to a column of a keyboard pulses two additional lines shift,CNTL/STB.The keys are automatically debounced and keyboard can operate in two modes,2-key lock out and N-key roll over. In 2-key lockout mode 1 if two keys are placed simultaneously only the first key is recognized and their codes are stored in internal buffer. In N-key roll over, If N-keys are pressed only the keys are recognized until one key is pressed.
SCAN SECTION:
The scan section has scan counter and 4 scan lines (SL0-SL3).These four lines can be decoded using 4 to 16 decoder to generate 16 linesa for scanning.These lines can be connected to the rows of the matrix display.
DISPLAY SECTION:
The display section has output lines divided into outputs A0 -A3 and B0 -B3.These lines can be used either as a group of 8 lines or as two groups of four in conjuction with the scan lines for a multiplex display. This display can be blank by using BD lines.
MPU INTERFACE SECTION:
This section includes birectional data lines DB0-DB7.One interrupt request,time and size,lines are interface including the buffer address line A0.When A0 is high signals are interrupted as control signals and when A0 is low signals are interrupted as control signals and when A0 is low signals are interrupted as data.ALGORITHM:
10
Step 1: Initialize the control register to set the keyboard and display modeStep 2: Clear displayStep 3: Writing a command word format for display RAMStep 4: Writing a corresponding binary word for letter ‘A’ (To enable the segment, corresponding binary digit is 0.To disable the segment, corresponding binary digit is 1)Step 5: Blank the rest of the display
11
BLOCK DIAGRAM OF 8279 (KEYBOARD AND DISPLOAY CONTROLLER)
IRQD0 - D7 RD WR CS A0
CLK RESET
TIMING AND CONTROL
DISPLAY ADDRESS REGISTER
DISPLAY ADDRESS REGISTER
SCAN CONTROLLER
BD
12
DATA BUFFER
I/O CONTROLLER
FIFO/SENSORAM
STATUS
INTERNAL DATA BUS (8)
DISPLAY ADDRESS REGISTER
16X8 DISPLAY
RAM
CONTROL AND TIMING REGISTER
8X8 FIFO/SENSOR
RAM
KEYBOARD DEBOUNCE
AND CONTROL
RETURN
SL0 – SL3OUT A0 –A3
OUT B0 – B3
RL0 – RL4 SHIFTCNTL /STB
(Fig. 1)
DISPLAY MODE SETUP:
The command word for keyboard and display mode is,
DD – DISPLAY MODE:
0 -- 8 8-bit character display – Left Entry01 – 16 8-bit character display – Left Entry10 -- 8 8-bit character display – Right Entry11 -- 16 8-bit character display – Right Entry
KKK – KEYBOARD MODE:
000 - Encoded Scan Keyboard – 2 key Lockout001 - Decoded Scan keyboard – 2 key Lockout010 - Encoded Scan Keyboard – N key roll-over011 - Decoded Scan Keyboard – N key roll-over100 - Encoded Scan Sensor Matrix101 - Decoded Scan Sensor Matrix110 - Strobed input, Encoded Display scan111 - Strobed input, Decoded Display scan
CLEAR DISPLAY:
The command word format for clear display is,
CD CD CD – The lower two CD bits specify the blanking code to be sent to the segments to turn them off while the 8279 is switching from one digit to next.
0 0 0 D D K K K
13
1 1 0 CD CD CD CF CA
CD CD CD
0 X - A0– 3 B0–3 = 00 (0000 0000)
0 0 - A0–3 B0– 3 =00(0000 0000) 1 0 - A0– 3 B0 – 3 =20(0010 0000) 1 1 - A0–3 B0 –3 =FF (1111 1111)
Enables clear Display when CD=1,the Rows of display RAM are cleared by Code set by lower two CD bits If CD=0 then the contents of RAM will
Be displayed.
CF -- If CF= 1, FIFO status is cleared, interrupt output line is reset. Sensor RAM pointer is set to row 0.
CF -- Clear All bit has the combined effect of CD and CF.It uses CD clearing code on Display Ram and clears FIFO status. It also resynchronizes the internal timing chain.
WRITE DISPLAY RAM: The write display RAM command word format is,
This command is written with A0 = 1.All subsequent writes with A0 = 0 will be to the Display RAM.
AI -- Auto Increment Flag. If AI = 1,the row address selected will be incremented after each following read or write to the Display RAM.
AAAA -- Selects one of the 16 rows of the Display RAM.
14
01 0 AI A A A A
FLOW CHART FOR INTERFACING 8085 WITH 8279(KEYBOARD AND DISPLAY CONTROLLER)
15
START
INITIALIZE THE CONTROL REGISTER TO SET THE KEYBOARD AND DIPLAY MODE
CLEAR DISPLAY
WRITING A COMMAND WORD FORMAT FOR DISPLAY RAM
WRITING A CORRESPONDING BINARY WORD FOR LETTER ‘A’
BLANK THE REST OF THE DISPLAY
STOP
ASSEMBLY LANGUAGE PROGRAM:
16
5. INTERFACING 8085 WITH 8253 (TIMER)
AIM:To generate a square wave using 8253 programmable interval timer by
interfacing it with 8085.APPARATUS REQUIRED:
1. 8085 microprocessor kit2. CRO3. 8253 programmable interval timer
THEORY:The 8253 programmable interval timer/counter is functionally similar to the
software designed timers and counters. It generates accurate time delays and can be used for applications such as real time clock, an event counter, a digital one shot, a square wave generator and a complex waveform generator. To operate a counter, a 16 bit count is loaded in its register and a command begins to decrement the count until it reaches zero.
8253 can operate with a clock frequency from DC to 2 MHz.The block diagram of 8253 includes 3 counters 0,1,2 and a data bus buffer, read/write control logic and a control register.
The Block diagram of 8253 is given in Fig(1) at its pin configuration is given in Fig(2).
CONTROL UNIT REGISTER:The register is activated when buses A0 and A1 are at logic 1.It is used to
write a command word which specifies the channel to be used, its mode and either a read/write operation.
SQUARE WAVE GENERATOR:In this mode, when a count is loaded the output is high. The count is
decremented by two at every clock cycle and when it reaches zero, the output goes low and the count is reloaded again. This is repeated continuously. Thus a continuous square wave with a period equal to that of the count is generated.ALGORITHM:Step 1: Initialise the 8253 to use binary counter, channel 0 enable reading of LSB first,MSB next and select mode 3 for square wave generationStep 2: Move the accumulator data to control register.Step 3: Read LSB data to accumulator.Step 4: Move the LSB value to channel 0.Step 5: Load the MSB data into accumulatorStep 6: Move the MSB value to channel 0.Step 7: Stop the program.
17
BLOCK DIAGRAM OF 8253
PIN CONFIGURATION:
18
CLK 0
CLK 1
CLK 2
GATE 0
GATE 1
GATE 2
OUT 0
OUT 1
OUT 2
DATA BUS BUFFER COUNTER 0
CONTROL WORD
REGISTER
READ/WRITE CONTROL
LOGIC
COUNTER 2
COUNTER 1
INTERNAL
BUS
RDWRA1A0
CS
D0-D7
Fig (1)
FLOW CHART FOR INTERFACING 8085 WITH 8253 (TIMER)
19
1 24
2 23
3 22
4 21
5 20
6 19
7 18
8 17
9 16
10 15
11 14
12 13
D7
D5
D3
D2
D4
D6
D1
D0
CLK 0
OUT 0
GND
GATE 0
CLK 2
OUT 2
GATE 2
CLK 1
GATE 1
OUT 1
VCC
WR
RD
CS
A1
A0
8253START
INITIALISE THE 8253 TO SELECT CHANNEL 0 TO ENABLE LOAD OF LSB FIRST, MSB NEXT, SELECT
MODE 3 FOR SQUARE WAVE GENERATION
MOVE THE ACCUMULATOR DATA TO CONTROL REGISTER
LOAD LSB DATA TO ACCUMULATOR
MOVE THE LSB VALUE TO CHANNEL 0
LOAD MSB DATA TO ACCUMULATOR
MOVE THE MSB VALUE TO CHANNEL 0
STOP
Fig (2)
ASSEMBLY LANGUAGE PROGRAM:
20
6. DETERMINATION OF THE LENGTH OF THE STRING USING 8086
AIM:To write an 8086 assembly language program to determine the length of
ASCII string. Use PC keyboard to input the string and display itslength on Personal Computer monitor.
21
START
LOAD OFFSET ADDRESS OF DATA SEGMENT IN AX
COPY THE CONTENT OF AX TO DS REGISTER
DISPLAY MESSAGE-1 (MSG 1)USING MACRO-DISP
CLEAR CX REGISTER (INITIALIZE COUNT AS ZERO)
LOAD 01H IN AH REGISTER
CALL DOS SERVICE INT 21H TO GET KEYCODE IN AL AND ECHO IT ON
MONITOR
COMPARE CONTENT OF AL WITH ODH
A B
APPARATUS REQUIRED:1. 8086 Microprocessor kit2. Personal computer
ALGORITHM:
(i). Main programStep 1: Initialize DS registerStep 2: Display the message “ENTER THE STRING.INPUT =”using
Macro DISPStep 3: Let CX register be used as counter. Initialize count as zeroStep 4: Load the function code 01H in AH register and initiate DOS
Interrupt INT 21H to get the ASCII value of key pressed in AL and Echo (display) the key symbol / character in the PC monitor
Step 5: Compare the content of AL with ASCII value of ENTER key to Check whether ENTER key is pressed. If ZF = 1,go to step-8, Otherwise go to next step
Step 6: Increment the counter (CX register)Step 7: Go to step-4Step 8: Display the message “THE LENGTH OF STRING =” using the
Macro DISPStep 9: Set SI as memory pointer for ASCII value of lengthStep 10: Copy the count value in AX registerStep 11: Call procedure HEX2ASC to get the ASCII value of count in
Memory pointed by SIStep 12: Display the length of string using the macro DISPStep 13: Load the function code 4CH in AH register and initiate the DOS
Interrupt INT 21H to terminate the programStep 14: Stop
(ii). Procedure HEX2ASC
Step 1: Load the divisor(OAH) in BX registerStep 2: Divide the hex value of length in AX with OAH to get units in DX and tens in AXStep 3: Add the ASCII value of zero to DL register to get ASCII value of unitsStep 4: Add the ASCII value of zero to AL register to get ASCII value of tensStep 5: Store the ASCII values in memory pointed by SIStep 6: Return
FLOW CHART FOR MAIN PROGRAM
22
23
A
IS ZF = 1 ?
B
FLOW CHART FOR PROCEDURE HEX2ASC
24
DISPLAY MESSAGE-2 USING MACRO DISP
SET SI AS POINTER FOR ASCII VALUE OF LENGTH
COPY THE COUNT VALUE IN AX REGISTER
CALL PROCEDURE HEX2ASC TO GET ASCII VALUE OF LENGTH IN MEMORY
DISPLAY THE LENGTH OF STRING USING MACRO-DISP
LOAD 4CH IN AH AND 00H IN AL
CALL DOS SERVICE INT 21H TO TERMINATE PROGRAM
STOP
INCREMENT CX REGISTER
NO
YES
START
LOAD OAH IN BX REGISTER AND OOH IN DX REGISTERDIVIDE AX BY BXADD ASCII ZERO TO DLADD ASCII ZERO TO ALSTORE AL AND DL IN MEMORY POINTED BY SI
STORE ASCII VALUE OF $ AS END OF ASCII STRINGRETURN
ASSEMBLY LANGUAGE PROGRAM:
25
7. ADDITION OF TWO 8-BIT NUMBERS AND SUBTRACTION OF TWO 8-BIT NUMBERS USING 8051-MICROCONTROLLER
AIM:To write an assembly language program to add and subtract two 8-bit
numbers using 8051 microcontroller.
26
APPARATUS REQUIRED:1. 8051 microcontroller kit2. Power supply
ALGORITHM:ADDITION
Step 1: Clear the carry flagStep 2: Move the first data to accumulatorStep 3: Add the second data to accumulator with carryStep 4: Set the pointer for the memory location where the data has to be storedStep 5: Store the result in memoryStep 6: Stop the processSUBTRACTION:
Step 1: Clear the borrow flagStep 2: Move the first data to accumulatorStep 3: Subtract the second data with borrow from accumulatorStep 4: Set the pointer for the memory location where the data has to be storedStep 5: Store the result in memoryStep 6: Stop the process
FLOW CHART FOR ADDITION OF TWO 8-BIT NUMBERS
27
START
CLEAR THE CARRY FLAG
MOVE FIRST DATA TO ACCUMULATOR
ADD SECOND DATA WITH CARRY TO ACCUMULATOR
A
SET THE POINTER FOR THE MEMORY LOCATION WHERE THE DATA HAS TO BE STORED
A
FLOW CHART FOR SUBTRACTION OF TWO 8-BIT NUMBERS:
ASSEMBLY LANGUAGE PROGRAM:
ADDITION
28
STORE THE RESULT IN MEMORY
STOP
START
CLEAR THE CARRY FLAG
MOVE FIRST DATA TO A REGISTER
SUBTRACT SECOND DATA WITH BORROW FROM A REGISTER
STORE THE RESULT IN MEMORY
STOP
SET THE POINTER FOR THE MEMORY LOCATION WHERE THE DATA HAS TO BE STORED
SUBTRACTION
8. FINDING THE LARGEST NUMBER USING 8051-MICROCONTROLLER
AIM:To write an assembly language program using 8051 microcontroller to find
the largest number from a given 8 bit ten numbers.
29
APPARATUS REQUIRED:1. Microcontroller kit2. CRO
ALGORITHM:
Step 1: Initialize the data pointer to memory where numbers are stored.Step 2: Initialize the counter.Step 3: Initialize the maximum value as 0.Step 4: Get the number from memory to accumulator.Step 5: Compare the number with the maximum value.Step 6: If both the values are not equal than go to step 8.Step 7: Otherwise go to step 10.Step 8: Check for carry flag. If carry comes go to step 10,otherwise go to next stepStep 9: Maximum value is the number taken from memory.Step 10: Increment data pointer.Step 11: Decrement the count value. If count is 0 stop the process otherwise go to step 4.
FLOW CHART FOR FINDING THE LARGEST NUMBER USING 8051
MICROCONTROLLER
30
START
INITIALIZE THE DATA POINTER TO MEMORY LOCATION
INITIALIZE THE COUNTER
MAXIMUM VALUE=0
A
A
GET THE NUMBER TO BE CHECKED FROM MEMORYAND COMPARE IT WITH THE MAXIMUM VALUE
CHECKCY=1
MAX VALUE=NUMBER TAKEN FROM MEMORY
ASSEMBLY LANGUAGE PROGRAM:
31
CHECK ZF=1
INCREMENT DATA POINTER
NO
NO
YES
YES
DECREMENT COUNT
CHECKZF=1
STOP
YES
NO
9. INTERFACING OF STEPPER MOTOR WITH 8051-MICROCONTROLLER
AIM:To run a stepper motor in both clock and anticlockwise direction by
interfacing it with 8051 microcontroller.APPARATUS REQUIRED:
1.Stepper motor
32
3.8051 microcontroller kit3. Stepper motor interfacing board
THEORY:A motor in which the rotor is able to assume only discrete stationary
angular position is a stepper motor. The rotary motion occurs in a stepwise manner from one equilibrium position to the next.
Stepper motor control is a very popular application of microprocessor in control area.
CONSTRUCTIONAL FEATURES:A Stepper motor could be either of the reluctance type or the permanent
magnet type. A permanent magnet stepper motor consists of multi-phased stator and two-part permanent magnet rotor.
The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles has its own winding. The excitation of any one winding generates a North Pole; a south pole gets induced at the diametrically opposite side.
It can be noted that the step size is =360/NS.Nr
Where, NS=Number of stator polesNr=Number of rotor poles
There are three different schemes available for stepping a stepper motor. They are
i). Wave schemeii). Two phase switching schemeiii). Half stepping or mixed scheme
TWO-PHASE SWITHING SCHEME:In this scheme, only any two adjacent station windings are energized.
There are two magnetic fields active in quadrature and none of the rotor pole faces can be in direct alignment with the stator poles. A partial but symmetric alignment of the rotor poles is of course possible.
The step angle is 300 as in the wave scheme. However,the rotor is offset by 150 in the two phase scheme with respect to move the rotor by 3600.Two phase drivers produce more torque than the wave drivers.
ALGORITHM:
Step 1: Set the data pointer for the memory location where the energizing pulses are available.Step 2: Set the count value as step 4.Step 3: Move the energizing pulse from memory to accumulator.Step 4: Save the data pointer value in stack.Step 5: Set the data pointer for the port address where the energizing pulses have to be given
33
Step 6: Establish a delay routine.Step 7: Send the energizing pulse to output stepper motor port.Step 8: Get the address which is saved in stack.Step 9: Increment the data pointer value.Step 10: Decrement the count value if it is not zero than go to step 3.Step 11: Otherwise go to step 1.
FLOW CHART FOR INTERFACING OF STEPPER MOTOR WITH 8051-
MICROCONTROLLER
34
START
SET THE DATA POINTER FOR THE ENERGIZING PULSES
SET THE COUNT VALUE FOR 4 ENERGIZING PULSES
MOVE THE ENERGZING PULSE FROM MEMORY TO ACCUMULATOR
PUSH THE ENERGIZING PULSE ADDRESS FROM DATA POINTER TO STACK MEMORY
AC
BA
SET THE DATA POINTER FOR THE OUTPUT STEPPER MOTOR PORT ADD
ESTABLISH A DELAY
SEND THE ENERGIZING PULSE FROM ACCUMULATOR TO THE OUTPUT PORT
POP THE ENERGIZING PULSE ADDRESS FROM STACK MEMORY TO DATA POINTERINCREMENT THE DATA POINTERDECREMENT THE COUNT VALUE
IFZF=1
B C
YES
ASSEMBLY LANGUAGE PROGRAM:
35
NO
36