0% found this document useful (0 votes)
65 views74 pages

Mprecord PDF

The document is a microprocessor record for experiments conducted on assembly language programs using 8086 instructions. It contains an index listing 12 experiments conducted, including familiarization of assembler directives and 8086 instructions, programs to display "Hello World", take keyboard input and display output, study ASCII conversions, and perform arithmetic operations. It provides the aims, procedures, and results for each experiment.

Uploaded by

Karthik
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)
65 views74 pages

Mprecord PDF

The document is a microprocessor record for experiments conducted on assembly language programs using 8086 instructions. It contains an index listing 12 experiments conducted, including familiarization of assembler directives and 8086 instructions, programs to display "Hello World", take keyboard input and display output, study ASCII conversions, and perform arithmetic operations. It provides the aims, procedures, and results for each experiment.

Uploaded by

Karthik
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/ 74

GOVERNMENT

POLYTECHNIC COLLEGE
CHERTHALA

MICROPROCESSOR RECORD

Name ..............................................................................
Class..................................................Roll No. ...............
2021-22
Reg. No.......................................Year........2020-21...........

DEPARTMENT OF

COMPUTER ENGINEERING

1
2
GOVERNMENT
POLYTECHNIC COLLEGE
CHERTHALA

MICROPROCESSOR RECORD

Name ..............................................................................
Class..................................................Roll No. ...............
Reg. No.......................................Year........2021-22
2020-21..........

3
4
INDEX
EXP. NAME OF EXPERIMENT PAGE
NO NO:

1 FAMILIARIZATION OF ASSEMBLER DIRECTIVES AND 8086 7-13


INSTRUCTIONS

2 HELLO WORLD 14-15

3 STUDY OF KEYBOARD I/P AND SCREEN DISPLAY 17-19

4 STUDY OF ASCII CONVERSIONS 21-23

5 STUDY OF ARITHMETIC INSTRUCTIONS 24-27

6 STUDY OF ARITHMETIC INSTRUCTIONS 29-37

7 SQUARE OF A SINGLE DIGIT 39-41

8 STUDY OF LOGICAL & ROTATE INSTRUCTION 43-49

9 PROGRAM ILLUSTRATING REVERSE OF A STRING 51-53

10 PROGRAM ILLUSTRATING ‘IF’ STRUCTURE 55-63

11 IMPLEMENTING ‘COPY – PASTE’ 65-67

12 STUDY OF STRING INSTRUCTIONS 69-73

5
6
EXP NO:1 DATE:

FAMILIARIZATION OF ASSEMBLER DIRECTIVES AND 8086


INSTRUCTIONS
AIM:- To Familiarization of Assembler Directives and 8086 Instructions.
PROCEDURE:-

ASSEMBLER
An assembler is a program that converts assembly language program into
machine code. It takes the basic commands and operations from assembly
code and converts them into binary code that can be recognized by a specific
type of processor.
MASM
The Macro Assembler (MASM) is a tool that converts x86 assembly language
programs intermediate OBJ files.
Usage: MASM <asm file>
LINK
LINK is used convert the intermediate OBI files to executable files.
Usage: LINK <obj file>
DEBUG
DEBUG is used to debug an executable program
Assembler Directive
Assembler directives are commands used in the assembler.
ASSUME
The ASSUME directive is used to inform the assembler the name of the logical
segment it should use for specified segment.
Eg: ASSUME CS:CODE, DS:DATA

7
8
DB-Define Byte: Used to declare a byte variable (1 byte)
DW-Define Word : Used to declare word variable (2 bytes)
DD-Define Double Word: Used to declare double words (4 bytes)
DQ-Define Quad Word: Used to declare quad words (8 bytes)
DT-Define Ten Byte: Used to declare ten bytes variable (10 bytes)
EQU: It is used to give a name to a value.
Eg: COUNT EQU 10
PROC-ENDP: Used to start and end a procedure
MACRO-ENDM: Used to start and end a macro

Important 8086 Instructions

MOV - Used to copy a byte or word from a source to destination.


PUSH-Used to put a word at the top of the stack.
POP- Used to get a word from the top of the stack to the provided location.
LEA - Used to load the address of operand into the provided register.
ADD - Used to add a byte/word with another byte/word.
INC - Used to increment a byte/word by 1. SUB - Used to subtract a byte/word
from another byte/word.
DEC - Used to decrement a byte/word by 1.
CMP - Used to compare 2 bytes/words.
MUL- Used to multiply a byte/word by another byte/word. DIV - Used to divide
a word/double word by a byte/word.
NOT - Used to invert each bit of a byte or word.

