0% found this document useful (0 votes)
12 views18 pages

Mic Microproject

The document describes an assembly language program that counts the number of positive numbers in an array using an 8086 microprocessor. It includes the algorithm, required software and devices, advantages and disadvantages of the approach, user interface, program code explanation, and conclusion.

Uploaded by

gaming14coc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
12 views18 pages

Mic Microproject

The document describes an assembly language program that counts the number of positive numbers in an array using an 8086 microprocessor. It includes the algorithm, required software and devices, advantages and disadvantages of the approach, user interface, program code explanation, and conclusion.

Uploaded by

gaming14coc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 18

BHIVARABAI SAWANT POLYTECHNIC

WAGHOLI ‘PUNE’ 412207

*WELCOME*
IN MIC MICRO PROJECT
INDEX
NO. TITLE
WELCOME PAGE
1
SUBMMITED STUDENT NAME
2
INTRODUCTION ABOUT
3
PROJECT
4 REQUIRED SOFTWARE AND DEVICES

5 ADVANTAGE AND DISADVANTAGE

6 USER INTERFACE

7 PROGRAM

8 OUTPUT

9 EXPLAINATION OF PROGRAM

10 CONCLUSION
11 THANKING PAGE
 PROJECT SUBMITTED BY
ROLL NAME
NO.
37 Atharva Chavan

38 Naresh Patil

39 Prem Khaire

40 Pratik Dhole
Introduction of Positive Numbers in
array
:
The most significant bit (MSB) i. e. D7 or D15 in 8bit or 16bit signed
magnitudes number sign od the number i.e. D7 or D15 as shown fig. Given
below

Hence, by checking most significant bit, we can find out a byte or word is positive number. Most
significant bit i.e. D7 or D15 for byte or word can be checked using either ROL or RCL instruction as given
in fig. Given below.
Problem – Write an assembly language program in 8085 microprocessor to
count the positive number in array

Algorithm –
1. Initialize the data segment.

2. Initialize CL register as a byte counter and DH register as


counter for counting positive numbers.

3. Set SI as a memory pointer to read the numbers from an


array.

4. Read the number from array in register AL.

5. Rotate AL by 1 bit position to the left.

6. If not carry then go to step 8


else
Goto next step.

7. Increment DH by 1 and go to step 9.


8. Increment memory pointer in SI which points to next element
of array.

9. Decrement byte counter in CL by 1.

10. CL is not equal to zero then goto step 4, otherwise go to


next step.

11. Store the result.

12. Stop.
 Required Software and devices

To write and run a program to count the positive numbers in an array


using the 8086 microprocessor, you will need the following:

1.Assembler: An assembler is needed to convert the assembly language


code into machine code that the 8086 microprocessor can execute.
Popular assemblers for the 8086 include NASM (Netwide Assembler)
and MASM (Microsoft Macro Assembler).

2.8086 Emulator or Simulator: Since the 8086 microprocessor is an


older architecture, you will likely need an emulator or simulator to run
your code on a modern computer. Examples include DOSBox,
EMU8086, and PCem.

3.Text Editor: A text editor is needed to write your assembly language


code. You can use any text editor of your choice, such as Notepad++,
Visual Studio Code, or Sublime Text.

4.8086 Development Board (Optional): If you want to run your code on


actual hardware, you will need an 8086 development board. However,
this is not necessary for most learning and development purposes.
Here's a general overview of the steps you would follow:

1.Write your assembly language code using a text editor.


2.Assemble the code using an assembler to generate a machine code
file.
3.Load the machine code file into an 8086 emulator or simulator.
4.Run the emulator or simulator to execute your program.
5.Check the output to see the count of positive numbers in the array.
6.Keep in mind that the specific steps may vary depending on the
assembler and emulator/simulator you choose to use.

ADVANTAGE AND DISADVANTAGE


Advantages:
1. Efficiency: The 8086 microprocessor is optimized for handling
numerical operations, making it efficient for tasks like counting positive
numbers in an array.
2. Low-level control:Programming directly in assembly language for the
8086 allows for precise control over memory and registers, which can
be beneficial for performance-critical applications.
3. Learning:Writing programs for the 8086 can deepen understanding
of computer architecture and low-level programming concepts.

