Micro Lab
Micro Lab
Objective: The objective of this lab is to write a program in MDA 8086 assembly language that
displays given characters in an 8x8 dot matrix on the screen.
Requirements:
Procedure:
Define a character table that contains the bit patterns for each character to be displayed. Each
character will be represented by an 8-bit pattern.
Set up the screen mode for text mode display and clear the screen.
Write a subroutine to display a given character at a specific location on the screen. The
subroutine should take the character code and the row and column coordinates as input
parameters.
Inside the subroutine, calculate the memory offset for the given row and column coordinates.
Load the character code into the appropriate memory location to display the character.
Sample Code:
.MODEL SMALL
.STACK 100H
.DATA
CHAR_TABLE DB 0F0H, 090H, 099H, 0A4H, 099H, 0A5H, 0F9H, 080H ; Example
character table
.CODE
MAIN PROC
MOV AL, 0
XOR BH, BH
XOR CX, CX
MOV DH, 24
MOV DL, 79
INT 10H
; Display characters
DISPLAY_LOOP:
; End program
INT 21H
DISPLAY_CHAR PROC
PUSH AX
PUSH BX
PUSH DX
POP DX
POP BX
POP AX
RET
DISPLAY_CHAR ENDP
MAIN ENDP
END MAIN
Discussion: In this lab, we used MDA 8086 assembly language to display given characters in an
8x8 dot matrix. We started by initializing the environment and setting up the screen mode for
text mode display. We then defined a character table that contained the bit patterns for each
character to be displayed.
2.
Title: Lab Report on Execute addition, subtraction, multiplication, Division and other
Objective: The purpose of this lab report is to explore the execution of arithmetic instructions
such as addition, subtraction, multiplication, division, and other instructions in the MDA 8086
microprocessor. Additionally, we will examine the status of the flags during the execution of
these instructions.
Introduction: The MDA 8086 microprocessor is a widely used 16-bit microprocessor that has a
rich instruction set supporting various arithmetic operations. In this lab, we will focus on the
execution of addition, subtraction, multiplication, division, and other instructions and observe the
behavior of the flags.
Materials:
Power on the system and load the assembler and simulator software.
Write assembly code to perform addition, subtraction, multiplication, division, and other
operations.
Use suitable registers and memory locations for storing operands and results.
Execute the code step-by-step, monitoring the registers and flags after each instruction.
5.1. Addition:
Observe the status of flags such as carry (CF), overflow (OF), zero (ZF), and sign (SF).
5.2. Subtraction:
5.3. Multiplication:
5.4. Division:
Explore additional instructions such as increment (INC), decrement (DEC), logical AND (AND),
logical OR (OR), etc.
3.
Title: Lab Report - Assembly Language Program for Calculating and Printing Terms of the
Fibonacci Series using 8086 Microprocessor
Introduction: The Fibonacci series is a sequence of numbers in which each number is the sum of
the two preceding ones. In this lab, we implemented an assembly language program using the
8086 microprocessor to calculate and print terms of the Fibonacci series. The program
demonstrates the use of iterative loops and arithmetic operations to generate the series.
Objective: The objective of this lab was to develop an assembly language program that can
calculate and print the terms of the Fibonacci series using the 8086 microprocessor.
1. 8086 microprocessor
2. Computer with an assembly language development environment (e.g., NASM)
3. Text editor
Procedure:
Define variables: Initialize memory locations to store the current term (currentTerm), the
previous term (previousTerm), and the next term (nextTerm) of the Fibonacci series.
Set the initial values: Assign the initial values of the variables. Set previousTerm to 0 and
currentTerm to 1.
Display the initial terms: Print the initial terms of the series (0 and 1) using appropriate
instructions (e.g., INT 21h in DOS).
Calculate and print the Fibonacci series: Implement a loop to calculate the next term of the series
by adding the previous two terms. Store the result in the nextTerm variable. Print the value of
nextTerm using suitable instructions.
Update variables: Update the values of previousTerm and currentTerm by shifting their
respective values. Assign the value of nextTerm to currentTerm and assign the value of the
currentTerm to previousTerm.
Repeat steps 4 and 5: Continue the loop for the desired number of terms to generate the
Fibonacci series.
.model small
.stack 100h
.data
; message db 10, 13, 'Fibonacci Series:', 10, 13, '$'
.code
main proc
mov ax, @data
mov ds, ax
; Display message
mov ah, 9
lea dx, message
int 21h
; Initialize variables
; Update variables
xchg dl, dh
; Loop control
inc si
cmp si, cx
jne print_terms
Discussion: The assembly language program described above calculates and prints the terms of
the Fibonacci series using the 8086 microprocessor. The program initializes variables, displays a
message, and enters a loop to generate and print the desired number of terms. It follows a basic
algorithm to calculate each term by adding the previous two terms. The loop continues until the
desired number of terms is generated.
4.
Name: Title: Lab Report on Programming with General Purpose Registers in 8086
Microprocessor
Objective: This lab report aims to explore the programming aspects of the 8086 microprocessor
using General Purpose Registers (GPRs). The 8086 microprocessor is a 16-bit CPU that was
widely used in early personal computers. GPRs are integral to the 8086 architecture and play a
crucial role in data manipulation and storage. This report presents the methodology, code
snippets, and results of various programming tasks performed using GPRs in the 8086
microprocessor.
Introduction: The 8086 microprocessor is based on the x86 architecture and has 8 general-
purpose registers, namely AX, BX, CX, DX, SI, DI, BP, and SP. These registers can be used for
various purposes, including arithmetic operations, data storage, and addressing modes. This lab
report explores the functionality and application of GPRs in programming tasks.
Methodology:
a. Register Initialization:
b. Arithmetic Operations:
1. Perform arithmetic operations such as addition, subtraction, multiplication, and division using
the GPRs.
c. Data Manipulation:
2. Demonstrate the use of various instructions like MOV, XCHG, and arithmetic instructions to
manipulate data.
d. Conditional Branching:
e. Looping:
Code Snippets:
a. Register Initialization:
MOV AX, 1234h ; Move the hexadecimal value 1234h into the AX register
MOV BX, 5678h ; Move the hexadecimal value 5678h into the BX register
b. Arithmetic Operations:
c. Data Manipulation:
MOV DX, AX ; Move the contents of AX into DX
XCHG AX, BX ; Exchange the contents of AX and BX
INC CX ; Increment the value of CX by 1
d. Conditional Branching:
e. Looping:
MOV CX, 10 ; Initialize CX with the loop count
LOOP label ; Decrement CX by 1 and jump to "label" until CX becomes zero
Results and Discussion: The programming tasks demonstrated the effectiveness of GPRs in the
8086 microprocessor. By leveraging GPRs, we were able to perform arithmetic operations,
manipulate data, implement conditional branching, and execute loops. These tasks illustrate the
versatility and significance of GPRs in programming with the 8086 microprocessor.
5.
Title: Lab Report - Arithmetic and Logical Operations Program in 8086 Microprocessor.
Objectives: This lab report describes the design and implementation of a program in 8086
microprocessor for performing arithmetic and logical operations. The program utilizes the
capabilities of the 8086 instruction set architecture to execute various mathematical and logical
computations. This report presents the program code, discusses its functionality, and provides
insights into the execution of the program on the 8086 microprocessor.
.MODEL SMALL
.STACK 100H
.DATA
.CODE
; Main program logic starts here
MOV AX, 5 ; Move value 5 into AX register
MOV BX, 3 ; Move value 3 into BX register
; Arithmetic Operations
ADD AX, BX ; Add BX to AX (AX = AX + BX)
SUB AX, BX ; Subtract BX from AX (AX = AX - BX)
MUL BX ; Multiply AX by BX (AX = AX * BX)
DIV BX ; Divide AX by BX (AX = AX / BX)
; Logical Operations
; Additional Operations
END
Program Explanation:
The program begins by defining the data segment and the code segment using the .DATA and .CODE
directives, respectively. It also sets the model and stack size using the .MODEL SMALL and .STACK
directives. Inside the code segment, the program starts by moving the values 5 and 3 into the AX and BX
registers, respectively, using the MOV instruction. The subsequent sections demonstrate various
arithmetic and logical operations:
Arithmetic Operations:
Additional Operations:
Discussion: This lab report presented an 8086 assembly program that showcases arithmetic
and logical operations. By utilizing the instructions provided by the 8086 instruction set, the
program demonstrates addition, subtraction, multiplication, division, bitwise logical operations,
complement, increment, and decrement operations. Understanding and implementing these
operations on the 8086 microprocessor are fundamental steps in learning assembly
programming and the inner workings of microprocessors.
6.
Title: Lab Report: Factorial Calculation Program Using 8086 Assembly Language.
Objective: The objective of this lab report is to present an assembly language program for
calculating the factorial of a number using the 8086 microprocessor.
The assembly language program for calculating the factorial of a number using the 8086 microprocessor
can be implemented using the following steps:
Set up the Data Segment (DS) and Stack Segment (SS) registers to appropriate values.
Clear the extra segment registers (ES, FS, GS) if not being used.
Prompt the user to enter a number for which the factorial needs to be calculated.
Read the input number from the user and store it in memory.
Initialize Variables:
Initialize variables for storing the result (factorial) and the loop counter.
Calculate Factorial:
Repeat the multiplication and decrement until the loop counter reaches zero.
Halt the program execution or provide an option for the user to exit.
.MODEL SMALL
.STACK 100H
.DATA
NUMBER DB ?
RESULT DW 1
COUNTER DW ?
.CODE
MAIN PROC
MOV DS, AX
INT 21H
INT 21H
MOV NUMBER, AL
; Initialize variables
MOV AX, 1
; Calculate factorial
LOOP_START:
MUL COUNTER
DEC COUNTER
LOOP LOOP_START
INT 21H
MOV DL, AL
INT 21H
INT 21H
MAIN ENDP
END MAIN
Discussion: The assembly language program presented in this lab report successfully calculates the
factorial of a given number using the 8086 microprocessor. By following the steps outlined in the
methodology, we were able to initialize the necessary registers, read the input, calculate the factorial,
and display the result. Assembly language programming allows for direct control and efficient utilization
of the microprocessor, making it a valuable tool for low-level programming tasks.
7.
Lab Report: Assembly Language Program to Find Average of n Eight-Bit Numbers in 8086
Microprocessor
Objective: The objective of this lab is to write an assembly language program for the 8086
microprocessor that calculates the average of n eight-bit numbers provided by the user.
Equipment/Software Used:
Introduction:
In this lab, we will focus on writing an assembly language program to find the average of n
eight-bit numbers. The program will prompt the user to enter the count of numbers (n) and then
prompt for each number individually. The program will calculate the average by summing up all
the numbers and dividing the sum by n.
.MODEL SMALL
.STACK 100H
.DATA
COUNT DB ?
NUMBER DB ?
SUM DW ?
AVERAGE DB ?
.CODE
MOV DS, AX
MOV AH, 1
INT 21H
MOV AH, 1
INT 21H
LOOP NEXT_NUMBER
; Calculate average
MOV AVERAGE, AL
; Display average
MOV AH, 2
INT 21H
INT 21H
END
Explanation: The .MODEL directive specifies the memory model to be used, and .STACK
directive reserves space for the program stack.
The .DATA section is used to declare data variables.
The .CODE section contains the actual program code.
The program starts by initializing the data segment and stack segment registers.
The program prompts the user to enter the count of numbers. The ASCII value of the entered
digit is converted to a numeric value using the SUB instruction.
The sum variable is initialized to zero.
The program enters a loop to prompt for each eight-bit number. The loop counter is set to the
count value entered by the user.
Inside the loop, the program prompts the user for a number and converts the ASCII digit to a
numeric value.
The program multiplies the previous sum by 10 using the MUL instruction and adds the current
number to the sum.
The loop continues until the counter reaches zero.
After the loop, the program calculates the average by dividing the sum by the count using the
DIV instruction.
The program then displays the average by converting the numeric value to an ASCII digit and
using the INT 21H DOS interrupt to display the character.
Finally, the program ends by calling the DOS terminate function using the INT 21H interrupt
with the appropriate parameters
.
Conclusion: In this lab, we successfully implemented an assembly language program for the
8086 microprocessor that calculates the average of n eight-bit numbers. The program utilized
various instructions and addressing modes to prompt the user, perform arithmetic operations, and
display the average. Assembly language programming provides fine-grained control over the
hardware, making it suitable for optimization and specialized tasks.
8.
Title: Assembly Language Program for Finding Square Root of a Number in 8086 Microprocessor
Objective:
This lab report presents an assembly language program written for the 8086 microprocessor to
calculate the square root of a given number. The program utilizes the Newton-Raphson method
to approximate the square root with a desired level of accuracy. The report outlines the
algorithm, provides a detailed explanation of the program's implementation, and discusses the
testing and results obtained.
Introduction:
The square root operation is a common mathematical operation required in various applications.
The 8086 microprocessor, being an 16-bit processor, lacks a built-in square root instruction.
Therefore, this lab aims to develop an assembly language program that can accurately compute
the square root of a given number.
Algorithm:
The program employs the Newton-Raphson method, an iterative numerical method for finding
the square root of a number. The algorithm can be summarized as follows:
Calculate a new approximation, 'nextX', using the formula: nextX = (x + (inputNumber / x)) / 2.
Store the final approximation as the square root of the input number.
Program Implementation:
The assembly language program is written for the 8086 microprocessor. It assumes that the input
number is provided by the user and stored in the memory location labeled 'inputNumber'. The
program consists of the following steps:
DATA SEGMENT
inputNumber DW ?
squareRoot DW ?
DATA ENDS
CODE SEGMENT
START:
MOV DS, AX
MOV AX, 0
MOV AL, BL
MOV AH, 0
MOV DX, 0
MOV CX, 2
MOV DX, 0
NEXT_ITERATION:
MOV AL, BL
MOV AH, 0
MOV CX, 2
INT 21h
INT 21h
INT 21h
INT 21h
INT 21h
; Exit program
INT 21h
CODE ENDS
END START
To test the program, various input numbers were provided to verify the correctness of the square
root calculation. The program produced accurate square root results with a desired level of
precision. For example:
Input: 9 -> Square Root: 3
9.
Objective: The objective of this lab report is to demonstrate the process of converting a 16-bit decimal
number to its corresponding hexadecimal format.
Procedure:
Divide the decimal number by 16 and note down the quotient and remainder.
If the quotient is greater than 0, repeat step 2 using the quotient obtained in the previous step.
Write down the remainders obtained in each step in reverse order to obtain the hexadecimal
representation of the decimal number.
Example:
Let's consider a 16-bit decimal number, 43721. We will convert this decimal number to hexadecimal
format.
Divide 43721 by 16:
Quotient: 2732
Quotient: 170
Quotient: 10
Divide 10 by 16:
Quotient: 0
Conclusion:
In this lab report, we demonstrated the process of converting a 16-bit decimal number to
hexadecimal format. By dividing the decimal number by 16 and noting down the remainders, we
obtained the corresponding hexadecimal representation. This conversion is useful in various
applications, particularly in computer science and digital systems.
10.
Title: Lab Report - Palindrome Checking Program using 8086 Assembly Language
Abstract:
This lab report presents an 8086 assembly language program to determine whether a given string
is a palindrome or not. The program utilizes the basic operations of string manipulation and
comparison to identify palindromic sequences. This report outlines the program's logic,
implementation, and provides a detailed explanation of the assembly code.
Introduction:
A palindrome is a sequence of characters that reads the same forward and backward. The task of
determining whether a given string is a palindrome can be efficiently accomplished using the
8086 assembly language. This report describes the development of a program that employs string
manipulation and comparison techniques to detect palindromes.
Methodology:
The program follows a straightforward algorithm that involves comparing characters from both
ends of the given string until the middle is reached. If all the characters match during the
comparison process, the string is considered a palindrome. On the other hand, if any character
pair fails to match, the string is not a palindrome.
Set up two pointers, one pointing to the beginning of the string and the other pointing to the end.
If the characters match, increment the first pointer and decrement the second pointer.
Repeat steps 4 and 5 until the pointers cross each other or a mismatch is found.
If all characters matched, display a message indicating that the string is a palindrome.
If a mismatch occurred, display a message indicating that the string is not a palindrome.
Program Implementation:
The following assembly code demonstrates the implementation of the palindrome checking program in
the 8086 architecture:
assembly
Copy code
.model small
.stack 100h
.data
buffer db 80h
length dw ?
.code
mov ds, ax
mov ah, 9
mov di, si
mov cx, 0
dec si
add di, cx
mov bx, 0
check:
cmp si, di
jae palindrome
jnz not_palindrome
inc si
dec di
jmp check
palindrome:
mov ah, 9
jmp exit
not_palindrome:
mov ah, 9
exit:
end
Explanation:
The program begins by initializing the data segment and the stack. It prompts the user to enter a
string and reads the input using the DOS interrupt 21h function 0ah, which reads a string from
standard input.
The pointers si and di are set to the beginning and end of the string, respectively. The cx register
is used to store the length of the string obtained from the buffer's first byte.
The check loop starts by comparing the positions of si and di. If si is greater than or equal to di, it
means the comparison has reached or crossed the middle of the string, indicating that all
characters matched.
Inside the loop, the program compares the characters pointed by si and di. If they do not match, it
jumps to the not_palindrome label and displays the appropriate message. If they match, the
pointers are adjusted, and the loop continues until the middle is reached.
If the loop completes without encountering a mismatch, the program jumps to the palindrome
label and displays the message indicating that the string is a palindrome.
Finally, the program terminates using DOS interrupt 21h function 4c00h.
Conclusion:
The 8086 assembly language program presented in this lab report successfully checks whether a
given string is a palindrome or not. By utilizing string manipulation techniques and comparison
operations, the program efficiently compares characters from both ends of the string to determine
palindromic sequences. The implemented algorithm can be further optimized or expanded based
on specific requirements or constraints.