0% found this document useful (0 votes)
35 views51 pages

MM Lab (252001173) Venu Gopal, Ece-B

Uploaded by

ABHEER SHARMA
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)
35 views51 pages

MM Lab (252001173) Venu Gopal, Ece-B

Uploaded by

ABHEER SHARMA
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
You are on page 1/ 51

University Institute of Engineering and Technology

(KURUKSHETRA UNIVERSITY KURUKSHETRA, HARYANA)

MICROPROCESSORS
AND
MICROCONTROLLER
LAB

NAME- VENU GOPAL

CLASS- ECE-B

ROLL NO.- 252001173

SEMESTER- 4TH SEMESTER

Submitted by: Venu Gopal

Submitted to: Shivani Chauhan


INDEX
Sr. No. Experiment Name Date Remark

Introduction to DosBox and MASM

Introduction to Keil

1.) Write assembly language program


to perform addition and subtraction
of 8/16 bit number using DOSBox.

2.) Write assembly language program


to perform multiplication of 8/16 bit
number using DOSBox.

3.) Write assembly language program


to perform division of 8/16 bit
number using DOSBox.

4.)(A)(B) Write assembly language program


to find smallest/greatest number
from a given set of 8/16 bit number
using DOSBox.

5,6.) Write an Assembly Language


Program to arrange a given set of
numbers in descending order and
ascending order.
7.) Write an Assembly Language
Program for ADDITION,
SUBTRACTION, MULTIPLICATION
AND DIVISION of 8/16 bit numbers
using keil software.

8.) Write an Assembly Language


Program for logic instructions i.e.,
and, or, Xor and complement of
8/16-bit numbers in using keil
software.

9.)
Write assembly language program to
perform Addition and Subtraction of
Multi-Byte 8/16 bit number using
keil software

10.) ALP to transfer data from ROM to


RAM using keil software.

DosBox and MASM


EDITOR
An editor is a program, which allows you to create a file containing the assembly
language statements for your program. As you type in your program, the editor stores the
ASCII codes for the letters and numbers in successive RAM locations. When you have typed
in all of your programs, you then save the file on a floppy of hard disk. This file is called
source file. The next step is to process the source file with an assembler. In the
MASM/TASM assembler, you should give your source file name the extension, .ASM

ASSEMBLER
An assembler program is used to translate the assembly language mnemonics for
instructions to the corresponding binary codes. When you run the assembler, it reads the
source file of your program from the disk, where you saved it after editing on the first pass
through the source program the assembler determines the displacement of named data items, the
offset of labels and pails this information in a symbol table. On the second pass through the
source program, the assembler produces the binary code for each instruction and insertsthe
offset etc that is calculated during the first pass. The assembler generates two files on floppy
or hard disk. The first file called the object file is given the extension. OBJ. The object file
contains the binary codes for the instructions and information about the addresses of the
instructions. The second file generated by the assembler is called assembler list file. The list
file contains your assembly language statements, the binary codes for each instruction and
the offset for each instruction. In MASM/TASM assembler, MASM/TASM source file name
ASM is used to assemble the file. Edit source file name LST is used to view the list file,
which is generated, when you assemble the file.

LINKER
A linker is a program used to join several object files into one large object file and convert to an
exe file. The linker produces a link file, which contains the binary codes for all the combined
modules.
The linker however doesn't assign absolute addresses to the program, it assigns is said
to be reloadable because it can be put anywhere in memory to be run. In MASM/TASM,
LINK/TLIN5K source filename is used to link the file.

DEBUGGER
A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot are debug it the debugger allows you to
look at the contents of registers and memory locations after your program runs. It allows
you to change the contents of register and memory locations after your program runs. It
allows you to change the contents of register and memory locations and return the
program. A debugger also allows you to set a break point at any point in the program. If you
inset a breakpoint the debugger will run the program up to the instruction where the
breakpoint is set and stop execution. You can then examine register and memory
contents to see whether the results are correct at that point. In MASM/TASM, td
filename is issued to debug the file.

DEBUGGER FUNCTIONS:

1. Debugger allows looking at the contents of registers and memory locations.


