0% found this document useful (0 votes)
20 views30 pages

MP Project

mp

Uploaded by

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

MP Project

mp

Uploaded by

Shruti Wali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

1.

ATM
Creating a full ATM machine program for the 8086 microprocessor involves a complex set of tasks
including user interface, input handling, data storage, and transaction processing. Below, I'll outline a
simplified version focusing on basic functionalities like balance inquiry, withdrawal, and deposit. Note
that real ATM software involves extensive security measures and error handling, which are not fully
covered here.

Here's a basic outline of an ATM program for 8086 assembly language:

; Assume data segment

data segment

pin db '1234$' ; ATM PIN (example)

balance dw 1000 ; Initial balance (example)

input_pin db 5 ; To store user input PIN

amount dw ? ; To store transaction amount

msg_pin db 'Enter PIN: $'

msg_balance db 'Your balance is: $'

msg_withdraw db 'Enter amount to withdraw: $'

msg_deposit db 'Enter amount to deposit: $'

msg_invalid_pin db 'Invalid PIN. Try again.$'

msg_insufficient db 'Insufficient balance. Transaction cancelled.$'

msg_withdrawn db 'Amount withdrawn successfully. New balance: $'

msg_deposited db 'Amount deposited successfully. New balance: $'

msg_newline db 0Dh, 0Ah, '$'

data ends

; Code segment

code segment

assume cs:code, ds:data

start:

mov ax, data


mov ds, ax

; Display message to enter PIN

mov ah, 09h

lea dx, msg_pin

int 21h

; Read user input PIN

mov ah, 0Ah

lea dx, input_pin

int 21h

; Compare input PIN with stored PIN

mov si, offset pin

mov di, offset input_pin + 2 ; Point to actual input buffer

mov cx, 4 ; Compare 4 characters (PIN length)

repe cmpsb

jz PIN_correct ; Jump if input PIN matches stored PIN

; Display invalid PIN message

mov ah, 09h

lea dx, msg_invalid_pin

int 21h

jmp start ; Restart the program

PIN_correct:

; Display menu options

mov ah, 09h

lea dx, msg_balance

int 21h
; Display balance

mov ax, balance

call display_number

; Display newline

lea dx, msg_newline

int 21h

; Menu options

mov ah, 09h

lea dx, msg_withdraw

int 21h

; Read amount to withdraw

mov ah, 01h

int 21h

sub al, '0'

mov amount, ax

; Check if sufficient balance

cmp ax, balance

jnc insufficient_balance

; Withdraw amount

sub balance, ax

; Display success message

mov ah, 09h

lea dx, msg_withdrawn

int 21h
; Display updated balance

mov ax, balance

call display_number

; Display newline

lea dx, msg_newline

int 21h

; End program

jmp exit_program

insufficient_balance:

; Display insufficient balance message

mov ah, 09h

lea dx, msg_insufficient

int 21h

jmp start ; Restart the program

exit_program:

; Exit program

mov ah, 4Ch

int 21h

display_number:

; Display AX as a number

push ax

mov cx, 10

mov bx, 0

l1:

mov dx, 0

div cx
add dl, 30h

push dx

inc bx

cmp ax, 0

jne l1

l2:

pop dx

mov ah, 02

int 21h

pop dx

loop l2

ret

code ends

end start

```

### Explanation:

1. **Data Segment**: Defines variables such as PIN, balance, and messages.

2. **Code Segment**:

- **start**: Main entry point of the program.

- **PIN_correct**: Executes if the entered PIN matches the stored PIN.

- **display_number**: Subroutine to display numbers.

- **insufficient_balance**: Handles the case when the user tries to withdraw more than the
available balance.

- **exit_program**: Exits the program after completing the transaction.

3. **Functions**:

- **display_number**: Converts the balance or transaction amount to a string for display.

### Notes:

- This program assumes a simple interface using text output and keyboard input.

- Error handling and security measures (like locking after multiple incorrect PIN attempts) are not
implemented for brevity.
- Handling of edge cases (like negative amounts, non-numeric input) is minimal or absent.

- For a complete ATM program, extensive testing and additional features (such as deposit handling,
transaction logs, receipt printing) would be necessary.

Creating a fully functional ATM program for the 8086 microprocessor is a significant task requiring
detailed planning, especially concerning security and transaction integrity.

2.TEMPERATURE CONTROL
Creating a temperature control program in 8086 assembly involves simulating temperature reading
and control logic. Since 8086 assembly doesn't directly interface with real-world temperature sensors
or HVAC systems, we'll simulate a simple scenario where the program checks a predefined
temperature value and controls a hypothetical heater based on that.

Here’s an example of how you might implement such a program:

```assembly

