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

DTMP MP

The document is a micro-project report on developing a simple calculator using 8086 assembly language programming, aimed at enhancing students' understanding of low-level programming concepts. It outlines the project background, objectives, technical approach, and the structure of the program, along with a sample code implementation. The project serves as a foundational exercise for mastering assembly language and understanding hardware-software interaction, with practical applications in embedded systems and operating system development.

Uploaded by

muttalwadvikas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views12 pages

DTMP MP

The document is a micro-project report on developing a simple calculator using 8086 assembly language programming, aimed at enhancing students' understanding of low-level programming concepts. It outlines the project background, objectives, technical approach, and the structure of the program, along with a sample code implementation. The project serves as a foundational exercise for mastering assembly language and understanding hardware-software interaction, with practical applications in embedded systems and operating system development.

Uploaded by

muttalwadvikas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

GOVERNMENTPOLYTECHNICPUNE

(AnAutonomousInstituteofMaharashtra)

DEPARTMENTOFCOMPUTERENGINEERINGACADEMIC
YEAR : 2024-25

Micro-Project Report on the topic:


Developing a Simple Calculator Using 8086 Assembly Language Programming

Course: Digital Techniques And

Microprocessors Programming

Course Code: CM31204

Guided by:
Smt. B. [Link]
Lecturer Government Polytechnic Pune

1
GOVERNMENTPOLYTECHNICPUNE
(AnAutonomousInstituteofMaharashtra)

DEPARTMENTOFCOMPUTERENGINEERINGACADEMIC
YEAR : 2024-25

CERTIFICATE
This is to certify that the micro-project entitled “Developing a Simple
Calculator Using 8086 Assembly Language Programming ” is bonafide
work carried out by:Omkar Jagtap-2306075 of class Second Year in
partial fulfillment of the requirement for the completion of course Digital
Techniques And Microprocessors Programming (CM31204) - ODD 2024
of Diploma in Computer Engineering from Government Polytechnic Pune.
The report has been approved as it satisfies the academic requirements in
respect of micro- project work prescribed for the course.

Prof. B.R Amrutkar Mrs. [Link] [Link]

(Microproject Guide) (Head of Department) (Principal)

2
ProjectReport

Background

The 8086 microprocessor is one of the earliest processors developed for personal computers.
Learning assembly language for this processor provides foundational knowledge of how hardware
and software interact at the most basic level. A simple calculator is an excellent beginner project
that demonstrates input/output handling, arithmetic operations, and memory manipulation in a low-
level environment like assembly language. This project reinforces the basic concepts of assembly
language programming such as register manipulation, using interrupts for I/O operations, and
arithmetic computations, while providing a hands-on experience in writing structured code for the
8086 microprocessor.

ProblemStatement
Developing a Simple Calculator Using 8086 Assembly Language Programming . A computer
science student is learning 8086 assembly language programming and wants to develop a simple
application to reinforce their understanding of the language. They decide to create a basic calculator
program that can perform addition, subtraction, multiplication, and division operations on two
operands entered by the user.

Objectives

The main objectives of this project are:

• To develop a basic calculator program in 8086 assembly language that performs addition,
subtraction, multiplication, and division.
• To enhance understanding of basic 8086 instructions, particularly those related to arithmetic
(ADD, SUB, MUL, DIV), control flow (CMP, JE, etc.), and input/output handling using interrupts
(INT 21h).
• To practice converting user input from ASCII characters to integers and outputting results in
a user-friendly format.
• To develop a practical understanding of the 8086 architecture, registers, and stack
management.

3
StructureUsed

The structure of the program can be broken down into the following components:

• Data Segment: Contains the variables and strings used for input/output, such as
prompts for the user, and space to store operands and results.
• Code Segment:
1. Initialization: Set up the data segment and stack.
2. User Input Handling: Prompt the user to enter two numbers and an
operation, using DOS interrupts for reading keyboard input (INT
21h).
3. Operation Selection: Based on the operation entered (+, -, *, /), the
program directs to the corresponding arithmetic operation using
comparison instructions (CMP and JE).
4. Arithmetic Computation: Perform addition, subtraction,
multiplication, or division using basic 8086 arithmetic instructions
(ADD, SUB, MUL, DIV).
5. Output Handling: Convert the result to an ASCII value and display it
using DOS interrupts.
6. Termination: End the program with a proper system exit call (INT
21h, AH = 4Ch).
• .

4
TechnicalApproach

The technical approach to developing the 8086 assembly language calculator includes the following
steps:

• Input Handling: Use DOS interrupt INT 21h with function AH = 01h to take single
character inputs from the user. The input characters (ASCII values) are stored in memory or
registers and then converted to integers by subtracting 30h (the ASCII value of '0').
• Processing Arithmetic Operations:
o The arithmetic operations are handled using native 8086 instructions: ADD for
addition, SUB for subtraction, MUL for multiplication, and DIV for division.
o Each operation manipulates data stored in registers (usually the AL register) and
performs the calculation.
• Control Flow:
o The program uses CMP and JE instructions to compare the user’s input and jump to
the appropriate arithmetic section (e.g., addition, subtraction).
o A simple control structure directs the flow based on the user-selected operation (+, -,
*, /).
• Result Handling: Once the arithmetic operation is performed, the result is stored in a
register. It is converted back into an ASCII character (by adding 30h) for display and
outputted to the screen using INT 21h, AH = 02h.
• Output: The output is displayed using DOS interrupts, and the results are displayed as
characters on the screen, with accompanying messages.

RationaleforKeyDesignChoices