9
10
AND- Used for AND operation.
OR - Used for OR operation
XOR-Used for Exclusive-OR operation
LODS/LODSB/LODSW-Used to store the string byte into AL or string word into
AX.
STOS/STOSB/STOSW-Used to store the AL into string byte or AX into string
word. Kinto
MOVS/MOVSB/MOVSW-Used to move data from one string to another.
CALL- Used to call a procedure
RET - Used to return from a procedure to the main program.
INT - Used to interrupt the program during execution and calling service
specified.
JA- Jump on above.
JNZ - jump on non zero
JZ-Jump on zero.
INT 21H
INT 21H is the MS-DOS service interrupt. It contains several functions.
1-Character Input
On entry: AH = 01h
Returns: AL=8 bit data input

2- Character output
On entry: AH = 02h, DL=8 bit data
Returns: Nothing

9- Output character string

11
12
On entry: AH = 09h, DS:DX = segment:offset of string
Returns: Nothing
OA - Input String
On entry: AH = 0Ah, DS:DX = segment:offset of string buffer
Returns: Nothing
4C-Terminate program with return code
On entry: AH = 4CH, AL= Return code (Error level)
Returns: Nothing
RESULT:- Familiarized the assembler directives and 8086 instructions

13
OUTPUT:

14
EXP NO:2 DATE:

HELLO WORLD
AIM: Write an ALP program to display string ”HELLO WORLD”
PROGRAM
.model small
.stack 100h

.data
str db "HELLO WORLD $"
.code

mov ax,@data
mov ds,ax

lea dx,str
mov ah,09h
int 21h

mov ah,4ch
int 21h
end

RESULT:- Program executed successfully and output verified

15
16
EXP NO:3 DATE:

STUDY OF KEYBOARD I/P AND SCREEN DISPLAY

AIM: Write an assembly Language program(ALP) in 8086 to read a character


from the keyboard in to a vaiable called ‘VAR’ and display it on the console.

PROGRAM
.model small
.stack 100h
.data
msg1 db 13,10, "ENTER THE CHARACTER :-$" ,13,10
msg2 db 13,10, "THE ENTERED CHARACTER IS:-$" ,13,10
var db ?
.code
mov ax,@data
mov ds,ax
lea dx,msg1
mov ah,09h
int 21h
mov ah,01h
int 21h

mov var,al
lea dx,msg2
mov ah,09h

17
OUTPUT

18
int 21h
mov dl,var
mov ah,02h
int 21h
mov ah,4ch
int 21h
end

RESULT
Program executed successfully and output verified.

19
20
EXP NO:4 DATE:

STUDY OF ASCII CONVERSIONS


AIM: Write an ALP in 8086 to read an uppercase alphabet and convert in to
corresponding lowercase alphabet
PROGRAM
.model small
.stack 100h
.data
msg1 db "ENTER THE UPPER CASE CHARACTER:-$",13,10
msg2 db 13,10," THE ENTERED CHARACTER IS:-$"
msg3 db 13,10,"CHAR CONVERTED IN TO IT'S LOWER CASE AS:-$"
.code
main proc
mov ax,@data
mov ds,ax

lea dx,msg1
call message
call enter_char
mov bl,al

lea dx,msg2
call message
mov dl,bl
call disp_char
lea dx,msg

21
OUTPUT:

22
call message
add bl,32
mov dl,bl
call disp_char
mov ah,4ch
int 21h
main endp
message proc
mov ah,09h
Int 21h
ret
message endp
enter_char proc
mov ah,01h
int 21h
ret
enter_char endp
disp_char proc
mov ah,02h
int 21h
ret
disp_char endp
end main
RESULT
Program executed successfully and output verified.

23
OUTPUT

24
EXP NO:5 DATE:

STUDY OF ARITHMETIC INSTRUCTIONS


AIM: Write an ALP program to find addition of two single digit numbers(<9)
PROGRAM
.model small
.stack 100h
.data
msg1 db "ENTER FIRST NUMBER:-$",13,10
msg2 db 13,10,"ENTER SECOND NUMBER:-$"
msg3 db 13,10,"SUM IS :-$"
N1 db ?
N2 db ?
.code
mov ax,@data
mov ds,ax
lea dx,msg1
mov ah,09h
int 21h
mov ah,01h
int 21h

sub al,30h
mov N1,al

lea dx,msg2
mov ah,09h

25
26
int 21h
mov ah,01h
int 21h
sub al,30h
mov N2,al

lea dx,msg3
mov ah,09h
int 21h

mov al,N1
add al,N2
add al,30h

mov ah,02h
mov dl,al
int 21h
mov ah,4ch
int 21h
end

RESULT
Program executed successfully and output verified.

27
28
EXP NO:6 DATE:

STUDY OF ARITHMETIC INSTRUCTIONS