.model small

.stack 100h

.data

current_temperature dw 25 ; Current temperature (initialized to 25°C)

target_temperature dw 20 ; Target temperature (initialize to 20°C)

heater_status db 0 ; Heater status (0 = off, 1 = on)

prompt db 'Current temperature: $'

prompt_length equ $ - prompt

prompt_target db 'Target temperature: $'

prompt_target_length equ $ - prompt_target


heater_on_msg db 0ah, 'Heater is ON. $'

heater_on_msg_length equ $ - heater_on_msg

heater_off_msg db 0ah, 'Heater is OFF. $'

heater_off_msg_length equ $ - heater_off_msg

.code

start:

mov ax, @data

mov ds, ax

; Display current temperature

mov dx, offset prompt

mov ah, 09h

int 21h

; Display current temperature value

mov ax, current_temperature

call print_number

; Display target temperature

mov dx, offset prompt_target

mov ah, 09h

int 21h

; Display target temperature value

mov ax, target_temperature

call print_number

; Compare current temperature with target temperature

mov ax, current_temperature


cmp ax, target_temperature

jle turn_on_heater ; Jump if current temperature <= target temperature

; If current temperature > target temperature, turn off heater

mov heater_status, 0

jmp display_heater_status

turn_on_heater:

; If current temperature <= target temperature, turn on heater

mov heater_status, 1

display_heater_status:

; Display heater status message based on heater_status

cmp heater_status, 1

je heater_on

mov dx, offset heater_off_msg

jmp print_message

heater_on:

mov dx, offset heater_on_msg

print_message:

mov ah, 09h

int 21h

exit_program:

mov ah, 4ch

int 21h

print_number proc near

push ax bx cx dx
mov cx, 0 ; Number of digits counter

mov bx, 10 ; Divisor for dividing by 10

; Convert number to decimal and store in output_buffer

L1:

xor dx, dx

3.PARKING SYSTEM
Creating a parking system program for the 8086 microprocessor involves simulating the process of
managing parking spaces, allocating them, displaying availability, and calculating fees based on
duration. Below is a detailed example outlining the structure and key functionalities of such a
program.

### Program Outline:

