Upload
basil-john
View
674
Download
1
Tags:
Embed Size (px)
DESCRIPTION
8085 description and basic lab experiments included.
Citation preview
INTRODUCTION TO 8085
INTEL 8085 is one of the most popular 8-bit microprocessor capable of addressing 64 KB of memory and its architecture is simple. The device has 40 pins, requires +5 V power supply and can operate with 3MHz single phase clock.
8085 MICROPROCESSOR FUNCTIONAL BLOCK DIAGRAM
Architecture of 8085 Microprocessor
a) General purpose registerIt is an 8 bit register i.e. B,C,D,E,H,L. The combination of 8 bit register is known as
register pair, which can hold 16 bit data. The HL pair is used to act as memory pointer is accessible to program.
b) AccumulatorIt is an 8 bit register which hold one of the data to be processed by ALU and stored
the result of the operation.
c) Program counter (PC)It is a 16 bit pointer which maintain the address of a byte entered to line stack.
d) Stack pointer (Sp)It is a 16 bit special purpose register which is used to hold line memory address for
line next instruction to be executed.
e) Arithmetic and logical unitIt carries out arithmetic and logical operation by 8 bit address it uses the accumulator
content as input the ALU result is stored back into accumulator.
f) Temporary registerIt is an 8 bit register associated with ALU hold data, entering an operation, used by
the microprocessor and not accessible to programs.
g) FlagsFlag register is a group of fire, individual flip flops line content of line flag register
will change after execution of arithmetic and logic operation. The line states flags arei) Carry flag (C) ii) Parity flag (P) iii) Zero flag (Z) iv) Auxiliary carry flag (AC) v) Sign flag (S)
Carry flag:If an arithmetic operation results in a carry, the carry flag is set. The carry flag also
serves as a borrow flag for subtraction.
Parity flag:After arithmetic – logic operation, if the result has an even number of 1’s the flag is
set. If it has odd number of 1’s it is reset.
Zero flag:The zero flag is set if the ALU operation results in zero. This flag is modified by the
result in the accumulator as well as in other registers.
Auxiliary carry flag:In an arithmetic operation when a carry is generated by digit D3 and passed on to D4,
the auxiliary flag is set.
Sign flag:After the execution of the arithmetic - logic operation if the bit D7 of the result is 1,
the sign flag is set. This flag is used with signed numbers. If it is 1, it is a negative number and if it is 0, it is a positive number.
h) Timing and control unitSynchronous all microprocessor, operation with the clock and generator and control
signal from it necessary to communicate between controller and peripherals.
i) Instruction register and decoderInstruction is fetched from line memory and stored in line instruction register decoder
the stored information.
j) Register ArrayThese are used to store 8 bit data during execution of some instruction.
PIN Description
Address Bus1. The pins Ao – A15 denote the address bus. 2. They are used for most significant bit
Address / Data Bus1. AD0 – AD7 constitutes the address / Data bus 2. These pins are used for least significant bit
ALE (Address Latch Enable)
1. The signal goes high during the first clock cycle and enables the lower order address bits.
IO / M1. This distinguishes whether the address is for memory or input. 2. When this pins go high, the address is for an I/O device.
S0 – S1
S0 and S1 are status signal which provides different status and functions.
RD1. This is an active low signal 2. This signal is used to control READ operation of the microprocessor.
WR1. WR is also an active low signal 2. Controls the write operation of the microprocessor.
HOLD1. This indicates if any other device is requesting the use of address and data
bus. 2. It indicates whether the hold signal is received or not.
HLDA1. HLDA is the acknowledgement signal for HOLD 2. It indicates whether the hold signal is received or not.
INTR1. INTE is an interrupt request signal 2. IT can be enabled or disabled by using software
INTA1. Whenever the microprocessor receives interrupt signal 2. It has to be acknowledged.
RST 5.5, 6.5, 7.51. These are nothing but the restart interrupts 2. They insert an internal restart junction automatically.
8 BIT ADDITION
AIM:
To write a assembly language program for Addition two (8) bit numbers by
using-8085 micro processor kit.
APPARATUS REQUIRED:
1. 8085 microprocessor kit2. keyboard
ALGORITHM (ADDITION)
Step1 : Start the microprocessor
Step2 : Initialize the carry as ‘Zero’
Step3 : Load the first 8 bit data into the accumulator
Step4 : Copy the contents of accumulator into the register ‘B’
Step5 : Load the second 8 bit data into the accumulator.
Step6 : Add the 2 - 8 bit datas and check for carry.
Step7 : Jump on if no carry
Step8 : Increment carry if there is
Step9 : Store the added request in accumulator
Step10 : More the carry value to accumulator
Step11 : Store the carry value in accumulator
Step12 : Stop the program execution.
Flow chart
NO
YES
Intialise the carry as zero
Load the 1st 8 bit number
Transfer the 1st number to register ‘B’
Load the 2nd 8 bit number
Transfer and Add the contents of A and B
Increment carry by one
Store the added value in accumulator
Store the value of carry in accumulator
Move the contents of carry into accumulator
END
Check for carry
START
PROGRAM:
ADDRESS
LABEL MNEMONICS OPCODE COMMENTS
4100 MVI C,00 0E,00 Clear the content of C Register.
4102 LDA 4300 3A,00,43Load the content of the accumulator in 4300
4105 MOV B, A 47Move the content from accumulator to B register
4106 LDA 4301 3A,01,43Load the content of the accumulator in 4301
4109 ADD B 80Add the content from accumulator to B register
410A JNC 410E ( LOOP 1) D2,0E,41Jump on no carry to the label (LOOP 1)
410D INR C 0C Increment the C register content
410E LOOP 1 STA 4302 32,02,43Store the sum at accumulator at in location 4300
4111 MOV A,C 79Move the carry content from C Register to accumulator
4112 STA 4303 32,03,43Store carry content in accumulator at the location 4303
4115 HLT 76 End the program
InputWithout carry
Input Address Value4300 044301 02
OutputOutput Address Value
4302 064303 00 (carry)
With carryInput Address Value
4300 FF4301 FF
Output Address Value Output 4302 FE
4303 01 (carry)
Calculation 1111 1111 0000 01001111 1111 0000 0010
---------------(1) 1111 1110 0000 0110
=========
F E
8 BIT SUBTRACTION
Aim:To write a assembly language program for subtracting two (8) bit numbers by using-
8085 micro processor kit.
Apparatus required:1. 8085 microprocessor kit2. Keyboard
ALGORITHM
Step1 : Start the microprocessor
Step2 : Intialize the carry as ‘Zero’
Step3 : Load the first 8 bit data into the accumulator
Step4 : Copy the contents of accumulator into the register ‘B’
Step5 : Load the second 8 bit data into the accumulator.
Step6 : Add the 2 - 8 bit datas and check for carry.
Step7 : Jump on if no carry
Step8 : Increment carry if there is
Step9 : Store the added request in accumulator
Step10 : More the carry value to accumulator
Step11 : Store the carry value in accumulator
Step12 : Stop the program execution.
Flow chart
NO
YES
Intialise the carry as zero
Load the 1st 8 bit number
Transfer the 1st number to register ‘B’
Load the 2nd 8 bit number
Subtract the two values
Increment carry by one
1’s compliment of 2nd value
Add 1 to 1’s compliment for 2’s compliment
END
Check for carry
START
Store the value of result in accumulator
Move the carry into the accumulator
Store the value of carry in accumulator
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS4100 MVI C,00 0E,00 Clear the content of C Register.
4102 LDA 4300 3A,00,43Load the content of the accumulator in 4300
4105 MOV B, A 47Move the content from accumulator to B register
4106 LDA 4301 3A,01,43Load the content of the accumulator in 4301
4109 SUB B 90Sub the content from accumulator to B register
410A JNC 410E ( LOOP 1) D2,0E,41 Jump on no carry to the label (LOOP 1)410D INR C 0C Increment the C register content
410E LOOP 1 STA 4302 32,02,43Store the content of accumulator at in location 4302
4111 MOV A,C 79Move the carry content from C Register to accumulator
4112 STA 4303 32,03,43Store carry content in accumulator at the location 4303
4115 HLT 76 End the program
InputWithout borrow
Input Address Value4300 054301 07
OutputOutput Address Value
4302 024303 00 (borrow)
With carry borrowInput Address Value
4300 074301 05
Output Address Value4302 024303 01 (borrow)
Calculation 05 – 0707 – 011110000001------1001
05 - 0101------1110 (-2)
ADDITION OF TWO 16 – BIT NUMBERS
AIM:
To write an assembly language program for adding two 16 bit numbers using 8085 micro processor kit.
APPARATUS REQUIRED:
1. 8085 microprocessor kit2. Key board
ALGORITHM (ADDITION):
Step1 : Get the 1st 8 bit in ‘C’ register (LSB) and 2nd 8 bit in ‘H’
Register (MSB) of 16 bit number.
Step2 : Save the 1st 16 bit in ‘DE’ register pair
Step3 : Similarly get the 2nd 16 bit number and store it in ‘HL’ register
Pair.
Step3 : Get the lower byte of 1st number into ‘L’ register
Step4 : Add it with lower byte of 2nd number
Step5 : tore the result in ‘L’ register
Step6 : Get the higher byte of 1st number into accumulator
Step7 : Add it with higher byte of 2nd number and carry of the lower bit
Addition.
Step8 : Store the result in ‘H’ register
Step9 : Store 16 bit addition value in ‘HL’ register pair
Step10 : Stop program execution
Flow chart
NO
YES
Address Label Mnemonics Hex Code Comments4500 MVI C,00 0E C = 00H
C = 00H
Load ‘HL’ with 1st Data
Transfer HL - DE
Load ‘HL’ with 2nd Data
DE + HL = HL
C = C + 01
Store ‘HL’ in memory (SUM)
Transfer C - A
END
Check for carry
START
Store ‘A’ in memory (Cy)
4501 004502 LHLD 4800 2A HL – 1st No.4503 004504 484505 XCHG EB HL – DE4506 LHLD 4802 2A HL – 2nd No.4507 024508 484509 DAD D 19 Double addition DE +
HL450A JNC Ahead D2 If Cy = 0, G0 to 450E
450E450B 0E450C 45450D INR C 0C C = C + 01450E AHEAD SHLD 4804 22 HL – 4804 (sum)450F 044510 484511 MOV C,A 79 Cy – A4512 STA 4806 32 Cy – 48064513 064514 484515 HLT 76 Stop execution
Input without carry
Input Address Value4800 01 (addend)4801 044802 02 (augend)4803 03 (augend)
OutputOutput Address Value
4804 03 (sum)4805 07 (sum)4806 00 (carry)
Calculation 0000 0100 0000 00010000 0011 0000 0010---------------------------------0000 0111 0000 00110 7 0 3
With carry
Input Address Value
4800 FF (addend)
4801 DE (addend)
4802 96 (augend)
4803 DF (augend)
Output Address Value
4804 95 (sum)
4805 BE (sum)
4806 01 (carry)
Calculation
1101 1110 1111 1111
1101 1111 1001 0101
---------------------------------
1011 1110 1001 0101
B E 9 5
SUBTRACTION OF TWO 16 – BIT NUMBERS
Aim:To write an assembly language program for subtracting two 16 bit numbers using
8085 microprocessor kit.
Apparatus required:1. 8085 microprocessor kit2. Keyboard
ALGORITHM
Step1 : Start the microprocessor
Step2 : Get the 1st 16 bit in ‘HL’ register pair
Step3 : Save the 1st 16 bit in ‘DE’ register pair
Step4 : Get the 2nd 16 bit number in ‘HL’ register pair
Step5 : Get the lower byte of 1st number
Step6 : Get the subtracted value of 2nd number of lower byte by
subtracting it with lower byte of 1st number
Step7 : Store the result in ‘L’ register
Step8 : Get the higher byte of 2nd number
Step9 : Subtract the higher byte of 1st number from 2nd number with
borrow
Step10 : Store the result in ‘HL’ register
Step11 : Stop the program execution
Flow chart
C = 00H
Load ‘HL’ with 1st Data
Transfer HL - DE
Load ‘HL’ with 2nd Data
Transfer E – A (LSB)
END
START
A = A – L (LSB)
Store ‘A’ in memory (LSB)
Transfer D – A (MSB)
A – A – H – Borrow (MSB)
Store ‘A’ in memory (MSB)
PROGRAM:
Address Label Mnemonics Hex Code Comments4500 MVI C,00 0E C = 00H4501 004502 LHLD 4800 2A L – 1st No.4503 004504 484505 XLHG EB HL – DE4506 LHLD 4802 2A HL – 2nd No.4507 024508 484509 MOV A,E 7B LSB of ‘1’ to ‘A’450A SUB L 95 A – A – L450B STA 4804 32 A – memory450C 04450D 48450E MOV A,D 7A MSB of 1 to A450F SBB H 9C A- A – H4510 STA 4805 32 A – memory4511 054512 484513 HLT 76 Stop execution
Input
Without borrow
Input Address Value4800 074801 084802 054803 06
OutputOutput Address Value
4804 024805 02
4807 00
Output
With borrow
Input Address Value4800 074801 084802 054803 06
OutputOutput Address Value
4804 024805 024807 00
Calculation
05 06 - 07 08
05 06 0101 0110 07 08 0111 10001010 1001 1000 01110000 0001 0000 0001--------------- --------------1010 1010 1000 1000
05 06 + 07 081010 10101000 1000---------------
(1) 0010 001002 02
8 BIT MULTIPLICATION & DIVISION
AIM:
To perform 8085 assembly language program for 8 bit multiplication .
APPARATUS REQUIRED:
1. 8085 microprocessor kit2. keyboard
ALGORITHM (MULTIPLICATION):
Algorithm:
Step1 : Start the microprocessor
Step2 : Get the 1st 8 bit numbers
Step3 : Move the 1st 8it number to register ‘B’
Step4 : Get the 2nd 8 bit number
Step5 : Move the 2nd 8 bit number to register ‘C’
Step6 : Intialise the accumulator as zero
Step7 : Intialise the carry as zero
Step8 : Add both register ‘B’ value as accumulator
Step9 : Jump on if no carry
Step10 : Increment carry by 1 if there is
Step11 : Decrement the 2nd value and repeat from step 8, till the 2nd
value becomes zero.
Step12 : Store the multiplied value in accumulator
Step13 : Move the carry value to accumulator
Step14 : Store the carry value in accumulator
Flowchart
NO
YES
No
YES
Get the 1st 8 bit number
Move it to register ‘B’
Get the 2nd 8 bit number
Intialize the accumulator as zero & carry as zero
Add the accumulator with 1st number
Increment carry
Decrement 2nd number
Store the value f carry in accumulator
END
Check for carry
start
2nd Number
PROGRAM:
Address Label Mnemonics Hex Code Comments4100 LDA 4500 3A, 00, 45 Load the first 8 bit number4103 MOV B,A 47 Move the 1st 8 bit data to
register ‘B’4104 LDA 4501 3A, 01, 45 Load the 2nd 16 it number4107 MOV C,A 4F Move the 2nd 8 bit data to
register ‘C’4108 MVI A, 00 3E, 00 Intialise the accumulator as
zero410A MVI D, 00 16, 00 Intialise the carry as zero410C ADD B 80 Add the contents of ‘B’ and
accumulator410D INC D2 11, 41 Jump if no carry4110 INR D 14 Increment carry if there is4111 DCR C OD Decrement the value ‘C’4112 JNZ C2 0C, 41 Jump if number zero4115 STA 4502 32 02, 45 Store the result in
accumulator4118 MOV A,D 7A Move the carry into
accumulator4119 STA 4503 32,03,45 Store the result in
accumulator411C HLT 76 Stop the program execution
InputInput Address Value
4500 044501 02
OutputOutput Address Value
4502 084503 00
DIVISION OF TWO 8 – BIT NUMBERS
Aim:To write an assembly language program for dividing two 8 bit numbers using
microprocessor kit.
Apparatus required:8085 microprocessor kit Key board
Algorithm:Step1 : Start the microprocessor
Step2 : Intialise the Quotient as zero
Step3 : Load the 1st 8 bit data
Step4 : Copy the contents of accumulator into register ‘B’
Step5 : Load the 2nd 8 bit data
Step6 : Compare both the values
Step7 : Jump if divisor is greater than dividend
Step8 : Subtract the dividend value by divisor value
Step9 : Increment Quotient
Step10 : Jump to step 7, till the dividend becomes zero
Step11 : Store the result (Quotient) value in accumulator
Step12 : Move the remainder value to accumulator
Step13 : Store the result in accumulator
Step14 : Stop the program execution
Flow chart
NO
YES
YES
END
Store the Quotient in accumulator
Move the remainder to accumulator
Dividend
Decrement 2nd number
Increment carry
Check for carry
Add the accumulator with 1st number
Compare the dividend & divisor
Get the divisor
Intialise the Quotient as zero
Get the divided
START
Store the remainder in accumulator
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS4100 MVI B,00 0E,00 Clear the content of B Register.
4102 LXIH 4200 21,00,42 The content of data 4200 transfer to HL pair.
4105 MOV A,M 7E Move the content of memory location to A Register.
4106 INX H 23 Increment memory location.
4107 LOOP 1 SUB M 96 Subtract the content of memory location with accumulator.
4108 INR B 04 Increment the B register.4109 JNC 4107 (LOOP 1) D2,07,41 If carry = 0, jump to address 4107.410C DCR B 05 Decrement the B register.
410D ADD M 86 Add the content of memory location with accumulator.
411E STA 4301 32,01,43 Store the remainder in address 4301.
4111 MOV A,B 78 Move the B Register content to the accumulator.
4112 STA 4302 32,02,43 Store the quotient in address 4302.4115 HLT 76 End the program
OBSERVATION:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
4200 43004201 4301
RESULT:
Thus the ALP for 8 bit multiplication and division were performed and output was verified
EXPT .NO:
BLOCK TRANSFER OPERATION
AIM:
To perform a forward block transfer and reverse block transfer operation using 8085 microprocessor.
APPARATUS REQUIRED:
1. 8085 microprocessor kit2. keyboard
ALGORITHM (Forward block transfer):
1. Initialize the source address in HL register pair.2. Initialize the destination address in DE register pair3. Move the memory content pointed by HL pair to accumulator.4. Move accumulator content to memory location pointed by storing DE register.5. Increment the HL pair6. Increment the DE registers pair7. Decrement C register8. If there is no zero jump to step 49. Stop the Program.
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
4100 MVI C,05 0E,05 Clear the content of C registers.(Count 5)
4102 LXIH 4200 21,00,42 The content of data 4200 transfer to HL pair
4105 LXID 4300 21,00,43 The content of data 4300 transfer to DE pair
4108 LOOP 1 MOV A,M 7E Move the content of memory to accumulator
4109 STAX D 12 Store the accumulator content at D register.
410A INX H 23 Increment the H register410B INX D 13 Increment the D register410C DCR C 0D Decrement the C register410D JNZ 4108 (LOOP 1) C2,08,41 If carry = 0, jump to address 4108.4110 HLT 76 End the program
Flow chart
No
OBSERVATION:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
4200 4300
Clear the content of C registers. (Count value)
Load the content to H reg
Load the content to D reg
Store the Accumulator content D register
INR H Reg
END
Check for carry
START
INX D Reg
Move the content of memory to accumulator
4201 43014202 43024203 43034204 4304
ALGORITHM (Reverse transfer):
1. Initialize the source address in HL register pair.2. Initialize the destination address in DE register pair3. Move the memory content pointed by HL pair to C register4. Move the content of C register to E register5. Increment the HL pair6. Move the content of memory to accumulator7. Store the accumulator content at D register8. Decrement the D register9. Decrement the C register10. If carry = 0, jump to address 410711. End the program
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
4100 LXIH 4200 21,00,42 The content of data 4200 transfer to HL pair
4103 LXID 4300 21,00,43 The content of data 4200 transfer to DE pair
4106 MOV C,M 4E Move the content of memory to C register
4107 LOOP 1 MOV E,C 59 Move the content of C register to E register.
4108 INX H 23 Increment the H register
4109 MOV A,M 7E Move the content of memory to accumulator
410A STAX D 12 Store the accumulator content at D register.
410B DCX D 1B Decrement the D register410C DCR C 0D Decrement the C register410D JNZ 4107 (LOOP 1) C2,07,41 If carry = 0, jump to address 4107.4110 HLT 76 End the program
OBSERVATION:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
4200 (Count 4) 43004201 43014202 43024203 43034204
Flow Chart
No
RESULT:
Load the content to HL Pair (Count value)
Transfer content HL to DE Pair
Transfer the content of C register to E register.
INR H Reg
END
Check for carry
START
DCR C Reg
Transfer the content of memory to C Reg
Transfer the content of memory to accumulator
Store the accumulator content at D register.
DCX D Reg
Thus the forward block transfer and reverse block transfer operation were performed and output was verified.
EXPT .NO:
ARRAY OPERATION
AIM:
To perform a smallest and largest of numbers using 8085 microprocessor.
APPARATUS REQUIRED:
1. 8085 microprocessor kit2. Keyboard
ALGORITHM (LARGEST NUMBER):
1. Place all the elements of an array in the consecutive memory locations.2. Fetch the first element from the memory location and load it in the accumulator.3. Initialize a counter (register) with the total number of elements in an array.4. Decrement the counter by 1.5. Increment the memory pointer to point to the next element.6. Compare the accumulator content with the memory content (next Element).7. If the accumulator content is smaller, then move the memory content (Largest element) to the accumulator. Else continue.8. Decrement the counter by 1.9. Repeat steps 5 to 8 until the counter reaches zero10. Store the result (accumulator content) in the specified memory location
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS4100 MVI C,00 0E,00 Clear the content of C Register
4102 LXIH 4200 21,00,42 The content of data 4200 transfer to HL pair
4105 MOV C,M 4E Move the content of memory to C register
4106 INX H 23 Increment the H register
4107 MOV A,M 7E Move the content of memory to accumulator
4108 DCR C 0D Decrement the C register4109 LOOP 1 INX H 23 Increment the C register
410A CMP M BE Compare the content of memory with accumulator
410B JNC 410F (Loop 2) D2,0F,41 If carry = 0, jump to address 410F410E MOV A,M 7E Move the content of memory to
accumulator410F Loop 2 DCR C 0D Decrement the C register4110 JNZ 4109 (LOOP 1) C2,09,41 If carry = 0, jump to address 4109
4113 STA 4300 32,00,43 Store the largest number in the memory location
4116 HLT 76 End the program.OBSERVATION:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
4200 03 (Count) 4300420142024203
ALGORITHM (SMALLEST NUMBER):
1. Place all the elements of an array in the consecutive memory locations.2. Fetch the first element from the memory location and load it in the accumulator.3. Initialize a counter (register) with the total number of elements in an array.4. Decrement the counter by 1.5. Increment the memory pointer to point to the next element.6. Compare the accumulator content with the memory content (next Element).7. If the accumulator content is smaller, then move the memory content (Largest element) to the accumulator. Else continue.8. The counter by 1.9. Repeat steps 5 to 8 until the counter reaches zero10. Store the result (accumulator content) in the specified memory location
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS4100 MVI C,00 0E,00 Clear the content of C Register.
4102 LXIH 4200 21,00,42 The content of data 4200 transfer to HL pair
4105 MOV C,M 4E Move the content of memory to C register
4106 INX H 23 Increment the H register
4107 MOV A,M 7E Move the content of memory to accumulator
4108 DCR C 0D Decrement the C register4109 LOOP 1 INX H 23 Increment the C register
410A CMP M BE Compare the content of memory with accumulator
410B JC 410F (Loop 2) DA,0F,41 If carry = 1, jump to address 410F
410E MOV A,M 7E Move the content of memory to accumulator
410F LOOP 2 DCR C 0D Decrement the C register4110 JNZ 4109 (LOOP 1) C2,09,41 If carry = 0, jump to address 4109
4113 STA 4300 32,00,43 Store the Smallest number in the memory location
4116 HLT 76 End the program
OBSERVATION:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
4200 03(Count) 4300420142024203
RESULT:
Thus the largest and smallest number operation were performed and output was verified.
EXPT .NO:
SORTING
AIM:
To perform a ascending and descending order of using 8085 microprocessor.
APPARATUS REQUIRED:
1. 8085 microprocessor kit2. Keyboard
ALGORITHM (ascending order):1. Get the numbers to be sorted from the memory locations.2. Compare the first two numbers and if the first number is larger than second then Interchange the number.3. If the first number is smaller, go to step 44. Repeat steps 2 and 3 until the numbers are in required order
PROGRAM:ADDRESS LABEL MNEMONICS OPCODE COMMENTS
4100 LXIH 4200 21,00,42 The content of data 4200 transfer to HL pair
4103 MOV B,M 46 Move the content of memory to B register
4104 DCR B 05 Decrement the B register
4105 LOOP 1 MOV C,B 48 Move the content of B register to C register.
4106 LXIH 4201 21,01,42 The content of data 4201 transfer to HL pair
4109 LOOP 2 MOV A,M 7E Move the content of memory to accumulator
410A INX H 23 Increment the H register
410B MOV D,M 56 Move the content of memory to D register
410C CMP D BA Compare the content of D register with accumulator
410D JC 4114 (LOOP 3) DA,14,41 If carry = 1, jump to address 4114
4110 MOV M,A 77 Move the content of memory to accumulator
4111 DCX H 2B Decrement the H register
4112 MOV M,D 72 Move the content of D register to memory
4113 INX H 23 Increment the H register4114 LOOP 3 DCR C 0D Decrement the C register4115 JNZ 4109 (LOOP 2) C2,09,41 If zero flag = 0, jump to address 41094118 DCR B 05 Decrement the B register
4119 JNZ 4105 (LOOP 1) C2,05,41 If zero flag = 0, jump to address 4105411C HLT 76 End the program
OBSERVATION:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
4200 (Count 05) 42014201 42024202 42034203 42044204 42054205
ALGORITHM (Descending order):1. Get the numbers to be sorted from the memory locations.2. Compare the first two numbers and if the first number is smaller than second then I Interchange the number.3. If the first number is larger, go to step 44. Repeat steps 2 and 3 until the numbers are in required order
PROGRAM:ADDRESS LABEL MNEMONICS OPCODE COMMENTS
4100 LXIH 4200 21,00,42 The content of data 4200 transfer to HL pair
4103 MOV B,M 46 Move the content of memory to B register
4104 DCR B 05 Decrement the B register
4105 LOOP 1 MOV C,B 48 Move the content of B register to C register.
4106 LXIH 4201 21,01,42 The content of data 4201 transfer to HL pair
4109 LOOP 2 MOV A,M 7E Move the content of memory to accumulator
410A INX H 23 Increment the H register
410B MOV D,M 56 Move the content of memory to D register
410C CMP D BA Compare the content of D register with accumulator
410D JNC 4114 (LOOP 3) DA,14,41 If carry = 0, jump to address 4114
4110 MOV M,A 77 Move the content of memory to accumulator
4111 DCX H 2B Decrement the H register
4112 MOV M,D 72 Move the content of D register to memory
4113 INX H 23 Increment the H register4114 LOOP 3 DCR C 0D Decrement the C register4115 JNZ 4109 (LOOP 2) C2,09,41 If zero flag = 0, jump to address 41094118 DCR B 05 Decrement the B register
4119 JNZ 4105 (LOOP 1) C2,05,41 If zero flag = 0, jump to address 4105411C HLT 76 End the program
OBSERVATION:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
4200 (Count 05) 42014201 42024202 42034203 42044204 42054205
RESULT:
Thus the Ascending and Descending operation were performed and output was verified.
EXPT .NO:
CODECONVERSION
AIM:
To perform a code conversion for Following
1.HEXA DECIMAL TO ASCII2.ASCII TO HEXA DECIMAL3APPARATUS REQUIRED:
1. 8085 microprocessor kit2. Keyboard
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS4100 MVI C,00 0E,00 Clear the content of C Register.
4102 LHLD 4200 2A,00,42 Load the augend in DE pair through HL pair
4105 XCHG EB Transfer the content of HL pair to DE pair
4106 LHLD 4202 2A,02,42 Load the addend in HL pair
4109 MOV A,E 7B Move the content of E register to A register
410A SUB L 95 Subtract the content of L register with accumulator
410B STA 4204 32,04,42 Store the LSB in address location 4204
410E MOV A,D 7A Move the Content of D register to register A
410F SBB H 9C Subtract the content of H register and carry flag with accumulator
4110 STA 4205 32,05,42 Store the MSB in address location 42054113 JNC 4117 ( LOOP 1) D2,17,41 If there is no carry go to label (LOOP 1)
4116 INR C 0C Increment the C register
4117 LOOP 1 MOV A,C 79 Move the content of C Register to A register
4118 STA 4206 32,06,42 Store the carry in 4206 through accumulator ( MSB of sum )
411B HLT 76 End the program