Disadvantages:
1. Complexity: Assembly language programming for the 8086 is
complex and requires a deep understanding of the processor's
architecture, making it less accessible for beginners.
2. Debugging: Debugging assembly language programs can be
challenging due to the lack of high-level constructs and the need to
manually manage memory and registers.
3. Portability:Code written for the 8086 is not easily portable to other
architectures, limiting its usefulness in cross-platform development.

USER INTERFACE
In the context of the 8086 microprocessor, there is no built-in concept of a
graphical user interface (GUI) as we know it today. Programs written for the 8086
typically interact with the user through the console, using text-based input and
output.

For the program to count positive numbers in an array, the user interface would
be quite simple. Here's a basic outline:

1. Display a Prompt: The program would start by displaying a prompt or message


to inform the user about the purpose of the program.

2. Input Array:The program would then ask the user to input the array elements,
typically by entering numbers separated by spaces or commas.

3. Process Data: The program would process the input array to count the positive
numbers.

4. Display Result:Finally, the program would display the count of positive numbers
to the user

In actual 8086 assembly language, the implementation would involve more


detailed handling of input/output operations and array processing, but the basic
structure would be similar.

Program –; Program to count the positive


numbers in an array
.MODEL SMALL
.STACK 100H

.DATA
ARR_SIZE DW 8
ARR DB 2, -5, 6, -7, 8, -1, 10, -3
POS_COUNT DB 0

.CODE
MOV AX, @DATA
MOV DS, AX

MOV CX, ARR_SIZE


XOR AL, AL

LEA SI, ARR

COUNT_LOOP:
MOV BL, [SI]
CMP BL, 0
JLE NEXT_ELEMENT
INC AL
NEXT_ELEMENT:
INC SI
LOOP COUNT_LOOP

MOV POS_COUNT, AL

MOV AH, 02H


MOV DL, POS_COUNT
ADD DL, 30H
INT 21H

MOV AH, 4CH


INT 21H

END

OUTPUT

Output : The positive Numbers are 2,6,8,10.

Explanation of the
program:
1. `.MODEL SMALL` and `.STACK 100H`: These
directives specify the memory model and the stack
size, respectively.

2. `.DATA` section: Here, you define the size of the


array (`ARR_SIZE`), the array itself (`ARR`), and a
variable to store the count of positive numbers
(`POS_COUNT`).

3. `.CODE` section: This is where the main code


logic resides.

4. `MOV AX, @DATA` and `MOV DS, AX`: These


instructions set up the data segment.

5. `MOV CX, ARR_SIZE` and `XOR AL, AL`: These


initialize the loop counter (`CX`) with the array size
and clear the `AL` register to store the count of
positive numbers.

6. `LEA SI, ARR`: This loads the address of the


array into the source index register (`SI`).

7. `COUNT_LOOP` is a label for the loop.


8. `MOV BL, [SI]`: This loads the current element of
the array into the `BL` register.

9. `CMP BL, 0` and `JLE NEXT_ELEMENT`: These


compare the element with zero and jump to
`NEXT_ELEMENT` if the element is less than or
equal to zero.

10. `INC AL` increments `AL` if the element is


positive.

11. `NEXT_ELEMENT` increments `SI` to move to


the next element and uses `LOOP COUNT_LOOP`
to repeat the loop for the remaining elements.

12. `MOV POS_COUNT, AL` stores the count of


positive numbers in `POS_COUNT`.

13. Displaying the result: `MOV AH, 02H` sets up


the display function, `MOV DL, POS_COUNT` loads
the count of positive numbers into `DL`, `ADD DL,
30H` converts the count to ASCII, and `INT 21H`
displays the count.

14. `MOV AH, 4CH` and `INT 21H` terminate the


program.
Overall, the program efficiently counts the positive
numbers in the array.

CONCLUSION

In conclusion, implementing a program to count the


positive numbers in an array using the 8086
microprocessor involves several key steps.

Firstly, the program must initialize the data segment


and set up the array containing the numbers to be
processed. It then uses a loop to iterate through
each element of the array, checking if the element
is positive. If the element is positive, a counter is
incremented to keep track of the total number of
positive numbers encountered.

Once all elements have been processed, the


program displays the count of positive numbers to
the user. This is typically done by converting the
count to ASCII characters and outputting them to
the console.

Overall, while programming for the 8086


microprocessor requires a deep understanding of its
architecture and assembly language, implementing
simple tasks like counting positive numbers in an
array can provide valuable insights into low-level
programming concepts.

You might also like