GCD of Two Numberss


AIM:
 To write a program to determine GCD of Two Numberss

ALGORITHM:
 1.Compare number 1(no1) with number 2(no2).If no1==no2,go to step 3.Else if no1<no2 ,then exchange no1 and no2.
 2.no1=no1-no2; go to step 1
 3.Display result as no1.


ARRANGE AN ARRAY OF DATA IN ASCENDING ORDER


AIM:
 To write a program to arrange an array of data in ascending order

ALGORITHM:
 1.Initialize HL pair as memory pointer
 2.Get the count at 3200 into C – register
 3.Copy it in D – register (for bubble sort (N-1) times required)
 4.Get the first value in A – register
 5.Compare it with the value at next location.
 6.If they are out of order, exchange the contents of A –register and Memory
 7.Decrement D –register content by 1
 8.Repeat steps 5 and 7 till the value in D- register become zero
 9.Decrement C –register content by 1
 10.Repeat steps 3 to 9 till the value in C – register becomes zero



SMALLEST NUMBER IN AN ARRAY OF DATA

AIM:
     To find the smallest number in an array of data using 8085 instruction set.
     
ALGORITHM:
     1) Load the address of the first element of the array in HL pair
     2) Move the count to B – reg.
     3) Increment the pointer
     4) Get the first data in A – reg.
     5) Decrement the count.
     6) Increment the pointer
     7) Compare the content of memory addressed by HL pair with that of A - reg.
     8) If carry = 1, go to step 10 or if Carry = 0 go to step 9
     9) Move the content of memory addressed by HL to A – reg.
     10) Decrement the count
     11) Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step.
     12) Store the smallest data in memory.
     13) Terminate the program.
     
PROGRAM:
             LXI H,4200 Set pointer for array
             MOV B,M         Load the Count
             INX  H         Set 1st element as largest data
             MOV A,M
             DCR B         Decremented the count
LOOP:    INX H
             CMP M         If A- reg < M go to AHEAD
             JC AHEAD
             MOV A,M        Set the new value as smallest
AHEAD:DCR B
             JNZ LOOP   Repeat comparisons till count = 0
             STA 4300        Store the largest value at 4300
             HLT

OBSERVATION:
                   05 (4200) ----- Array Size
    Input:
                   0A (4201)
                   F1 (4202)
                   1F (4203)
                   26 (4204)
                   FE (4205)
                   0A (4300)
    Output:
    
RESULT:
Thus the program to find the smallest number in an array of data was executed

LARGEST NUMBER IN AN ARRAY OF DATA

AIM:
     To find the largest number in an array of data using 8085 instruction set.
     
ALGORITHM:
     1) Load the address of the first element of the array in HL pair
     2) Move the count to B – reg.
     3) Increment the pointer
     4) Get the first data in A – reg.
     5) Decrement the count.
     6) Increment the pointer
     7) Compare the content of memory addressed by HL pair with that of A - reg.
     8) If Carry = 0, go to step 10 or if Carry = 1 go to step 9
     9) Move the content of memory addressed by HL to A – reg.
     10) Decrement the count
     11) Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step.
     12) Store the largest data in memory.
     13) Terminate the program.
     
PROGRAM:
             LXI H,4200 Set pointer for array
             MOV B,M    Load the Count
             INX H         Set 1st element as largest data
             MOV A,M
             DCR B         Decrements the count
LOOP:  INX H
             CMP M          f A- reg > M go to AHEAD
             JNC AHEAD
             MOVA,M   Set the new value as largest
AHEAD:DCR B
             JNZ LOOP     Repeat comparisons till count = 0
             STA 4300     Store the largest value at 4300
             HLT

OBSERVATION:
                   
    Input: 05 (4200) ----- Array Size
                   
    Output: 0A (4201)
                F1 (4202)
              1F (4203)
                26 (4204)
                FE (4205)
                FE (4300)
    
RESULT:
Thus the program to find the largest number in an array of data was executed

DIVISION OF TWO 8 BIT NUMBERS

AIM:
     To perform the division of two 8 bit numbers using 8085.
     
ALGORITHM:
     1) Start the program by loading HL register pair with address of memory location.
     2) Move the data to a register(B register).
     3) Get the second data and load into Accumulator.
     4) Compare the two numbers to check for carry.
     5) Subtract the two numbers.
     6) Increment the value of carry .
     7) Check whether repeated subtraction is over and store the value of product and
        carry in memory location.
     8) Terminate the program.
     

MULTIPLICATION OF TWO 8 BIT NUMBERS


AIM:
     To perform the multiplication of two 8 bit numbers using 8085.
   
ALGORITHM:
     1) Start the program by loading HL register pair with address of memory location.
     2) Move the data to a register (B register).
     3) Get the second data and load into Accumulator.
        Add the two register contents
     4) Check for carry.
        Increment the value of carry.
     5) Check whether repeated addition is over and store the value of product and carry
        in memory location.
     6) Terminate the program.

SUBTRACTION OF TWO 8 BIT NUMBERS

AIM:
     To perform the subtraction of two 8 bit numbers using 8085.
   
ALGORITHM:
     1. Start the program by loading the first data into Accumulator.
        Move the data to a register (B register).
     2. Get the second data and load into Accumulator.
     3. Subtract the two register contents.
     4. Check for carry.
     5. If carry is present take 2’s complement of Accumulator.
     6. Store the value of borrow in memory location.
     7. Store the difference value (present in Accumulator) to a memory
     8. location and terminate the program.