KEMBAR78
MPMC Experiment 1 Manual | PDF | Assembly Language | Office Equipment
0% found this document useful (0 votes)
10 views11 pages

MPMC Experiment 1 Manual

The document provides a detailed guide for using MASM in a Microprocessors and Microcontrollers lab, including steps for executing assembly language programs for arithmetic operations, multiplication, division, and calculating factorial, square, and cube of a number. It outlines the necessary commands and structure for writing and debugging assembly programs, along with example codes and expected outputs. The document concludes with successful execution results for the various programs demonstrated.

Uploaded by

vallimahaboob777
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)
10 views11 pages

MPMC Experiment 1 Manual

The document provides a detailed guide for using MASM in a Microprocessors and Microcontrollers lab, including steps for executing assembly language programs for arithmetic operations, multiplication, division, and calculating factorial, square, and cube of a number. It outlines the necessary commands and structure for writing and debugging assembly programs, along with example codes and expected outputs. The document concludes with successful execution results for the various programs demonstrated.

Uploaded by

vallimahaboob777
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/ 11

DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

INTRODUCTION TO MASM

1. Switch on the computer.


2. Select “start-> run” button.
3. Type “cmd” & click ok.
4. Press alt+enter to get full screen.
5. Type cd.. & press “enter” button.
6. Repeat step 4.
7. Type ” cd MASM (or) Term 86E” & press enter button.
8. Type “edit” & press “enter” button
9. Type the program & select “file ->save as”
10. Save the file with an exetension “.asm”,(ex1.asm)
11. Select “file->exit”
12. Type the command “MASM (or) Term 86E programname.asm” & press enter 4 times.
13. Check if any errors / warnings are there in ur program ..if any errors are there
modify the program by giving the command ”edit programname.asm”
14. Again save the program.
15. Repeat step 12 until u get 0 errors & 0 warnings.
16. Then type the command “link programname.obj” (ex1.obj) & press enter 4 times
17. Then type the command “debug programname.exe”(ex1.exe) & press enter.
18. Give the command ” u “ to note the address & opcode of program.
19. Give the command ” t“ to check the registers update after each & every
instruction execution, repeat this process until the program ends.
20. If the RESULT is in memory location give the command “d ds:0000”
21. To quit from debugging mode type the command “q”
22. Repeat the same process from step 8 to execute the next program.
DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS


(Using various addressing modes)

A. ADDITION & SUBTRACTION

Aim: To Write an Assembly Language Program to perform addition & subtract two
16-Bit Numbers.

Apparatus:
Software: MASM (or) TERM 86E
Hardware: PC, Key Board/ 8086 Trainer Kit, R.P.S

Program:

Address Opcode Label Mnemonics Operands Comments


ASSUME CS:CODE, DS:

DATA DATA SEGMENT

X DW 4521H
Y DW 1324H
Z DW ?

DATA ENDS
CODE SEGMENT
START: MOV AX,DATA ;Copy Data Segment Starting
Address into AX Register
MOV DS,AX ;Copy the Content of AX into DS
MOV AX,X ;Copy the Contents of X into
AX Register.
MOV BX,Y ;Copy the Contents of Y into
BX Register.
ADD AX, BX ;Add the Contents of AX with
BX.
MOV Z,AX ;Copy the Contents of AX into
memory location pointed by Z.
INT 21H ;Return to DOS Prompt.

CODE
ENDS
END
START
Input: AX = 4521H, BX=1324H
Output: AX = 5645H
DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

Subtraction Program:

Adress Opcode Label Mnemonics Operands Comments


ASSUME CS:CODE, DS:

DATA DATA SEGMENT


X DW 4521H
Y DW 1324H
Z DW ?

DATA

ENDS

CODE SEGMENT
START MOV AX,DATA ;Copy Data Segment Starting
Address into AX Register
:
MOV DS,AX ;Copy the Content of AX into
DS
MOV AX,X ;Copy the Contents of X
into AX Register.
MOV BX,Y ;Copy the Contents of Y
into BX Register.
SUB AX, BX ;Subtract the Contents of AX
with BX.
MOV Z,AX ;Copy the Contents of AX
into memory location
pointed by Z.
INT 21H ;Return to DOS Prompt.

CODE
ENDS
END
START

Input: AX = 4521H, BX=1324H

Output: AX = 31FDH

RESULT: The Assembly Language Program to add & subtract two 16-bit numbers
was successfully executed.
DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