2. We can extend 8-bit register to 16-bit register which the help of extended register
option.
3. Debugger allows setting breakpoints at any point with the program.
4. The debugger will run the program up to the instruction where the breakpoint is set
and then stop execution of program. At this point, we can examine registry and
memory contents at that point.
5. With the help of dump, we can view register contents.
6. We can trace the program step by step with the help of F7.
7. We can execute the program completely at a time using F8.
The DOS -Debugger:
The DOS “Debug” program is an example of simple debugger that comes with MS-
DOS.
Hence it is available on any PC .it was initially designed to give the user the
capability to trace logical errors in executable file.
MS-
MASM:
Microsoft's Macro Assembler (MASM) is an integrated software package Written
by Microsoft Corporation for professional software developers. It consists of an
editor, an assembler, a linker and a debugger (Code View). The programmer's
workbench combines these four parts into a user-friendly programming environment
with built-in on-line help. The following are the steps used if you are to run MASM
from DOS.

MICROPROCESSOR LAB EXECUTION PROCEDURE:


STEP1: Install DOSBox.
STEP2: Checking the masm installation
To know MASAM is installed or not simply type masm at the command prompt
upon that it replies masm version vendor (Microsoft), etc... If you get any error there
is no masm in that PC
STEP3: Directory changing (create a folder with your branch and no in C drive)
Change the current directory to your won directory suppose your folder in C drive
type the following commands to change the directory at command prompt type C:
hit enter now you are in C drive type cd folder name hit the enter Ex. Z:\>C: Now
we are in folder C
STEP4: writing the program
At the DOSBox prompt type the edit programname.asm Ex. Edit add.asm
Immediately editor window will open and there you have to write the program.
Type the program in that window after completion save the Program, to save the
program Go to file opt in the menu bar and select save opt now your code is ready
to Assemble.
STEP5: Assembling, Linking and Executing the program
Go to file opt click exit opt now DOS prompt will be displayed to assemble the
program type the following commands at the DOS prompt
Masm Program Name, Program Name, Program Name, Program Name hit the ente
Ex: Masm add.asm;

If there are any errors in the program assembler reports all of them at the command
prompt with line no's, if there are no bugs, you're ready to link the program.
To link the program, type the following line at DOSBox prompt.
Ex: link add.obj;
After linking you are ready to execute the program. To execute the program, type
the following command
Debug program name.exe hit the enter
Ex: Debug add.exe
Now you entered into the execution part of the program here you have to execute
the program. it'll execute that instruction and displays the contents of all the register.
You have to do this until you reach the last instruction of the program. After
execution you have to observe the results (in memory or registers based on what
you have written in the program).

Different registers and their operations are listed below:

Register Uses/Operations

AX As accumulator in Word multiply & Word divide operations, Word I/O


operations

AL As accumulator in Byte Multiply, Byte Divide, Byte I/O, translate,


Decimal Arithmetic

AH Byte Multiply, Byte Divide

BX As Base register to hold the address of memory

CX String Operations, as counter in Loops

CL As counter in Variable Shift and Rotate operations

DX Word Multiply, word Divide, Indirect I/O

 Program Format and assembler Directives


The typical assembler program construct for 8051/8086:
Line 1 MODEL

.code segment

 code view to debug the program by following the steps given


below:
Write the program in a file with .ASM extension
using an editor [PRETEXT Editor which saves
it in ASCII].
ssEx:
EDIT TEST1.ASM
Assemble the program using the
command MASM/ZI file name; Ex:
MASM TEST1.ASM
Link the program using the
command LINK/CO file name;
Ex: LINK TEST1.OBJ
To debug use
DEBUG FILENAME.EXE

Introduction to Micro(µ)-Vision Keil Software

Keil C cross compiler: Keil is a German based Software development company. It provides
several development tools like

• IDE (Integrated Development environment)


• Project Manager
• Simulator
• Debugger
• C Cross Compiler , Cross Assembler, Locator/Linker

Keil Software provides you with software development tools for the 8051 family of
microcontrollers. With these tools, you can generate embedded applications for the multitude
of 8051 derivatives.
Keil provides following tools for 8051 development:

1. C51 Optimizing C Cross Compiler,