```assembly

; Assume data segment

data segment

; Constants

max_spaces dw 10 ; Maximum number of parking spaces

rate_per_hour dw 20 ; Rate per hour ($20)

; Variables

spaces_available dw ? ; Number of available spaces

parked_cars dw 10 dup(?) ; Array to track parked cars (0 means space is free, non-zero means
space is occupied)

car_count dw ? ; Number of cars currently parked

selected_space dw ? ; Selected parking space by the user

parking_duration dw ? ; Duration for which car is parked

total_fee dw ? ; Total fee to be paid


msg_main_menu db '1. Park Car', 0Dh, 0Ah, '2. Remove Car', 0Dh, 0Ah, '3. Display Parking Status',
0Dh, 0Ah, '4. Exit', 0Dh, 0Ah, '$'

msg_select db 'Select an option (1-4): $'

msg_invalid db 'Invalid option. Please select again.$'

msg_park db 'Enter parking space number (1-10): $'

msg_remove db 'Enter parking space number to remove car: $'

msg_duration db 'Enter parking duration in hours: $'

msg_fee db 'Total fee to be paid: $'

msg_newline db 0Dh, 0Ah, '$'

data ends

; Code segment

code segment

assume cs:code, ds:data

start:

mov ax, data

mov ds, ax

; Initialize parking system

mov spaces_available, max_spaces

mov car_count, 0

mov ax, max_spaces

mov cx, 0

rep stosw

jmp main_menu

main_menu:

; Display main menu options

mov ah, 09h

lea dx, msg_main_menu


int 21h

; Display message to select an option

mov ah, 09h

lea dx, msg_select

int 21h

; Read user input for menu option

mov ah, 01h

int 21h

sub al, '0' ; Convert ASCII to number

; Process user option

cmp al, 1

je park_car

cmp al, 2

je remove_car

cmp al, 3

je display_status

cmp al, 4

je exit_program

jmp invalid_option

park_car:

; Display message to enter parking space number

mov ah, 09h

lea dx, msg_park

int 21h

; Read user input for parking space

mov ah, 01h


int 21h

sub al, '0' ; Convert ASCII to number

mov selected_space, ax

; Validate parking space number

cmp ax, 1

jl invalid_space

cmp ax, max_spaces

jg invalid_space

; Check if selected space is already occupied

mov bx, selected_space

dec bx ; Adjust for 0-based index in array

cmp parked_cars[bx], 0

jne space_occupied

; Space is available, proceed with parking

mov ah, 09h

lea dx, msg_duration

int 21h

; Read parking duration

mov ah, 01h

int 21h

sub al, '0' ; Convert ASCII to number

mov parking_duration, ax

; Calculate fee

mov ax, parking_duration

mul rate_per_hour

mov total_fee, ax
; Update arrays and counters

mov bx, selected_space

dec bx ; Adjust for 0-based index in array

mov parked_cars[bx], 1 ; Mark space as occupied

inc car_count

dec spaces_available

; Display fee to be paid

mov ah, 09h

lea dx, msg_fee

int 21h

mov ax, total_fee

call display_number

; Display newline

lea dx, msg_newline

int 21h

jmp main_menu

remove_car:

; Display message to enter parking space number to remove car

mov ah, 09h

lea dx, msg_remove

int 21h

; Read user input for space number to remove car

mov ah, 01h

int 21h
sub al, '0' ; Convert ASCII to number

mov selected_space, ax

; Validate parking space number

cmp ax, 1

jl invalid_space

cmp ax, max_spaces

jg invalid_space

; Check if selected space is already empty

mov bx, selected_space

dec bx ; Adjust for 0-based index in array

cmp parked_cars[bx], 0

je space_empty

; Space is occupied, proceed with car removal

mov bx, selected_space

dec bx ; Adjust for 0-based index in array

mov parked_cars[bx], 0 ; Mark space as empty

dec car_count

inc spaces_available

; Display message: car removed successfully

mov ah, 09h

lea dx, msg_newline

int 21h

jmp main_menu

display_status:

; Display current parking status

mov ah, 09h


lea dx, msg_newline

int 21h

; Display number of available spaces

mov ah, 02h

mov dl, spaces_available

add dl, '0'

int 21h

; Display newline

lea dx, msg_newline

int 21h

; Display number of occupied spaces

mov ah, 02h

mov dl, car_count

add dl, '0'

int 21h

; Display newline

lea dx, msg_newline

int 21h

; Display parking status (occupied or not)

mov cx, max_spaces

mov si, 0

mov bx, offset parked_cars

loop1:

CMP BX, first SP Can It

4.TRAFFIC LIGHT CONTROOLER


Creating a detailed traffic light controller program for the 8086 microprocessor involves simulating
the timing and sequencing of traffic lights at an intersection. Below is a structured outline of such a
program focusing on key functionalities. This example assumes a simplified approach and does not
cover advanced features like pedestrian signals or real-time synchronization with sensors.

### Program Outline:

```assembly

; Assume data segment

data segment

green_time dw 30 ; Time in seconds for green light

yellow_time dw 5 ; Time in seconds for yellow light

red_time dw 25 ; Time in seconds for red light

delay_time dw 1 ; Delay time in seconds for each timer tick

time_counter dw ? ; Counter to keep track of elapsed time

current_light db 0 ; Current traffic light state (0 = Red, 1 = Green, 2 = Yellow)

msg_green db 'Green Light', 0Dh, 0Ah, '$'

msg_yellow db 'Yellow Light', 0Dh, 0Ah, '$'

msg_red db 'Red Light', 0Dh, 0Ah, '$'

msg_newline db 0Dh, 0Ah, '$'

data ends

; Code segment

code segment

assume cs:code, ds:data

start:

mov ax, data

mov ds, ax

; Initialize time counter

mov time_counter, 0
; Start traffic light sequence

jmp green_light

green_light:

; Display green light message

mov ah, 09h

lea dx, msg_green

int 21h

; Set timer for green light duration

mov cx, green_time

call delay_seconds

; Change to yellow light

mov current_light, 1

jmp yellow_light

yellow_light:

; Display yellow light message

mov ah, 09h

lea dx, msg_yellow

int 21h

; Set timer for yellow light duration

mov cx, yellow_time

call delay_seconds

; Change to red light

mov current_light, 2

jmp red_light
red_light:

; Display red light message

mov ah, 09h

lea dx, msg_red

int 21h

; Set timer for red light duration

mov cx, red_time

call delay_seconds

; Change to green light

mov current_light, 0

jmp green_light

delay_seconds:

; Delay subroutine using timer interrupt 1Ch (18.2 ticks per second)

; CX contains the number of seconds to delay

mov ax, 0

int 1Ah ; Get current time

delay_loop:

mov bx, cx ; Copy CX to BX for inner loop

delay_inner:

mov dx, 0

mov ax, 46812 ; Approximately 18.2 ticks per second

div cx

sub bx, ax

jnz delay_inner
; Check if CX has reached zero (end of delay)

dec cx

