2012manual 85 - 86
2012manual 85 - 86
(SASTRA University)
TIRUMALAISAMUDRAM THANJAVUR 613 401.
COURSE CODE: BECCEC 505 COURSE: MICROPROCESSOR LABORATORY BRANCH: ELECTRONICES AND COMMUNICATION SEMESTER: V
LIST OF EXPERIMENTS Assembly language programming using 8085: 01. 8 bit & 16 - bit arithmetic operations. 02. BCD to Hex and Hex to BCD conversion and other code conversions. Interfacing Through 8085 Programming: 03. Programming 8255 in various modes. 04. Waveform generation (Saw tooth, Triangular, Staircase etc) using D/A converter. 05. Interfacing 7 segment displays. Assembly language programming using 8086: 06. Program for sorting and searching. 07. Program for matrix operations. Interfacing Through 8086 Programming: 08. Interfacing Matrix keypad. 09. Interfacing stepper motor. 10. Interfacing traffic light control. Assembly language programming using 8087 : 11. Arithmetic operations. 12. Computing area of circle and triangle.
Note: Attach separate sheets for Programs in each experiment before the result page.
For interfacing experiments verify the addresses given in the lab manual using the trainer kit user manual. For experiments using 8086 processors the opcode column given in the program format is optional. Common format for Program: Address Label Mnemonics Opcode Comments
ARITHMETIC OPERATIONS AIM: To write an assembly language program to perform arithmetic operations such as 8-bit & 16-bit addition, subtraction, multiplication and division using 8085 microprocessor. ALGORITHM: Step1: Get two 8/16-bit data inputs. Step2: Perform arithmetic operations using the appropriate instruction for various addressing modes. Step3: Store the results in suitable memory locations. Step4: Halt the program.
RESULT: Thus the assembly language program for 8 & 16-bit arithmetic operations are written, executed and the outputs are verified using 8085 microprocessor. Exp. No.: 2a Date : BCD to HEX CONVERSION
AIM: To write an assembly language program to convert the given 8-bit BCD value to its equivalent hexadecimal value using 8085 microprocessor.
ALGORITHM: Step1: Get the two digit (8-bit) BCD input. Step2: Split the lower and upper nibbles of the BCD input using masking and shifting operations. Step3: Multiply the value of upper nibble with 0x0A and store the result in a register. Step4: Add the lower nibble value with the result obtained Step3. Step5: Store the result (HEX value) in a suitable memory location. Step6: Halt the program.
Extraction of Nibble from a byte Example BCD value = 59 Lower nibble = 0x59 AND 0x0F Upper nibble = (0x59 AND 0xF0) << 4 [Rotate Right/Left without carry for 4times to get the Upper nibble in LSD position]
RESULT: Thus the assembly language program to convert BCD to hexadecimal value is written, executed and the output is verified using 8085 microprocessor. Exp. No.: 2b Date : HEX TO BCD CONVERSION
AIM: To write an assembly language program to convert the given 8-bit HEX value to its equivalent BCD value using 8085 microprocessor. ALGORITHM: Step1: Get the 8-bit hexadecimal input. Step2: Initialize counters for 100s, 10s and 1s with zero. Step3: Find number of 100s present in the given HEX value by subtracting 64H from given value and increment 100s counter after every subtraction, till the HEX value goes below 64H. Step4: Similarly find the number of 10s by subtracting 0AH from the result obtained in Step3 and increment the 10s counter, till the HEX value goes below 0AH. Step5: Store the result of Step4 in the 1s counter. Step6: Finally the contents of 100s counter, 10s counter and 1s counter gives BCD equivalent of the input HEX value. Step7: Halt the program.
RESULT: Thus the assembly language program to convert BCD value to hexadecimal value is written, executed and the output is verified using 8085 microprocessor. Exp. No.: 3 Date : 8255 MODES OF OPERATION
AIM: To write an assemble language program to verify the various modes of operation in 8255PPI by establishing parallel communication between two 8085 microprocessor kits. THEORY: 8255 has three 8-bit ports A,B, & C and has two major modes of operations namely the I/O mode & BSR mode. Under I/O mode it can operate under three distinct operating modes (Modes 0, 1 and 2).
Port A can be set for Modes 0, 1, 2. Port B for 0,1 and Port C for mode 0 and for BSR Modes.
Mode 0: Ports A and B operate as either inputs or outputs and Port C is divided into two 4-bit groups either of which can be operated as inputs or outputs. Mode 1: Same as Mode 0 but Port C is used for handshaking and control.
Mode 2: Port A is bidirectional (both input and output) and Port C is used for handshaking. Port B is not used.
Individual bits of Port C can be set or reset through BSR mode. ALGORITHM - MODE 0 (SIMPLE I/O MODE) Mode 0 Kit 1 Step1: Configure all the ports of 8255PPI as o/p port under mode 0 in I/O mode by writing the appropriate control word in the address of control word register (CWR). Step2: Load the data to be sent out in Acc. Step3: Output the data to the address of port A/B/C. Step4: Halt the program. Mode 0 Kit 2 Step1: Configure all the ports of 8255PPI as i/p port under mode 0 in I/O mode by writing the appropriate control word in the address of control word register (CWR). Step2: Read the data in to Acc from port AB/C. Step3: Store the Acc content in a suitable memory location. Step4: Halt the program. ALGORITHM - MODE 1 (I/O MODE WITH HAND SHAKE SIGNALS) Mode 1 is same as mode 0 but port C cannot be used.
ALGORITHM - MODE 2 (BIDIRECTIONAL I/O FOR PORT A WITH HAND SHAKE SIGNALS) Mode 2 Kit 1 Step1: Configure port A of 8255PPI as i/p port under mode 2 in I/O mode by writing the appropriate control word in the address of control word register (CWR). Step2: Load the data to be sent out in Acc. Step3: Output the data to the address of port A. Step4: Wait for a period of few milliseconds (call delay function). Step5: Read the data in to Acc from port A. Step6: Store the Acc content in a suitable memory location. Step7: Halt the program. Mode 2 Kit 2 Step1: Configure all the ports of 8255PPI as i/p port under mode 2 in I/O mode by writing the appropriate control word in the address of control word register (CWR). Step2: Read the data in to Acc from port A. Step3: Increment the Acc content by one. Step4: Output the data to the address of port A. Step5: Halt the program. ALGORITHM BSR Mode Step1: Write the appropriate control word in the address of control word register (CWR) to configure port C in BSR mode & to set any one of the bit in port C of 8255PPI. Step2: Wait for a period of few milliseconds (call delay function). Step3: Write the appropriate control word in the address of control word register (CWR) to configure port C in BSR mode & to reset the bit in port C of 8255PPI which we set in step 1. Step4: Wait for a period of few milliseconds (call delay function). Step5: Go to step 1. Step6: Halt the program. Note: In BSR mode, the above algorithm is used to turn ON & turn OFF a LED with a fixed delay between On & OFF.
RESULT:
Thus the assemble language program to verify the various modes of operation in 8255PPI are verified by establishing parallel communication between two 8085 microprocessor kits.
Exp. No.: 4
Date
AIM: To write an assembly language program to generate square and triangular waveforms by interfacing 8-bit DAC with 8086 microprocessor. THEORY: The Dual DAC interface has two 8-bit digital to analog converters based on DAC 0800. The digital inputs to these DACs are provided through the port A and port B of 8255 which are used as o/p ports. The O/P from the DAC varies between 0 to 5V corresponding to values between 00 to FFH. The O/Ps can be obtained from the points marked as Xout and Yout which are controlled by port A & port B respectively. The board requires external power supply voltages of +12V, -12V and GND. The interface between DAC board and J2 of 8085 trainer kit can be made through a 26-pin FRC.
MODEL CALCULATION:
where, Vmax - 5V
SAMPLE INPUT & OUTPUT: Wave form Type Square Triangular X-axis Y-axis Time/Div Volts/Div Time Amplitude Freq Peroid (ms) (V) (1/T)HZ
RESULT: Thus the assembly language program to generate square and triangular waveforms using 8-bit DAC interface with 8086 microprocessor is written, executed and the outputs are verified. Exp. No.: 5
Date
AIM: To write an assembly language program to display the desired data in seven segment display through on-board 8279 of 8085 microprocessor kit. THEORY: Bit position for each segment is given below. Segment Bit d 7 c 6 b 5 a 4 dp 3 g 2 f 1 e 0
dp
ALGORITHM: Step1: Load the values required to obtain the desired display pattern in an array. Step2: Load the port addresses of all the seven segment displays in an array. Step3: Load a register with the number of characters to display. Step4: Output the address of desired display to the address of 8279 command register. Step5: Output the desired data to be displayed to the address of 8279 data register. Step6: Decrement the count register by one, if zero flag is not set after decrementing go to step 4. Step7: Halt the program. Example input data: Displays the character S
d 7 1
c 6 1
b 5 0
a 4 1
dp 3 0
g 2 1
f 1 1
E 0 0
Load 0xD6 in data register to display the character shown below after loading the Command register with field address of corresponding display. a
d MODEL CALCULATION:
RESULT: Thus the assembly language program to interface seven segment displays with 8085 microprocessor is written, executed and the output is verified. Exp. No.: 6a
Date
: LINEAR SEARCH
AIM: To write an assembly language program to perform linear search using 8086 microprocessor. ALGORITHM: Step1: Initialize a count register with the number of elements to be searched. Step2: Get the value of element to be searched in a register. Step3: Initialize a 16-bit register with the starting address of the input elements array & another register with the starting address of the result array to store the addresses of matched elements in the input array. Step4: Initialize a 8-bit register with zero to count the number of occurrences of the required element in the array. Step5: Compare the value of element to be searched with the value of element pointed by the input array pointer, if both the values are not equal go to step 9 . Step6: Increment the occurrence count register by one. Step7: Copy the current address pointed by the input array pointer to the result array. Step8: Increment the result array pointer by two. Step9: Increment the input array pointer by one to point the next element in the array. Step10: Decrement the count element by one, if the value after decrement is not zero go to Step 5 . Step11: Halt the program.
RESULT: Thus the assembly language program to perform linear search is written, executed and the output is verified using 8086 microprocessor. Exp. No.: 6b
Date
AIM: To write an assembly language program to sort the given numbers in ascending order with bubble sort algorithm using 8086 microprocessor. ALGORITHM: Step1: Get the number of elements in the array n in a count register. Step2: Initialize a 8-bit register with n as number of iterations. Step3: Initialize a 16-bit register with the starting address of the input elements array. Step4: Copy the contents in number of iterations loop count register to a 8-bit register as loop count for number of comparisons. Step5: Get the value pointed by the input array pointer in a 8-bit compare register. Step6: Increment the input array pointer by one to point the next element in the array. Step7: Compare the content of compare register with the value pointed by the input array pointer, if carry flag is set swap the two values. Step8: Decrement the comparisons loop count register by one, if the value after decrement is not zero go to step 5. Step9: Decrement the iterations loop count register by one, if the value after decrement is not zero go to step 3. Step10: Halt the program.
RESULT: Thus the assembly language program to perform sorting is written, executed and the output is verified using 8086 microprocessor. Exp. No.: 7
Date
: MATRIX ADDITION
AIM: To write an assembly language program to perform matrix operations using 8086 microprocessor.
ALGORITHM: Step1: Get the size of matrix n x n. Step2: Get the element values for the two input matrices. Step3: Add/Subtract the value of each element in the first matrix with the value of same element in the second matrix. Step4: Store each result value in the resultant matrix. Step5: Halt the program.
RESULT: Thus the assembly language program to perform matrix addition is written, executed and the output is verified using 8086 microprocessor. Exp. No.: 8
Date AIM:
To write an assembly language program to interface a 3x8 matrix keypad with 8086 microprocessor. THEORY: . ALGORITHM:
MODEL CALCULATION:
RESULT: Thus the assembly language program to interface 3x8 matrix keypad with 8086 microprocessor is written, executed and the output is verified.
EXP. NO.: 9 DATE : STEPPER MOTOR INTERFACE AIM: To write an assembly language program to interface stepper motor with 8086 microprocessor. THEORY: A permanent magnet stepper motor consists of two stator windings A,B and a motor having two magnetic pole N, and S. It will have 1.8 degree step angle and 50 tooth on its rotor. There are 8 main poles on the stator, each having 5 teeth in the pole face. The step angle is given by A = 3600 / (N x K) degree. N = Number of rotor tooth K = Excitation sequence factor. The lower nibble (PA0- PA3) of Port A in 8255 PPI is configured as output pins in order to interface stepper motor with the microprocessor. The interface between stepper motor board and J8 of 8086 trainer kit can be made through a 26-pin FRC. ALGORITHM: Step1: Get the required direction of rotation and load it in a register. Step2: Configure port pins PA0-PA3 of 8255PPI as output ports by writing the appropriate control word in the address of control word register (CWR). Step3: Load the step count value in to the count register. Step4: Load a register with excitation data. Step5: Output the excitation data to the address of portA. Step6: Rotate the contents of excitation data register in required direction (left/right). Step7: Give a delay of few milliseconds. Step8: Decrement contents of count register by 1, if the value after decrement is not zero go to step5. Step9: Halt the program.
RESULT: Thus the assembly language program to interface stepper motor with 8086 microprocessor is written, executed and the output is verified.
Exp. No.: 10 Date : TRAFFIC LIGHT CONTROLLER AIM: To write an assembly language program to interface traffic light controller with 8086 microprocessor. THEORY: Traffic light interface provides a set of LEDs and a control by 24 port lines. The 24 LEDs and the corresponding port lines are summarized below. LED South RED AMBER LEFT STRAIGHT RIGHT PEDESTRIAN East RED AMBER LEFT STRAIGHT RIGHT PEDESTRIAN North RED AMBER LEFT STRAIGHT RIGHT PEDESTRIAN PA3 PA2 PA0 PC3 PA1 PC6 PA7 PA6 PA4 PC2 PA5 PC7 PB3 PB2 PB0 PC1 PB1 PC4 PORTLINE
West RED AMBER LEFT STRAIGHT RIGHT PEDESTRIAN PB6 PB4 PC0 PB5 PC5
ALGORITHM: Step1: Load the data required to generate different traffic control patterns in an array. Step2: Load a register with the data count required to generate the pattern. Step3: Configure all the ports of 8255PPI as output ports by writing the appropriate control word in the address of control word register (CWR). Step4: Output the data in the control Pattern array in a cyclic manner one by one to the appropriate port addresses of 8255 and give delay for few milliseconds between different patterns. Step5: Go to step4.
RESULT: Thus the assembly language program to interface traffic light controller with 8086 microprocessor is written, executed and the output is verified.
IEEE Standard 754 Floating Point Numbers IEEE Standard 754 floating point is the most common representation today for real numbers on computers, including Intel-based PC's. IEEE floating point numbers have three basic components: the sign, the exponent, and the mantissa. The following figure shows the layout for single (32-bit) floating-point values. The number of bits for each field are shown (bit ranges are in square brackets): Sign Exponent Fraction Bias 127
The Sign Bit: The sign bit is as simple as it gets. 0 denotes a positive number; 1 denotes a negative number. Flipping the value of this bit flips the sign of the number. The Exponent: The exponent field needs to represent both positive and negative exponents. To do this, a bias is added to the actual exponent in order to get the stored exponent. For IEEE single-precision floats, this value is 127. Thus, an exponent of zero means that 127 is stored in the exponent field. A stored value of 200 indicates an exponent of (200-127), or 73. The Mantissa: The mantissa, also known as the significand, represents the precision bits of the number. In order to maximize the quantity of representable numbers, floating-point numbers are typically stored in normalized form. This basically puts the radix point after the first non-zero digit. Putting it All Together So, to sum up: 1. 2. The sign bit is 0 for positive, 1 for negative. The exponent's base is two.
3. The exponent field contains 127 plus the true exponent for singleprecision, or 1023 plus the true exponent for double precision. 4. The first bit of the mantissa is typically assumed to be 1.f, where f is the field of fraction bits.
Example Let us encode the decimal number 118.625 using the IEEE 754 system in Single presion with 32-bits. 1. First we need to get the sign, the exponent and the fraction. Since, it is a negative number the sign is "1". 2. Now, we write the number (without the sign) using binary notation. The result is 1110110.101. 3. Next, let's move the radix point left, leaving only a 1 at its left: 1110110.101 = 1.110110101 26. This is a normalized floating point number. The mantissa is the part at the right of the radix point, filled with 0 on the right until we get all 23 bits. That is 11011010100000000000000. 4. The exponent is 6, but we need to convert it to binary and bias it (so the most negative exponent is 0, and all exponents are non-negative binary numbers). For the 32-bit IEEE 754 format, the bias is 127 and so 6 + 127 = 133. In binary, this is written as 10000101. 5. Putting them all together:
Bit 31 Sign Bit Bits 30 23 Exponent Field Bits 22 - 0 Mantissa
10000101
11011010100000000000000
6. Group them as 4bits from left to right to obtain the HEX value.
Hexadecimal: C2 ED 40 00
Decimal: -118.62500
Exp. No.: 11 Date : ARITHMETIC OPERATIONS AIM: To write an assembly language program to perform arithmetic operations such as 32-bit addition, subtraction, multiplication and division using 8087 math coprocessor. ALGORITHM: Step1: Get two 32-bit data inputs. Step2: Perform arithmetic operations using the appropriate instruction. Step3: Store the results in suitable memory locations. Step4: Halt the program.
RESULT: Thus the assembly language program to perform various 32-bit arithmetic operations is written, executed and the output is verified using 8087 math coprocessor.
Exp. No.: 12a Date : AREA OF A CIRCLE AIM: To write an assembly language program to find the area of circle using 8087 math coprocessor. ALGORITHM: Step1: Get the value of radius for the circle in a register. Step2: Square the value of radius and store it in the same register. Step3: Multiply the resultant value with the value of (3.14). Step4: Store the result in a memory location. Step5: Halt the program.
RESULT: Thus the assembly language program to find the area of circle is written, executed and the output is verified using 8087 math coprocessor.
Exp. No.: 12b Date : AREA OF A TRIANGLE AIM: To write an assembly language program to find the area of triangle using 8087 math coprocessor. ALGORITHM: Step1: Get the value of breath & height of the triangle in registers. Step2: Multiply the value of breath & height. . Step3: Divide the resultant value by 2. Step4: Store the result in a memory location. Step5: Halt the program.
RESULT: Thus the assembly language program to find the area of triangle is written, executed and the output is verified using 8087 math coprocessor.
On board 7-seg displays Port addresses 90H to 93H Port addresses 94H & 95H 31H 30H
8255 - J8
8255 - J (U42)