• Assembly Language: The decision to use assembly language is key to understanding how
software interacts with hardware at a low level. Working with registers and direct memory access
helps solidify the fundamentals of computation and I/O handling, which are crucial in systems
programming.

• Using DOS Interrupts: The use of DOS interrupts (INT 21h) for handling input and output was
chosen because it provides a straightforward way to interact with the user through the console. This
simplifies reading from the keyboard and displaying characters without needing to manually control
hardware-level I/O.

• Simple Data Handling (One-Digit Operands): To keep the focus on learning assembly
instructions and control structures, the program is designed to handle single-digit numbers. More
complex multi-digit handling would require additional logic for string manipulation and is beyond
the scope of this introductory project.

5
CosCovered:
• CO3: Analyze 8086 microprocessor functionality.
• CO4: Develop assembly language programs.
• CO5: Use procedure and macro in assembly language programs.

Program:
.MODEL SMALL
.STACK 100H

.DATA
num1 DB 0 ; First number input by user
num2 DB 0 ; Second number input by user
result DB ? ; Result of the calculation
prompt1 DB 'Enter first number: $'
prompt2 DB 'Enter second number: $'
promptOp DB 'Enter operation (+,-,*,/): $'
msgAdd DB 'Addition result: $'
msgSub DB 'Subtraction result: $'
msgMul DB 'Multiplication result: $'
msgDiv DB 'Division result: $'

.CODE
START:
MOV AX, @DATA
MOV DS, AX

; Get first number from user


LEA DX, prompt1
MOV AH, 09H
INT 21H

; Read first number


MOV AH, 01H
INT 21H
SUB AL, '0' ; Convert ASCII to integer
MOV num1, AL

; Get second number from user


LEA DX, prompt2
MOV AH, 09H
INT 21H

; Read second number


MOV AH, 01H
INT 21H
SUB AL, '0'
MOV num2, AL

6
; Get the operation (+,-,*,/)
LEA DX, promptOp
MOV AH, 09H
INT 21H

; Read operation character


MOV AH, 01H
INT 21H

; Perform the operation


CMP AL, '+' ; Check for addition
JE ADDITION
CMP AL, '-' ; Check for subtraction
JE SUBTRACTION
CMP AL, '*' ; Check for multiplication
JE MULTIPLICATION
CMP AL, '/' ; Check for division
JE DIVISION

; Addition
ADDITION:
MOV AL, num1
ADD AL, num2
MOV result, AL
LEA DX, msgAdd
MOV AH, 09H
INT 21H
JMP PRINT_RESULT

; Subtraction
SUBTRACTION:
MOV AL, num1
SUB AL, num2
MOV result, AL
LEA DX, msgSub
MOV AH, 09H
INT 21H
JMP PRINT_RESULT

7
; Multiplication
MULTIPLICATION:
MOV AL, num1
MOV BL, num2
MUL BL
MOV result, AL
LEA DX, msgMul
MOV AH, 09H
INT 21H
JMP PRINT_RESULT

; Division
DIVISION:
MOV AL, num1
MOV BL, num2
DIV BL
MOV result, AL
LEA DX, msgDiv
MOV AH, 09H
INT 21H

PRINT_RESULT:
; Convert result to ASCII and display
ADD result, '0'
MOV DL, result
MOV AH, 02H
INT 21H

; Terminate program
MOV AH, 4CH
INT 21H

END START

Output:

8
9
10
Real-LifeUse:

1. Embedded Systems Programming


• Embedded systems are used in devices like washing machines, microwave ovens, and traffic lights,
where low-level programming and interaction with hardware are crucial. Assembly language is often
used in embedded systems due to its ability to control hardware directly and efficiently.
• The 8086 calculator project teaches how to manage input/output operations and basic arithmetic
computations, which are fundamental skills for programming simple embedded systems that perform
similar tasks (reading input, processing it, and outputting results).

2. Operating System Development


• Operating systems (OS) use low-level assembly code to interact with the hardware. The calculator
project provides a beginner’s understanding of how to handle user input/output using interrupts ( INT
21h in DOS), a concept that's extended in OS development.
• Understanding how basic arithmetic and system control instructions work at the processor level can
help in developing drivers or routines that manage resources, memory, or devices in an OS.

3. Learning Hardware-Software Interaction


• This project gives insight into how software interacts directly with the CPU (8086 in this case)
and the registers. This is critical knowledge for designing systems where resource efficiency is vital,
such as real-time systems, robotics, or avionics, where precise control of the hardware is necessary.

4. Low-Level Debugging and Performance Optimization


• Debugging at the assembly level is essential for identifying performance bottlenecks and optimizing
code. Learning how a calculator processes inputs and performs operations in 8086 assembly helps
developers understand how to optimize code by minimizing instruction cycles and memory usage.
• This is useful in fields like game development, where efficient use of CPU and memory is key to
smooth performance on low-end hardware.

SkillsDeveloped:
• Assembly Language Proficiency
• Hardware-Software Interaction
• Problem-Solving and Logic
• Debugging and Troubleshooting
• Input/Output Handling
• Optimization Techniques
• Knowledge of CPU Architecture
• Structured Program Development

11
Conclusion :

The 8086 assembly language calculator project serves as an excellent introductory exercise for
mastering low-level programming. By developing a simple calculator, you gain valuable experience
with assembly language instructions, hardware-software interaction, and the architecture of the
8086 microprocessor. This project not only helps build a strong foundation in understanding how
computers process data at the lowest level but also sharpens essential skills such as problem-
solving, optimization, and debugging. The knowledge acquired from this project has practical
applications in areas like embedded systems, operating system development, and performance-
critical applications, making it a significant stepping stone for more advanced system-level
programming.

12

You might also like