jnz delay_loop

ret

code ends

end start

```

### Explanation:

1. **Data Segment**:

- Defines variables such as timing for each traffic light state (green, yellow, red), delay time for each
timer tick, and messages for each light state.

2. **Code Segment**:

- **start**: Entry point of the program.

- **green_light, yellow_light, red_light**: Sequences through the traffic light states (green ->
yellow -> red) using jump instructions.

- **delay_seconds**: Subroutine to implement a delay using the timer interrupt 1Ch. It calculates
the delay based on the number of seconds specified in CX register.

3. **Functions and Subroutines**:

- **delay_seconds**: Implements a delay by calculating the number of timer ticks needed to


achieve the specified delay in seconds. It uses the timer interrupt 1Ch (timer tick interrupt) to
measure time.

### Notes:

- This program assumes a simplified approach where each traffic light state has a fixed duration
specified in seconds.
- The delay subroutine (`delay_seconds`) uses the BIOS interrupt `1Ah` to get the current time and
then calculates the delay based on the number of seconds specified.

- For a more realistic traffic light controller, additional features could be added such as pedestrian
signals, synchronization with traffic sensors, and more complex timing logic.

- Error handling and interrupt management are not extensively covered in this simplified example.

This program provides a basic framework for simulating the timing and sequencing of traffic lights
using assembly language on the 8086 microprocessor. For real-world applications, additional
considerations and features would be necessary to handle various traffic scenarios effectively.

5.ACCIDENT
Creating an accident simulation program for the 8086 microprocessor involves modeling the
sequence of events after an accident, such as emergency response and data logging. Below is a
simplified outline of such a program. Please note that this program is for educational purposes and
does not cover real-time data acquisition or advanced simulation features.

### Program Outline:

```assembly

; Assume data segment

data segment

msg_accident db 'Accident Reported. Emergency Services Activated.$'

msg_response db 'Emergency services are on their way.$'

msg_clearance db 'Accident site cleared.$'

msg_exit db 'End of program.$'

data ends

; Code segment

code segment

assume cs:code, ds:data

start:

mov ax, data


mov ds, ax

; Display message indicating accident reported

mov ah, 09h

lea dx, msg_accident

int 21h

; Call emergency response subroutine

call emergency_response

; Display message indicating site clearance

mov ah, 09h

lea dx, msg_clearance

int 21h

; End program

mov ah, 09h

lea dx, msg_exit

int 21h

; Exit to DOS

mov ah, 4Ch

int 21h

emergency_response:

; Display message indicating emergency response

mov ah, 09h

lea dx, msg_response

int 21h

; Simulate emergency response actions (e.g., dispatching ambulance, police)


; This could include further subroutine calls or simulated actions.

ret

code ends

end start

```

### Explanation:

1. **Data Segment**:

- `msg_accident`: Message indicating that an accident has been reported.

- `msg_response`: Message indicating that emergency services are on their way.

- `msg_clearance`: Message indicating that the accident site has been cleared.

- `msg_exit`: Message indicating the end of the program.

2. **Code Segment**:

- **start**: Entry point of the program.

- **emergency_response**: Subroutine to simulate emergency response actions. In a real


program, this could involve actual dispatching of emergency services, but here it's simplified to
displaying a message.

### Notes:

- This program provides a basic framework for simulating the sequence of events after an accident
using assembly language on the 8086 microprocessor.

- In a real-world scenario, this program would be integrated with sensors or user inputs to trigger the
accident reporting and response process.

- Error handling and complex decision-making processes (such as routing emergency services) are
not covered in this simplified example.

- Assembly language programming on the 8086 microprocessor can be extended to include more
sophisticated features depending on specific requirements, such as logging accident details,
interacting with external devices, or simulating multiple accident scenarios.
This example serves as a foundational program to understand how assembly language can be used to
simulate and respond to an accident scenario using basic messaging and subroutine calls on the 8086
microprocessor.

6.MOBLE APPLICATION
Creating a mobile application simulation on the 8086 microprocessor involves designing a program
that emulates basic functionalities typically found in mobile apps. Given the limitations of the 8086
architecture, we'll focus on a simplified version that includes a basic user interface, a few essential
features, and interaction through text-based menus. Below is an outline of such a program:

### Program Outline:

```assembly

; Assume data segment

data segment

; Constants for messages and data

msg_menu db '1. Calculator', 0Dh, 0Ah, '2. Contact List', 0Dh, 0Ah, '3. Notes', 0Dh, 0Ah, '4. SMS',
0Dh, 0Ah, '5. Settings', 0Dh, 0Ah, '6. Exit', 0Dh, 0Ah, '$'