B. 16-BIT UNSIGNED & SIGNED MULTIPICATION & DIVISION


Aim: To Write an Assembly Language Program to Perform Multiplication and
Division of signed and unsigned Hexadecimal numbers.

Apparatus:
Software: MASM (or) TERM 86E
Hardware: PC, Key Board, 8086 Trainer Kit, R.P.S

Unsigned Multiplication Program:

Address Opcode Label Mnemoni Operands Comments


cs
ASSUME CS:CODE, DS:

DATA DATA SEGMENT

X DW 4521H
Y DW 1324H
Z DW ?

DATA

ENDS

CODE SEGMENT
START: MOV AX,DATA ;Copy Data Segment Starting
Address into AX Register
MOV DS,AX ;Copy the Content of AX into DS
MOV AX,X ;Copy the Contents of X into AX
Register.
MOV BX,Y ;Copy the Contents of Y into BX
Register.
MUL BX ;Multiply the Contents of AX with
BX.
MOV SI, OFFSET Z ;Copy the Address pointed by Z into
SI.
MOV [SI],AX ;Copy the Contents of AX into
Memory location pointed by SI.
ADD SI,02H ;Add 02 to SI Register.
MOV [SI],DX ;Copy the Contents of DX into
memory location pointed by SI.
INT 21H ;Return to DOS Prompt.
CODE
ENDS END
START
DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

Input: AX = 4521H, BX=1324H

Output: DX = 052BH & AX = 2BA4H (Multiplication Of 4521H * 1324H = 052B2BA4 H)


DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

UNSIGNED DIVISION Program:

Address Opcode Label Mnemonics Operands Comments


ASSUME CS:CODE, DS:

DATA DATA SEGMENT

X DW 4521H
Y DW 1324H
Z DW ?

DATA

ENDS

CODE SEGMENT
START ;Copy Data Segment
Starting Address into AX
: MOV AX,DATA Register
MOV DS,AX ;Copy the Content of AX into
DS
MOV AX,X ;Copy the Contents of X
into AX Register.
MOV BX,Y ;Copy the Contents of Y
into BX Register.
DIV BX ;Divide the Contents of AX
with BX.
MOV SI, OFFSET ;Copy the Address pointed by
Z Z into SI.
MOV [SI],AX ;Copy the Contents of AX
into Memory location
pointed by SI.
ADD SI,02H ;Add 02 to SI Register.

MOV [SI],DX ;Copy the Contents of DX


into memory location pointed
by SI.
INT 21H ;Return to DOS Prompt.

CODE
ENDS
END
START

Input: AX = 4521H, BX=1324H

Output: DX = 0BB5H (Remainder) & AX = 0003H (Quotient)


DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

SIGNED MULTIPLICATION Program:

Address Opcode Label Mnemonics Operands Comments


ASSUME CS:CODE,

DS: DATA

DATA SEGMENT
X DW 4521H
Y DW 1324H
Z DW ?

DATA

ENDS

CODE SEGMENT
START: MOV AX,DATA ;Copy Data Segment Starting
Address into AX Register
MOV DS,AX ;Copy the Content of AX into
DS
XOR AX,AX ;Clear Contents of AX Register.

MOV AX,X ;Copy the Contents of X into


AX Register.
MOV BX,Y ;Copy the Contents of Y into
BX Register.
NEG BX ;Perform 2’s Complement of BX.
CWD ;Convert Word into Double
Word
IMUL BX ;Multiply the Contents of AX
with BX Including Sign.
MOV SI, OFFSET Z ;Copy the Address pointed by Z
into SI.
MOV [SI],AX ;Copy the Contents of AX into
Memory location pointed by SI.
ADD SI,02H ;Add 02 to SI Register.
MOV [SI],DX ;Copy the Contents of DX into
memory location pointed by SI.
INT 21H ;Return to DOS Prompt.

CODE
ENDS
END
START

Input: AX = 4521H, BX=1324H


Output: DX = FAD4H & AX = D45CH ( Multiplication of 4521H * -1324H =FAD4D45C H)
DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

SIGNED DIVISION Program:

Address Opcode Label Mnemoni Operands Comments


cs
ASSUME CS:CODE, DS:

DATA DATA SEGMENT


X DW 4521H
Y DW 1324H
Z DW ?

DATA

ENDS

