Você está na página 1de 13

AVERAGE OF N NUMBERS

AIM:

To write an assembly language program that finds the average of N numbers and
execute the program using 8085 microprocessor kit.

APPARATUS REQUIRED:

8085 microprocessor kit, power supply.

ALGORITHM:

STEP 1: Load HL register pair with a memory pointer.


STEP 2: Get the count to B register and clear accumulator.
STEP 3: Push the count to stack pointer.
STEP 4: Increment memory pointer.
STEP 5: Add the content of memory location to accumulator.
STEP 6: If carry results increment D register.
STEP 7: Decrement count. If it is not zero go to STEP 4.
STEP 8: Else move the sum to E register.
STEP 9: Get the count from stack pointer.
STEP10: subtract the count from sum(content of DE pair).
STEP11:If the subtraction results a carry add the count to the result and get the remainder
STEP12: Otherwise increment B register content and go to STEP10.
STEP 13: Store the quotient and remainder in successive memory location.

PROGRAM:

MEMORY MAHINE LABEL MNEMONICS COMMENTS


LOATION CODE
4100 21,00,42 LXI H, 4200 Initialize HL register
pair with memory
pointer
4103 46 MOV B,M Transfer the memory
content to B register
4104 C5 PUSH B Push the content of B
register to stack
pointer
4105 AF XRA A Clear accumulator
4106 57 MOV D,A Clear D register
4107 5F MOV E,A Clear E register
4108 23 LOOP1 INX H Increment memory
pointer
4109 86 ADD M Add the content of
memory location to
accumulator
410A D2,0E,41 JNZ LOOP2 Jump on no carry to
LOOP2
410D 14 INR D Increment D register
content
410E 05 LOOP2 DCR B Decrement B register
content
410F C2,08,41 JNZ LOOP1 Jump on zero to
LOOP!
4112 5F MOV E,A Move the content of
accumulator to E
register
4113 C1 POP B Retrieve the content
of B register from
stack
4114 26,00 MVI H,00 Clear H register
4116 68 MOV L,B Move the[B] to L
register
4118 7B LOOP4 MOV A, E Mover the[E] content
to accumulator
4119 95 SUB L Subtract [L] content
from accumulator
411A 5F MOV E,A Move the
accumulator content
to E register
411B 7A MOV A, D Mover the[B] to
accumulator
411C 9C SBB H Subtract [H] from
accumulator through
borrow
411D DA,25,41 JC LOOP3 Jump on carry to
LOOP3
4120 57 MOV D,A Move accumulator
content to D register
4121 04 INR B Increment B register
4122 C3,18,41 JMP LOOP 4 Jump to LOOP4
4125 7B LOOP3 MOV A,E Move[E] to
accumulator
4126 85 ADD L Add [L] with
accumulator content
4217 5F MOV E,A Move accumulator
content to E register
4128 78 MOV A,B Move [B] register to
accumulator
4129 32,00,43 STA 4300 Store the
accumulator content
in 4300
412C EB XCHG Exchange [DE] with[
HL]
412D 22,01,43 SHLD 4301 Store the remainder
in 4301 and 4302
4130 76 HLT Ends execution

SAMPLE INPUT AND OUTPUT:


MEMORY INPUT MEMORY OUTPUT
LOCARION LOCATION

RESULT:

Thus an 8085 assembly language program that finds average of N numbers was
written and executed using microprocessor kit.

SQUARE ROOT OF A NUMBER


AIM:

To write an assembly language program that finds the average of N numbers


and execute the program using 8085 microprocessor kit.

APPARATUS REQUIRED:

8085 microprocessor kit, power supply.


METHOD TO FIND SQUARE ROOT OF A NUMBER:

Suppose that X is the square root of number N. to find a suitable equation


to be used by the computer for iteration the following multiplication is done.

X2=N
2 X2=N+ X2
X2=(N+ X2)/2
X=(N+ X2)/(2*X)
X=((N/X)+X)/2
Xnew= ((N/X)+X)/2

To find the square root of a given number we provide an initial value of the
root, which may be very approximate. In the above equation X is the initial value of the
root given by the programmer. The computer calculates Xnew and compare it with X.
when Xnew=X, it gives the result =Xnew.

ALGORITHM:
Step1: load HL register pair with a memory pointer.
Step2: get the number into an accumulator and E register.
Step3: increment memory pointer.
Step4: get the initial guess to D and B registers.
Step5: call the division program.
Step6: add the initial guess with the accumulator.
Step7: divide the content of accumulator by a value 2 using division program.
Step8: if the calculated value is equal to guess, store the result in the memory location.
Step9: else take calculated value as guess and go to step5.

PROGRAM:

MEMORY MACHINE LABEL MNIMONICS COMMENTS


LOCATION CODE
4100 21,00,42 LXIH, 4200 Initialize HL register
pair with memory
pointer
4103 7E MOV A, M Transfer the content
of memory location to
accumulator
4104 5E MOV E, M Transfer the content
of memory location to
E register
4105 23 INX H Increment memory
pointer
4106 56 MOV D, M Move the initial guess
to D register
4107 46 MOV B,M Move the initial guess
to to B register
4108 0E,00 LOOP3 MVI C,00 Clear C register
410A CD,1E,41 CALL DIV Call division program
410D 80 ADDB Add guess with
accumulator
410E 06,02 MVI B,02 Move 02 to B register
4110 0E,00 MVI C,00 Clear C register
4112 CD,1E,41 CALL DIV Call division program
4115 7A MOV A,D Move [D] to
accumulator
4117 B9 CMP C Compare the guess
with calculated value
4118 C2,28,41 JNZ LOOP1 Jump on no zero to
loop1
411B 23 INX H Increment memory
pointer
411C 71 MOV M,C Move [C] to memory
location
411D 76 HLT Ends execution
411E 90 DIV SUB B Subtract [B] from
accumulator
411F DA,26,41 JC LOOP2 Jump on carry to
loop2
4122 0C INR C Increment C register
content
4123 C3,1E,41 JMP DIV Jump to division
program
4126 79 LOOP2 MOV A,C Move [C] to
accumulator
4127 C9 RET Return to main
program
4128 7B LOOP1 MOV A,E Move[E] to
accumulator
4129 41 MOV B,C Move [B] to C
register
412A C3,08,41 JMP LOOP3 Jump to loop3
SAMPLE INPUT AND OUTPUT:

INPUT DATA [4200] OUTPUT DATA [4202]

RESULT:

Thus an 8085 assembly language program that finds the square root of a given
number was written and executed using microprocessor kit.

GENERATION OF TIME DELAY

AIM:

To write an assembly language program to generate time delay and execute


the program using 8085 microprocessor kit.

APPARATUS REQUIRED:

8085 microprocessor kit, power supply.

ALGORITHM:

Step1: Move the outer loop count to the C register.


Step 2: Load the inner loop count to DE register pair.
Step 3: Decrement DE reg pair content.
Step 4: Check whether DE register pair content is 0, if not go to step 3.
Step 5: Decrement C register.
Step 6: If C register content is not 0, go to step 2.
CALCULATION:

DCX D —6T
MOV A,E—4T
ORA D —4T
JNZ loop —10T
=24T
24×N×0.33×10-6=0.5
N=63132
=(F69C)H
For delay of 10 s loop is called 20 times.
(20)10=14H

PROGRAM:

MEMORY MACHINE LABEL MNEMONICS COMMENTS


LOCATION CODE
4100 0E,14 MVI C,14 Initialize outer
loop count
4102 11,9C,F6 Loop 1 LXI D,F69C Initialize inner
loop count
4105 1B Loop DCX D Decrement
inner loop
count
4106 7B MOV A,E Move the
contents of E
register to
accumulator
4107 B2 ORA D Check whether
DE register pair
contents is zero.
4108 C2,05,41 JNZ Loop If [DE] not zero
go to loop
410B 0D DCR C Decrement
outer loop
count
410C C2,02,41 JNZ Loop1 If [C]not zero
go to loop1
410F C7 RST Reset

RESULT:
Thus the time delay of 10 seconds has been generated using microprocessor
8085 kit and the output has been verified.
DECIMAL COUNTER

AIM:

To write an assembly language program to realize a decimal counter and


execute the program using 8085 microprocessor kit.

APPARATUS REQUIRED:

8085 microprocessor kit, power supply.

ALGORITHM:

Step 1:initialize L register with 00.


Step 2:adjust the contents of ‘L’register to decimal value and store it in 4200.
Step 3:call monitor program to display L register in data field.
Step 4: call delay program to give a delay of two sec.
Step 5: copy the contents of 4200 to L register through A
Step 6:increment contents of Lregister and go to step 2.

SUBROUTINE:

Step1:move the outer loop count to the C register.


Step 2:load the inner loop count to DE register pair.
Step 3:decrement DE reg pair content.
Step 4:check whether DE register pair content is 0, if not go to step 3.
Step 5: decrement C register.
Step 6:if C register content is not 0, go to step 2.

CALCULATION:
DCX D —6T
MOV A,E—4T
ORA D —4T
JNZ loop —10T
=24T
24×N×0.33×10-6=0.5
N=63132
=(F69C)H
For delay of 2 s loop is called 4 times.
(4)10=(4)H