AIM: Write an assembly language program in 8086 to perform 8 bit operations
(+,-,*,/)
PROGRAM
.model small
.stack 100h

.data
msg db 13,10,"CHECK $"
msg1 db 13,10,"ENTER FIRST NUMBER: $"
msg2 db 13,10,"ENTER SECOND NUMBER: $"
msg3 db 13,10,"THE QUOTIENT IS: $"
msg4 db 13,10,"THE REMAINDER IS: $"
msg5 db 13,10,"THE SUM IS:-$"
msg6 db 13,10,"THE DIFFERENCE IS: $"
msg7 db 13,10,"THE PRODUCT IS: $"
num1 db ?
num2 db ?
remainder db ?
quotient db ?
sum db ?
difference db ?
product db ?

.code

29
30
main proc
mov ax,@data
mov ds,ax

lea dx,msg1
call message
call input

mov num1,al
lea dx,msg2
call message
call input

mov num2,al
call compute_a
lea dx,msg5
call message
mov dl,sum
call output
call compute_s

lea dx,msg6
call message
mov dl,difference
call output

31
32
call compute_m
lea dx,msg7
call message
mov dl,product
call output
call compute_d
lea dx,msg3
call message
mov dl,quotient
call output
lea dx,msg4
call message
mov dl,remainder
call output
mov ah,4ch
int 21h
main endp
input proc
mov ah,01h
int 21h
sub al,30h
ret
input endp
output proc
mov ah,02

33
34
add dl,30h
int 21h
ret
output endp
message proc
mov ah,09
int 21h
ret
message endp
compute_a proc
mov al,num1
add al,num2
mov sum,al
ret
compute_a endp
compute_s proc
mov al,num1
sub al,num2
mov difference,al
ret
compute_s endp
compute_m proc
mov al,num1
mov bl,num2
mul bl

35
OUTPUT

36
mov product,al
ret
compute_m endp
compute_d proc
xor ah,ah
mov al,num1
mov bl,num2
div bl
mov quotient,al
mov remainder,ah
ret
compute_d endp
end main

RESULT
Program executed successfully and output verified.

37
38
EXP NO:7 DATE:

SQUARE OF A SINGLE DIGIT


AIM: Write an ALP program to find square of a single digit numbers(<9)
PROGRAM
.model small
.stack 100h
.data
msg db 0ah,0dh,"input number: $"
res db 0ah,0dh,"square is"
n dw ?
db "$"

.code
mov ax,@data
mov ds,ax

lea dx,msg
mov ah,09h
int 21h
mov ah,01h
int 21h

sub al,30h
mul al
mov dl,10
div dl

39
OUTPUT

40
or ax,3030h
mov n,ax
lea dx,res
mov ah,09h
int 21h
mov ah,4ch
int 21h
end

RESULT
Program executed successfully and output verified.

41
42
EXP NO:8 DATE:

STUDY OF LOGICAL & ROTATE INSTRUCTION


AIM: Write an ALP in 8086 to find the given number is odd or even
PROGRAM
.model small
.stack 100h
.data
source db 5 dup(?)
c_even db 0
c_odd db 0

msg1 db "enter an element into source block array: $"


msg2 db "the number of even array element is: $"
msg3 db "the number of odd array elemebt is: $"
.code
main proc
mov ax,@data
mov ds,ax
lea si,source
mov cx,0005
up:
call newline
lea dx,msg1
call message
call newline
call input

43
44
sub al,30h
mov [si],al
inc si
loop up
lea si,source
mov cx,0005
mov bx,0
up1: mov al,[si]
ror al,1
jc odd
inc bl

jmp next
odd : inc bh
next: inc si
loop up1
mov c_even,bl
mov c_odd,bh

call newline
call newline

lea dx,msg2
call message
call newline

45
46
mov dl,c_even
add dl,30h
call output

call newline
call newline

lea dx,msg3
call message
call newline

mov dl,c_odd
add dl,30h
call output
mov ah,4ch
int 21h
main endp

message proc
mov ah,09h
int 21h
ret

message endp

47
OUTPUT

48
output proc
mov ah,02
int 21h
ret

output endp
input proc
mov ah,01
int 21h
ret
input endp

newline proc
mov ah,02
mov dl,0ah
int 21h
mov dl,0dh
int 21h
ret
newline endp
end main

RESULT
Program executed successfully and output verified.

49
50
EXP NO:9 DATE:

PROGRAM ILLUSTRATING REVERSE OF A STRING


AIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM ( ALP) IN 8086 TO ILLUSTRATING
REVERSE OF STRING.

PROGRAM
.model small
.stack 100h
.data
msg1 db 0ah,0dh,"enter the string: $"
msg2 db 0ah,0dh,"string reverse: $"
str db 25 dup('$')