CODE SEGMENT
START: MOV AX,DATA ;Copy Data Segment Starting
Address into AX Register
MOV DS,AX ;Copy the Content of AX into DS
XOR AX,AX ;Clear Contents of AX Register.
MOV AX,X ;Copy the Contents of X into AX
Register.
MOV BX,Y ;Copy the Contents of Y into BX
Register.
NEG BX ;Perform 2’s Complement of BX.
CWD ;Convert Word into Double Word
IDIV BX ;Divide the Contents of AX with BX
Including Sign.
MOV SI, OFFSET Z ;Copy the Address pointed by Z into
SI.
MOV [SI],AX ;Copy the Contents of AX into
Memory location pointed by SI.
ADD SI,02H ;Add 02 to SI Register.
MOV [SI],DX ;Copy the Contents of DX into
memory location pointed by SI.
INT 21H ;Return to DOS Prompt.
CODE
ENDS
END
START
Input: AX = 4521H, BX=1324H
Output: AX = FFFDH
(QUOTIENT) DX =
0BB5H (REMAINDER)
RESULT: The Assembly Language Program to Perform Multiplication and
Division of signed and unsigned Hexadecimal numbers was successfully executed.
DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

C.FACTORIAL, SQUARE & CUBE OF A


NUMBER

Aim: To Write an ALP to find square, cube and factorial of a given number.
Apparatus:
Software: MASM (or) TERM 86E

Hardware: PC, Key Board, 8086 Trainer Kit, R.P.S

Factorial Program:
Address Opcode Label Mnemonics Operands Comments
ASSUME
CS:CODE,DS:DATA
DATA SEGMENT
N DB 04H
RES DW ?
DATA ENDS
CODE SEGMENT
MOV AX,DATA ;Copy Data Segment Starting
START Address into AX Register
:
MOV DS, AX ;Copy the Content of AX into DS
XOR AX,AX ;Clear Contents of AX Register.
MOV AL, N ;Copy the Contents of X into AX
Register.
XOR BX,BX ;Clear Contents of BX Register.
MOV BL,AL ;Copy Contents of AL in to
Register BL
UP: DEC BL ; Decrement BL by 01
CMP BX, 01 ;Compare BX register contents
with 01H
JZ EXIT ; Jump to Label EXIT if ZF = 1
MUL BL ;Multiply contents of AL with BL
JMP UP ;Jump to Label UP
EXIT: MOV RES, AX ; Copy the Factorial of N into
Memory Location RES.
INT 21H ; Return to DOS Prompt
CODE
ENDS
END
START
Input: N =[0000]= 04H
Output: RES =[0001]= 18H
DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

Square of a Number Program:

Address Opcode Label Mnemonics Operands Comments


ASSUME
CS:CODE,DS:DATA
DATA SEGMENT
X DB 08H
SQR DW (?)
DATA ENDS
CODE SEGMENT
MOV AX,DATA ;Copy Data Segment
Starting Address into AX
START Register
:
MOV DS, AX ;Copy the Content of AX
into DS
XOR AX,AX ;Clear Contents of AX
Register.
MOV AL, X ;Copy the Contents of X
into AX Register.
MUL AL ;Multiply contents of AL
with AL & RESULT is
stored in AX.
MOV SQR,AX ;Copy the contents of AX
into SQR Memory
Location
INT 21H ; Return to DOS Prompt

CODE
ENDS END
START

Input: X =[0000]= 08H

Output: SQR =[0001]= 40H


DEPT OF ECE MICROPROCESSORS & MICROCONTROLLERS LAB

Cube of a Number Program:

Address Opcode Label Mnemonics Operands Comments


ASSUME
CS:CODE,DS:DATA
DATA SEGMENT
X DB 08H
CUBE DW
(?)
DATA ENDS
CODE SEGMENT
MOV AX,DATA ;Copy Data Segment
Starting
START Address into AX Register
:
MOV DS, AX ;Copy the Content of AX
into DS
XOR AX,AX ;Clear Contents of AX
Register.
MOV AL, X ;Copy the Contents of X
into AX Register.
MOV BL,AL ;Copy the Contents of
Register BL into AL
Register.

MUL BL ;Multiply contents of AL


with BL & RESULT is
stored in AX.
MUL BL ;Multiply contents of AL
with BL & RESULT is
stored in AX.
MOV CUBE,AX ;Copy the contents of AX
into SQR Memory
Location
INT 21H ; Return to DOS Prompt

CODE
ENDS END
START

Input: X =[0000]= 08H

Output: AX= 200H

RESULT: The Assembly Language Program to find square, cube and factorial of a
given number was successfully executed.

You might also like