MEMORY MACHINE LABEL MNEMONICS COMMENTS


LOCATION CODE
4300 2E,00 MVI L,00 Initialize L
register with 00
4302 7D Loop 1 MOV A,L Move the
contents of L
register to
accumulator.
4303 27 DAA Decimal adjust
accumulator
4304 6F MOV L,A Move the
contents of L
register to
accumulator.
4305 32,00,42 STA 4200 Store the
accumulator
contents to
4200
4308 3E,0B MVI A,0B Initialize
accumulator
with 0B
430A 0E,02 MVI C,02 Initialize C
register with 02
430C CD,05,00 CALL 0005 Call monitor
program to
display L
register
contents
430F CD,00,41 CALL delay Call delay
program
4312 3A,00,42 LDA 4200 Load
accumulator
with 4200
contents
4315 6F MOV L,A Move
accumulator to
L register
contents
4316 2C INR L Increment L
register
contents
4317 C3,02,43 JMP Loop Jump to loop
SUBROUTINE:

MEMORY MACHINE LABEL MNEMONICS COMMENTS


LOCATION CODE
4100 0E,04 MVI C,04 Initialize outer
loop count
4102 11,9C,F6 Loop 1 LXI D,F69C Initialize inner
loop count
4105 1B Loop DCX D Decrement
inner loop
count
4106 7B MOV A,E Move the
contents of E
register to
accumulator
4107 B2 ORA D Check whether
DE register pair
contents is zero.
4108 C2,05,41 JNZ Loop If [DE] not zero
go to loop
410B 0D DCR C Decrement
outer loop
count
410C C2,02,41 JNZ Loop1 If [C]not zero
go to loop1
410F C9 RET Return to main
program

RESULT:
Thus the decimal counter has been realized using 8085 microprocessor kit and
the result has been verified.
HEXADECIMAL COUNTER

AIM:

To write an assembly language program to realize a hexadecimal counter and


execute the program using 8085 microprocessor kit.

APPARATUS REQUIRED:

8085 microprocessor kit, power supply.

ALGORITHM:

Step 1: Initialize L register with 00.


Step 2: Store the contents of ‘L’register in 4200.
Step 3: Call monitor program to display L register in data field.
Step 4: Call delay program to give a delay of two sec.
Step 5: Copy the contents of 4200 to L register through A
Step 6: Increment contents of Lregister and go to step 2.

SUBROUTINE:

Step1: Move the outer loop count to the C register.


Step 2: Load the inner loop count to DE register pair.
Step 3: Decrement DE reg pair content.
Step 4: Check whether DE register pair content is 0, if not go to step 3.
Step 5: Decrement C register.
Step 6: If C register content is not 0, go to step 2.

CALCULATION:
DCX D —6T
MOV A,E—4T
ORA D —4T
JNZ loop —10T
=24T
24×N×0.33×10-6=0.5
N=63132
=(F69C)H
For delay of 2 s loop is called 4 times.
(4)10=4H

MEMORY MACHINE LABEL MNEMONICS COMMENTS


LOCATION CODE
4300 2E,00 MVI L,00 Initialize L
register with 00
4302 7D Loop 1 MOV A,L Move the
contents of L
register to
accumulator.

4303 32,00,42 STA 4200 Store the


accumulator
contents to
4200
4306 3E,0B MVI A,0B Initialize
accumulator
with 0B
4308 0E,02 MVI C,02 Initialize C
register with 02
430A CD,05,00 CALL 0005 Call monitor
program to
display L
register
contents
430D CD,00,41 CALL delay Call delay
program
4310 3A,00,42 LDA 4200 Load
accumulator
with 4200
contents
4313 6F MOV L,A Move
accumulator to
L register
contents
4314 2C INR L Increment L
register
contents
4315 C3,02,43 JMP Loop Jump to loop
SUBROUTINE:

MEMORY MACHINE LABEL MNEMONICS COMMENTS


LOCATION CODE
4100 0E,04 MVI C,04 Initialize outer
loop count
4102 11,9C,F6 Loop 1 LXI D,F69C Initialize inner
loop count
4105 1B Loop DCX D Decrement
inner loop
count
4106 7B MOV A,E Move the
contents of E
register to
accumulator
4107 B2 ORA D Check whether
DE register pair
contents is zero.
4108 C2,05,41 JNZ Loop If [DE] not zero
go to loop
410B 0D DCR C Decrement
outer loop
count
410C C2,02,41 JNZ Loop1 If [C]not zero
go to loop1
410F C9 RET Return to main
program

RESULT:
Thus the hexadecimal counter has been realized using 8085 microprocessor kit
and the result has been verified.

Você também pode gostar