Mprecord PDF
Mprecord PDF
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:
5
6
EXP NO:1 DATE:
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
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
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
15
16
EXP NO:3 DATE:
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:
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:
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:
.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:
.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:
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
.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
.model small
.stack 100h
.data
source db 5 dup(?)
largest db 0
.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
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:
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:
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