.code
mov ax,@data
mov ds,ax
lea dx,msg1
mov ah,09h
int 21h

lea dx,str
mov ax,0ah
mov cx,0ah
mov ah,3fh
int 21h

sub ax,02h

51
OUTPUT

52
mov si,ax
mov cx,ax
lea dx,msg2
mov ah,09h
int 21h

next: dec si
mov dl,str[si]
mov ah,02
int 21h

loop next
mov ah,4ch
int 21h
end

RESULT
Program executed successfully and output verified.

53
54
EXP NO:11 DATE:

PROGRAM ILLUSTRATING ‘IF’ STRUCTURE


AIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM( ALP) IN 8086 TO READ AN ARRAY OF 5
ELEMENTS (SINGLE DIGIT) AND COMPUTE THE LARGEST AMONG THEM

PROGRAM
.model small
.stack 100h
.data

source db 5 dup(?)
largest db 0

msg1 db "ENTER AN ELEMENT INTO SOURCE BLOCK ARRAY:-$"


msg2 db "THE ELEMENTS IN SOURCE BLOCK ARRAY ARE:-$"
msg3 db "THE LARGEST ARRAY ELEMENT IS $"

.code
main proc
mov ax,@data
mov ds,ax
lea si,source
mov cx,0005

up:
call newline

55
56
lea dx,msg1
call message
call newline
call input

sub al,30h
mov [si],al
inc si
loop up

call message
call newline
lea dx,msg2
call message
lea si,source
mov cx,0005

dis: call newline


mov dl,[si]
call output
call newline
inc si
loop dis

57
58
lea si,source
mov cx,0005

up1:
mov al,largest
cmp al,[si]
jnc skip

mov al,[si]
mov largest,al
skip: inc si

loop up1
call newline
call newline
lea dx,msg3
call message
call newline

mov dl,largest

call output
mov ah,4ch
int 21h
main endp

59
60
message proc
mov ah,09h
int 21h
ret
message endp

output proc
mov ah,02
add dl,30h
int 21h
ret
output endp

input proc
mov ah,01
int 21h
ret
input endp

newline proc
mov ah,02
mov dl,0ah
int 21h
mov dl,0dh
int 21h

61
OUTPUT

62
ret
newline endp
end main
RESULT
Program executed successfully and output verified.

63
64
EXP NO:11 DATE:

IMPLEMENTING ‘COPY – PASTE’


AIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM( ALP) IN 8086 TO TRANSFER A BLOCK OF
DATA FROM ONE SET OF MEMORY LOCATIONS INTO ANOTHER.

PROGRAM
.model small
.stack 100h
.data
source db 1h,2h,3h,4h,5h
dest db 5 dup(?)
msg db "the transferred block of data is $"
.code
main proc
mov ax,@data
mov ds,ax
lea si,source
lea di,dest
lea dx,msg
mov ah,09h
int 21h
mov cx,0005
up:
mov al,[si]
mov [di],al
call newline
mov dl,[di]

65
OUTPUT

66
call output
inc si
inc di
loop up
mov ah,4ch
int 21h
main endp
output proc
mov ah,02
add dl,30h
int 21h
ret
output endp
newline proc
mov ah,02
mov dl,0ah
int 21h
mov dl,0dh
int 21h
ret
newline endp
end main
RESULT
Program executed successfully and output verified.

67
68
EXP NO:12 DATE:

STUDY OF STRING INSTRUCTIONS


AIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM( ALP) IN 8086 TO CHECK WHETHER A
GIVEN STRING IS A PALINDROME / NOT USING STRING INSTRUCTIONS.

PROGRAM
.model small
.stack 100h
.data
disp_pal db"THE ENTERED STRING IS A PALINDROME $"
disp_nopal db"THE ENTERED STRING IS NOT A PALINDROME $"
arr db "MALAYALAM$"
rev_arr db 9 dup('$')

.code
main proc
mov ax,@data
mov ds,ax
;checking for palindrome

lea si,arr
lea di,rev_arr+8
mov cx,0009
back:cld
lodsb
std

69
70
stosb
loop back
lea si,arr
lea di,rev_arr
mov cx,0009
cld
repz cmpsb
jnz notpal
call newline
lea dx,disp_pal
call message
jmp exit_dos
call newline
notpal:call newline
lea dx,disp_nopal
call message
exit_dos:mov ah,4ch
int 21h
main endp
newline proc
mov ah,02
mov dl,0ah
int 21h
mov dl,0dh
int 21h

71
OUTPUT

72
ret
newline endp
message proc
mov ah,09h
int 21h
message endp
end main

RESULT
Program executed successfully and output verified.

73
74

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