2. A51 Macro Assembler,
3. 8051 Utilities (linker, object file converter, library manager),
4. Source-Level Debugger/Simulator,
5. µVision for Windows Integrated Development Environment.

The keil 8051 tool kit includes three main tools like assembler, compiler and linker. These tools
have the following functions:

• An assembler is used to assemble your 8051 assembly program • A compiler is


used to compile your C source code into an object file.
• A linker is used to create an absolute object module suitable for your in-circuit
emulator.

8051 project development cycle: These are the steps to develop 8051 project using keil

• Create source files in C or assembly.


• Compile or assemble source files.
• Correct errors in source files.
• Link object files from compiler and assembler.
• Test linked application.

Working with Keil:


To open keil software click on start menu then program and then select keil (any available
version on your pc). Following window will appear on your screen
Software Windows:
We can see three different windows in this screen.
1) Project work space window
2) Editing window
3) Output window.

• Project workspace window: It is for showing all the related files connected with our
project.
• Editing window: It is the place where we will edit the code.
• Output window: It will show the output when you compile or build or run your project.

Procedure to Start a New Project:


Now to start with new project follow the steps, which are as follows:

• Click on project menu and select new project


• You will be asked to create new project in specific directory
• Just move to your desired directory and there create a new folder for your project named
“first”. Here I am creating new project in Keil Software as shown in figure

Target Selection
• Now we will be asked to choose your target device for which you want to write the
program.
• Scroll down the cursor and select generic from list. Expand the list and select 8051 (all
variants)
• When we click OK, we will be asked to add startup code and file to your project folder.
Click yes. Now on your screen expand target1 list fully. You will see following window.
• After that we have to add a file along with the appropriate file extension and then save it
to write the code in it.

• In this editor window we can write the code of our program


• And then after adding the file in the source group
• We can build the target by simply clicking F7
• And then we can debug or run the program to get the desired result
• Also we can generate the hex code file with .hex extension to burn it in the microcontroller

Target options in Keil Software:

• Select output tag and check “create hex file” box


• Now when you again build your program you will see the message in output window “hex
file is created”.
• This file you can directly load in 8051 target board and run the application on actual
environment.

EXPERIMENT: 1(A)
AIM: Write an Assembly Language Program for Addition. (8 bit).

APPARATUS: Using DOSBox software.


PROGRAM:

Code segment
assume cs:code
start:
mov ah,0000h
mov si,3000h
mov al,[si]
Inc si
mov bl,[si]
add bl,al
inc si
mov [si],al
jc l1
inc si
mov[si],ah
Int 3
l1:
inc ahinc
si
mov[si],ah
code ends
end start
OUTPUT

RESULT – Two numbers are added using Assembly Language


program and executed.
EXPERIMENT: 1 (B)
AIM: Write an Assembly Language Program for addition. (16 bit)

APPARATUS: Using DOSBox software.

PROGRAM:

ADDITION OF TWO 16 BIT NUMBER


code segment
assume cs:code
start:
mov ax,0000h
mov bx,ax
mov dx,ax
mov si,3000h
mov ax,[si]
inc si
inc si
mov bx,[si]
inc si
inc si
add ax,bx
mov [si],ax
jc l1

inc si
inc si

mov[si],dx

int 3
l1:
inc dx
inc si
inc si
mov [si],dx

int 3
code ends
end start

Code window
Output

RESULT-Two 16 number are added using assembly language program and


executed.
EXPERIMENT: 1 (C)
AIM: Write an Assembly Language Program for subtraction. (8 bit)

APPARATUS: Using DOSBox software.

PROGRAM:
Code segment
assume cs: Code
start:
mov ah,0000h
mov si,3000h
mov al,[si]
inc si
mov bl,[si]
sub al, bl
inc si
mov [si],al
jc l1
inc si
mov[si], ah
int 3
l1:
inc ah
inc si
mov [si], ah
int 3
code ends
end start
code window:

Output:

Result: Two 8 bit numbers are subtracted using Assembly


Languageprogram and executed.
EXPERIMENT: 1 (D)
AIM: Write an Assembly Language Program for subtraction. (16 bit)