msg_select db 'Select an option (1-6): $'

msg_invalid db 'Invalid option. Please select again.$'

msg_newline db 0Dh, 0Ah, '$'

; Calculator variables

num1 dw ?

num2 dw ?

result dw ?

; Contact List variables

contacts db 'John Smith$Sara Brown$Mike Johnson$Alice Lee$Terrence Green$'

; Notes variables
notes db 500 dup('$') ; Array to store notes

notes_count dw 0 ; Number of notes stored

data ends

; Code segment

code segment

assume cs:code, ds:data

start:

mov ax, data

mov ds, ax

main_menu:

; Display main menu options

mov ah, 09h

lea dx, msg_menu

int 21h

; Display message to select an option

mov ah, 09h

lea dx, msg_select

int 21h

; Read user input for menu option

mov ah, 01h

int 21h

sub al, '0' ; Convert ASCII to number

; Process user option

cmp al, 1

je calculator
cmp al, 2

je contact_list

cmp al, 3

je notes

cmp al, 4

je sms

cmp al, 5

je settings

cmp al, 6

je exit_program

jmp invalid_option

calculator:

; Clear previous result

mov result, 0

; Display calculator menu

mov ah, 09h

lea dx, 'Enter first number: $'

int 21h

; Read first number

mov ah, 01h

int 21h

sub al, '0'

mov num1, ax

; Display prompt for second number

mov ah, 09h

lea dx, 'Enter second number: $'

int 21h
; Read second number

mov ah, 01h

int 21h

sub al, '0'

mov num2, ax

; Perform addition

add ax, num1

mov result, ax

; Display result

mov ah, 09h

lea dx, 'Result: $'

int 21h

mov ax, result

add ax, '0'

mov dl, ah

int 21h

jmp main_menu

contact_list:

; Display contact list

mov ah, 09h

lea dx, contacts

int 21h

; Wait for user input to return to main menu


mov ah, 01h

int 21h

jmp main_menu

notes:

; Display notes menu

mov ah, 09h

lea dx, 'Notes$'

int 21h

; Wait for user input to return to main menu

mov ah, 01h

int 21h

jmp main_menu

sms:

; Simulate sending a message

mov ah, 09h

lea dx, 'Enter recipient: $'

int 21h

; Read recipient (for simplicity, just display a message)

mov ah, 09h

lea dx, 'Message sent!$'

int 21h

jmp main_menu

settings:

; Display settings menu

mov ah, 09h


lea dx, 'Settings$'

int 21h

; Wait for user input to return to main menu

mov ah, 01h

int 21h

jmp main_menu

exit_program:

; Exit program

mov ah, 4Ch

int 21h

invalid_option:

; Display invalid option message

mov ah, 09h

lea dx, msg_invalid

int 21h

jmp main_menu

code ends

end start

```

### Explanation:

1. **Data Segment**:

- `msg_menu`: Menu options displayed to the user.

- `msg_select`: Prompt to select an option.

- `msg_invalid`: Message displayed for invalid options.

- `msg_newline`: New line character sequence for formatting.


- `num1`, `num2`, `result`: Variables used for calculator operations.

- `contacts`: Simulated contact list stored as a string separated by '$'.

- `notes`: Array to store notes, assuming each note can be up to 500 characters.

- `notes_count`: Counter to keep track of the number of notes stored.

2. **Code Segment**:

- **start**: Entry point of the program.

- **main_menu**: Loop that displays the main menu, reads user input, and processes the selected
option.

- **calculator**: Subroutine to perform basic addition using user-input numbers.

- **contact_list, notes, sms, settings**: Subroutines to simulate accessing contact list, notes,
sending SMS, and accessing settings.

- **exit_program**: Terminates the program using DOS interrupt `4Ch`.

- **invalid_option**: Handles invalid user inputs by displaying an error message and returning to
the main menu.

### Notes:

- This program provides a basic framework for simulating a simple mobile application-like interface
using assembly language on the 8086 microprocessor.

- Each menu option (`calculator`, `contact_list`, `notes`, `sms`, `settings`) can be expanded with more
functionalities based on specific requirements.

- Error handling and complex functionalities such as actual data storage, user authentication, or
interactive UI elements are not implemented in this simplified example.

- Assembly language programming on the 8086 microprocessor can be extended with additional
features like file handling, graphics simulation, or more advanced calculations to enhance the
simulation.

7.LIBRARY MANGMENT
This example serves as a starting point to understand how assembly language can be used to
simulate basic mobile application operations on the 8086 microprocessor, providing a foundation for
further development and customization based on specific educational or demonstration needs.

You might also like