APPARATUS: Using DOSBox software.

Program

program for two subtract two 16bit umber .

code segment

assume cs: code

start:
mov ax,0000h
movbx,ax
mov dx,ax
mov si,3000h
movax,[si]
inc si
inc si

mov bx,[si]

inc si

inc si

sub ax,bx
mov [si],ax

jc l1

inc si

inc si
mov[si],dx
int 3
l1:inc dx
inc si
inc si
mov[si],dx
int 3
code ends
end start
Code window:

Output

RESULT –Two 16 numbers are subtracted using Assembly Language


program and executed.
EXPERIMENT: 2
AIM: Write an Assembly Language Program for Multiplication

APPARATUS: Using DOSBox software.

PROGRAM:

Code segment
Assume cs:code
Start:
Mov si,3000h
Mov al,[si]
Inc si
Mov bl,[si]
Mul b1
Inc si
Mov[si],ax
Int 3
Code ends
End start
CODE WINDOW:

OUTPUT:

RESULT: Two numbers are Multiplicated using Assembly Language


program and executed.
B)MULTIPLICATION OF 16 BIT NUMBER
Code segment
Assume cs:code
Start:
Mov si,3071h
Mov ax,[si]
Add si,02h
Mov bx,[si]
Mul bx
Add si,02h
Mov [si],ax
Add si,02h
Mov [si],dx
Int 3
Code ends
End start
Code-window

OUTPUT

RESULT – Two numbers are multiplied using Assembly Language


program and executed.
EXPERIMENT: 3
AIM: Write an Assembly Language Program for Division

APPARATUS: Using DOSBox software.

PROGRAM:

code segment

assume cs: code

start :

mov ax,0000h
mov bx,ax
mov si,3000h
mov al,[si]
inc si
mov bl ,[si]
div b1
inc si
mov[si],ax
int 3
code ends
end start
CODE WINDOW:

OUTPUT:

RESULT: Two numbers are Divided using Assembly Language program


and executed
B)Division of two 16 bit number
code segment
assume cs:code
start:
mov ax,0000h
mov dx,ax
mov bx,ax
mov si,7071h
mov ax,[si]
inc si
inc si
mov bx,[si]
inc si
inc si
div bx
mov[si],ax
incsi
inc si
mov[si],dx
int3
code ends
end start
Code window:

OUTPUT WINDOW

Result:- Two numbers are divided using Assembly Language program and
executed.
EXPERIMENT: 4(A)

AIM: Write an Assembly Language Program to find smallest number.

APPARATUS: Using DOSBox software.

PROGRAM:
Cod segment
Assume cs:code
Start:
Mov ax,0000h
Mov bl,al
Mov cl,al
Mov si,1000h
Mov bl,[si]
Dec b1
Mov cl,bl
Mov si,2000h
L2:mov al,[si]
Cmp al,[si+1]
Jge l1
Xchg al,[si+1]
Mov [si],al
L1:inc si
Loop l2
Int 3
Code ends
End start
Code window:
OUTPUT:

RESULT: we were able to find smallest number from a given set of


numbers using Assembly Language program and executed.
EXPRIMENT: 4(B)
AIM: Write an Assembly Language Program to find Greatest number.

APPARATUS: Using DOSBox software.

PROGRAM:
Code segment
Assume cs:code
Start:
Mov ax,0000h
Mov bl,al
Mov cl,bl
Mov si,1000h
Mov bl,[si]
Dec b1
Mov cl,b1
Mov si,2000h
L2:mov al,[si]
Cmp al,[si+1]
Jle l1
Xchg al,[si+1]
Mov [si],al
L1:inc si
Loop l2
Int 3
Code ends
End start
CODE WINDOW:

OUTPUT:

RESULT: we were able to find greatest number from a given set of


numbers using Assembly Language program and executed
EXPERIMENT: 5

AIM: Write an Assembly Language Program to arrange a given set of numbers in


ascending order.
APPARATUS: Using DOSBox software.

PROGRAM:

code segment
assume cs:code
start:
mov ax,0000h
mov bl,al
mov cl,bl
mov si,1000h
mov bl,[si]
dec b1
l3:mov cl,bl
mov si,7071h
l2:mov al,[si]
cmp al,[si+1]
jle l1
xchg al,[si+1]
mov [si],al
l1:inc si
loop l2
dec bl
jnz l3
code ends
end start
OUTPUT:

RESULT: we were able to arrange a given set of numbers in ascendingorder


using Assembly Language program and executed
EXPERIMENT: 6

AIM: Write an Assembly Language Program to arrange a given set of numbers in


descending order.

APPARATUS: Using DOSBox software.

PROGRAM:

Code segment
Assume cs:code
Start:
Mov ax,0000h
Mov bl,al
Mov cl,bl
Mov si,1000h
Mov bl,[si]
Dec bl
L3:mov c1,bl
Mov si,3000h
L2:mov al,[si]
Cmp al,[si+1]
Jge l1
Xchg al,[si+1]
Mov [si],al
L1:inc si
Loop l2
Dec bl
Jnz l3
Int 3
Code ends
End start
CODE WINDOW:

OUTPUT:

RESULT: we were able to arrange a given set of numbers in descending


order using Assembly Language program and executed
EXPERIMENT: 7

AIM: Write an Assembly Language Program for ADDITION, SUBTRACTION,


MULTIPLICATION AND DIVISION of 8/16 bit numbers using keil software.

APPARATUS: Using KEIL software.

PROGRAM:
//addition
mov a,#40h
mov b,#20h
add a,b
mov r0,a
mov 44h,a
//subtraction
mov a,#40h
mov b,#20h
subb a,b
mov r1,a
mov 45h,a
//multiplication
mov a,#40h
mov b,#20h
mul ab
mov r2,a
mov r3,b
mov 46h,a
mov 47h,b
//division
mov a,#40h
mov b,#20h
div ab
mov r4,a
mov r5,b
mov 48h,a
mov 49h,b
end

CODE WINDOW:

OUTPUT:

RESULT– Two numbers are Added, Subtracted, Multiplicated and


Divided using Assembly Language program and executed
EXPERIMENT: 8

AIM: Write an Assembly Language Program for logic instructions i.e., and, or, xor and
complement of 8/16-bit numbers Using KEIL software

APPARATUS: Using KEIL software.

PROGRAM:
//and operation
mov a,#40h
mov r0,#20h
anl a,r0
mov r1,a
mov 44h,a
//or operation
mov a,#40h
mov r2,#20h
orl a,r2
mov r3,a
mov 45h,a
//xor operation
mov a,#40h
mov r4,#20h
xrl a,r4
mov r5,a
mov 46h,a
//cmpl operation
mov a,#40h
cpl a
mov r6,a
mov 47h,a
end

CODE WINDOW:

OUTPUT :

Result: Logic instructions i.e., and, or, xor and complement of 8/16-bit numbers
Using KEIL software were performed using Assembly Language program and
executed.
EXPERIMENT: 9
AIM: To write assembly language program using Using KEIL software to perform
Multi byte addition and subtraction .

APPARATUS: Using KEIL software.

PROGRAM:
//addition

mov a,#20h

mov r0,#10h

add a,r0

mov r1,a

mov 44h,a

mov a,#40h

mov r2,#20h

add a,r2

mov r3,a

mov 45h,a

//subtraction

mov a,#20h

mov r4,#10h

subb a,r4

mov r5,a

mov 46h,a

mov a,#40h

mov r6,20h

subb a,r6
mov r7,a

mov 47h,a

end

CODE WINDOW :

OUTPUT:

RESULT– Two numbers are Added, subtracted using Assembly


Language program and executed.
EXPERIMENT: 10
AIM: ALP to transfer data from ROM memory.

Apparatus Required: Using Keil uVision5 software

Program:
// ALP to transfer data from ROM memory

org 0000h

mov dptr, #600h

mov r0, #60h

mov r7, #07h

back: movc a, @a+dptr

mov @ r0,a

inc dptr

inc r0

clr a

djnz r7,back

org 600h

db 10h, 20h, 30h, 40h, 50h, 60h, 70h

end.
CODE WINDOW :

OUTPUT :

RESULT : ALL Data is moved to RAM

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy