vtu microprocessor lab programs
TRANSCRIPT
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 1/35
vtu microprocessor lab programs
67
rate or flag this pageTweet this
By techno geek
PGM TO READ A CHAR FROM THE KEYBOARD IN THE MODULE1 DISPLAY ACHAR IN MODULE2
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
stack segment
dw 64 dup(0)
stack ends
data segment
str db 100 dup(0)
msg db 0Ah, 0Dh, '$'
data ends
code segment
assume cs:code,ds:data,ss:stack
start:mov ax,data
mov ds,ax
extrn scan:far
extrn display:far
lea si,str
mov cl,00h
again:call scan
cmp al,0Dh
je exit
mov [si],al
inc si
inc cl
jmp again
exit:lea dx,msg
mov ah,09h
int 21h
lea si,str
repeat:cmp cl,00h
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 2/35
33
34
35
36
37
38
39
40
41
42
43
44
45
46
je t1
mov al,[si]
call display
inc si
dec cl jmp repeat
t1:mov ah,4ch
int 21h
code ends
end start
_
2 (a1) ;READ A CHARACTR FROM THE KEYBOARD
?
1
2
3
4
5
6
7
8
9
10
11
12
13
rdkb macro
mov ah,01h
int 21h
endm
code segment
assume cs:code
start:public scan
scan proc far
rdkb
ret
scan endp code ends
end start
2 (a2) ;TO DISPLAY A CHARACTER IN MODULE[2]
?
1
2
3
4
5
67
8
9
10
11
12
13
echo macro
mov dl,al
mov ah,02h
int 21h
endm
stack segment dw 64 dup(0)
stack ends
code segment
assume cs:code, ss:stack
start:public display
display proc far
echo
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 3/35
14
15
16
17
ret
display endp
code ends
end start
PROGRAMME TO IMPLEMENT THE BCD UPCOUNTER
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
data segment
porta equ 0280h
cwr equ 0283h
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov dx,cwr
mov al,82h
out dx,al
mov ah,01h
int 21h
cmp al,31h
je up
jmp down
up: mov al,00h
mov dx,porta
again: out dx,al
inc al
cmp al,0ah
je stop
call delay
jmp again
down: mov al,09h
mov dx,porta
next: out dx,al
dec al
cmp al,0ffh
je stop
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 4/35
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
call delay
jmp next
stop: mov ah,4ch
int 21h
delay proc
mov si,0ffffh
t2: mov di,200h
t1: dec di
jnz t1
dec si
jnz t2
ret
delay endp
code ends
end start
PROGRAMME TO PERFORM THE RING COUNTER
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
data segment
porta equ 0280h
cwr equ 0283h
data ends
code segment
assume cs:code,ds:data
start: mov ax,data mov ds,ax
mov dx,cwr
mov al,82h
out dx,al
mov al,01h
mov cl,08h
mov dx,porta
again: out dx,al
call delay
rol al,1
dec cl
jnz again
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 5/35
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
int 3h
delay proc
mov si,0ffffh t2: mov di,200h
t1: dec di
jnz t1
dec si
jnz t2
ret
delay endp
code ends
end start
TO SORT A GIVEN NO IN ASCENDING AND DESCENDING ORDER
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
data segment
num1 db 12h,21h,17h,19h
num2 db 4 dup(0)
num3 db 4 dup(0)
l1 dw 0004
data ends
code segment
assume cs:code,ds:data,ss:stack
start:mov ax,data mov ds,ax
lea si,num1
lea di,num2
lea bx,num3
mov cx,l1
repeat1:mov al,[si]
mov [di],al
mov [bx],al
inc si
inc di
inc bx
dec cx
jnz repeat1
mov bx,l1
dec bx
outlp1:mov cx,bx
lea si,num2
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 6/35
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
inlp1:mov al,[si]
inc si
cmp al,[si]
jb next1
xchg al,[si]
mov [si-1],al next1:dec cx
jnz inlp1
dec bx
jnz outlp1
mov bx,l1
dec bx
outlp2:mov cx,bx
lea si,num3
inlp2:mov al,[si]
inc si
cmp al,[si]
ja next2
xchg al,[si]
mov [si-1],al
next2:dec cx
jnz inlp2
dec bx
jnz outlp2
int 3h
code ends
end start
READ A STATUS OF TWO 8 BITS INPUTS FROM THE LOGIC CONTROLLER XAND Y. DISPLAY X*Y.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
data segment
porta equ 0280h
portb equ 0281h
cwr equ 0283h
data ends
code segment
assume cs:code, ds:data
start: mov ax,data
mov ds,ax
mov dx,cwr
mov al,82h
out dx,al
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 7/35
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
mov dx,portb
in al,dx
mov bl,al
mov ah,01h
int 21h
in al,dx
mul bl
mov cx,ax
mov dx,porta
out dx,al
mov ah,01h
int 21h
mov al,ch
out dx,al
mov ah,4ch
int 21h
code ends
end start
READ AN ALPHANUMERIC CHARACTERS AND DISPLAY ITS EQUIVALENTASCII CODE AT THE CENTRE OF THE SCREEN
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
stack segment
dw 64 dup(0)
stack ends
data segment
str db 'enter the character:$'
data ends
code segment
assume cs:code,ds:data,ss:stack
start:mov ax,data
mov ds,ax
lea dx,str
mov ah,09h
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 8/35
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
int 21h
mov ah,01h
int 21h
mov bl,al
call clrscr
call curset call display
mov ah,4ch
int 21h
clrscr proc
mov cx,0000h
mov dx,184fh
mov bh,01h
mov al,00h
mov ah,06h
int 10h
ret
clrscr endp
curset proc
push ax
push bx
push dx
mov bh,00h
mov bh,02h
mov dl,38
mov dh,12
int 10h
pop dx
pop bx
pop ax
ret
curset endp
display proc mov al,bl
mov cl,04h
shr al,cl
cmp al,09h
jb t1
add al,07h
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 9/35
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
t1:add al,30h
mov dl,al
mov ah,02h
int 21h
mov al,bl
and al,0fh cmp al,09h
jb t2
add al,07h
t2:add al,30h
mov dl,al
mov ah,02h
int 21h
ret
display endp
code ends
end start
DISPLAY MESSAGES FIRE AND HELP ALTERNATELY WITH FLICKERINGEFFECTS ON A 7-SEGMENT DISPLAY INTERFACE FOR A SUITABLE PERIODOF TIME.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
data segment
portb equ 281h
portc equ 282h
cwr equ 283h num1 db 086h,0ceh,0f9h,8eh
num2 db 8ch,0c7h,86h,89h
n dw 04h
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov al,80h
mov dx,cwr
out dx,al
ne: lea si,num1
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 10/35
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
call display
call delay
lea si,num2
call display
call delay
dec n
jnz ne
mov ah,4ch
int 21h
display proc
mov di,0004
again: mov al,[si]
mov bh,08h
next: rol al,01h
mov bl,al
mov dx,portb
out dx,al
mov al,00h
mov dx,portc
out dx,al
mov al,0ffh
mov dx,portc
out dx,al
mov al,bl dec bh
jnz next
inc si
dec di
jnz again
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 11/35
67
68
69
70
71
72
73
74
75
76
77
78
79
80
ret
display endp
delay proc
mov si,0ffffh
t2: mov di,134h
t1: dec di jnz t1
dec si
jnz t2
ret
delay endp
code ends
end start
PGM TO REVERSE A GIVEN STRING A CHECK WHEATHER IT IS APALINDROME OR NOT
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
stack segment
dw 64 dup(0)
stack ends
data segment
str1 db "abcd"
str2 db 4 dup(0)
len dw 0004h
res dw ?
data ends
code segment
assume cs:code,ss:stack,ds:data
start:mov ax,data
mov ds,ax
lea si,str1
lea di,str2
add di,len
dec di
mov cx,len
again:mov al,[si]
mov [di],al
inc si
dec di
dec cx
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 12/35
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
jnz again
lea si,str1
mov di,si
add di,len
dec di mov cx,len
shr cx,1
repeat:mov al,[si]
cmp al,[di]
jne no
inc si
dec di
dec cx
jnz repeat
mov res,1111h
jmp stop
no:mov res,0000h
stop:int 3h
code ends
end start
ASSUME ANY SUITABLE MESSAGE OF 12 CHARACTERS LENGHT AND
DISPLAY IT IN THE ROLLING FASHION ON A 7-SEGMENT DISPLAYINTERFACE.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
data segment
portb equ 281h
portc equ 282h
cwr equ 283h
num db 0ffh,0ffh,0ffh,0ffh,8ch,0c7h,86h,89h,0f9h,0c0h,0f9h,0c0h
n dw 04
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov al,80h
mov dx,cwr
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 13/35
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
out dx,al
again1: lea si,num
call display dec n
jnz again1
mov ah,4ch
int 21h
display proc
mov di,0012
again: mov al,[si]
mov bh,08h
next: rol al,01h
mov bl,al
mov dx,portb
out dx,al
mov al,00h
mov dx,portc
out dx,al
mov al,0ffh
mov dx,portc
out dx,al
mov al,bl
dec bh
jnz next
call delay
inc si
dec di
jnz again
ret
display endp
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 14/35
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
delay proc
push si
push di
mov si,0ffffh
t2: mov di,123h
t1: dec di
jnz t1
dec si
jnz t2
pop di
pop si
ret
delay endp
code ends
end start
PGM TO READ TWO STRINGS,STORED THEM IN LOCATIONSTR1,STR2.DISPLAY THEIR LENGHTS AND CHECK THEY ARE EQUAL ORNOT
? 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
stack segment
dw 64 dup(0)
stack ends
data segment
dms1 db 'enter the string1:$'
msg1 db 20
len1 db 00
str1 db 20 dup(0)
dms2 db 'enter the string2:$'
msg2 db 20
len2 db 00
str2 db 20 dup(0)
dis1 db 'strings are equal $'
dis2 db 'strings are not equal $'
dsl1 db 'length1:$'
dsl2 db 'length2:$'
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 15/35
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
nexl db 0ah,0dh,'$'
data ends
code segment
assume cs:code,ds:data,ss:stack
start:mov ax,data mov ds,ax
lea dx,dms1
mov ah,09h
int 21h
lea dx,msg1
mov ah,0ah
int 21h
lea dx,nexl
mov ah,09h
int 21h
lea dx,dms2
mov ah,09h
int 21h
lea dx,msg2
mov ah,0ah
int 21h
lea dx,nexl
mov ah,09h
int 21h
lea dx,dsl1
mov ah,09h
int 21h
mov al,len1
call display
lea dx,dsl2
mov ah,09h
int 21h
mov al,len2
call display mov al,len1
cmp al,len2
jne exit
lea si,str1
lea di,str2
mov cl,len1
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 16/35
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
again:mov al,[si]
cmp al,[di]
jne exit
inc si
inc di
dec cl jnz again
lea dx,dis1
mov ah,09h
int 21h
jmp stop
exit:lea dx,dis2
mov ah,09h
int 21h
stop:mov ah,4ch
int 21h
display proc
aam
mov cx,ax
mov dx,cx
add dh,30h
mov dl,dh
mov ah,02h
int 21h
mov dx,cx
add dl,30h
mov ah,02h
int 21h
ret
display endp
code ends
end start
READ YOUR NAME FROM THE KEYBOARD AND DISPLAY IT AT A SPECIFIED
LOCATION ON SCREEN
?
1
2
3
4
5
data segment
msg1 db 20
len1 db 00
str1 db 20 dup('$')
str2 db 0ah,0dh,'$'
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 17/35
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
msg2 db 'what is your name?$'
data ends
code segment
assume cs:code,ds:data
start: mov ax,data mov ds,ax
lea dx,msg1
mov ah,0ah
int 21h
call clrscr
call curset
lea dx,msg2
mov ah,09h
int 21h
lea dx,str1
mov ah,09h
int 21h
mov ah,01h
int 21h
mov ah,4ch
int 21h
clrscr proc
mov cx,0000
mov dx,184fh
mov al,00
mov bh,01
mov ah,06h
int 10h ret
clrscr endp
curset proc
mov ah,02h
mov bh,00h
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 18/35
51
52
53
54
55
56
57
58
mov dh,10h
mov dl,10h
int 10h
ret
curset endp
code ends
end start
A STEPPER MOTOR INTERFACE TO ROTATE THE MOTOR IN CLOCKWISEDIRECTION BY N STEPS.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
data segment
portc equ 282h
cwr equ 283h
n equ 10
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov al,80h
mov dx,cwr
out dx,al
mov dx,portc mov al,77h
mov cx,n
again: out dx,al
call delay
ror al,1
dec cx
jnz again
int 3h
delay proc
mov si,0ffffh
t2: mov di,123h
t1: dec di
jnz t1
dec si
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 19/35
34
35
36
37
38
39
jnz t2
ret
delay endp
code ends
end start PGM TO COMPUTE THE FACTORIAL OF A POSITIVE INTEGER N USINGRECURSIVE PROCEDURE
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
stack segment
dw 64 dup(0)
stack ends
data segment
n dw 0004
res dw 1 dup(0)
data ends
code segment
assume cs:code,ds:data,ss:stack
start:mov ax,data
mov ds,ax
mov bx,n
call fact
mov res,ax
int 3h
fact proc
cmp bx,0000
je exit
push bx
dec bx
call fact
pop bx
mul bx
ret
exit:mov ax,0001
ret
fact endp
code ends
end start
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 20/35
DRIVE A STEPPER MOTOR INTERFACE TO ROTATE THE MOTOR INANTICLOCKWISE DIRECTION BY N STEPS.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
data segment
portc equ 282h
cwr equ 283h
n equ 10
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov al,80h
mov dx,cwr
out dx,al
mov dx,portc
mov al,77h
mov cx,n
again: out dx,al
call delay
rol al,1
dec cx
jnz again
int 3h
delay proc
mov si,0ffffh
t2: mov di,123h
t1: dec di
jnz t1
dec si
jnz t2
ret
delay endp
code ends end start
;PROGRAMME TO COMPUTE NCR USING RECURSIVE PROCEDURE
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 21/35
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
stack segment
dw 64 dup(0)
stack ends
data segment
n dw 0007 r dw 0004
ncr dw ?
data ends
code segment
assume cs:code,ds:data,ss:stack
start:
mov ax,data
mov ds,ax
mov ax,n
mov bx,r
call ncrp
int 3h
ncrp proc
cmp ax,bx
je t1
cmp bx,0000
je t1
cmp bx,0001
je t2
dec ax
cmp ax,bx
je t3
push ax
push bx
call ncrp
pop bx
pop ax
dec bx
push ax
push bx call ncrp
pop bx
pop ax
ret
t1:add ncr,0001
ret
t3:add ncr,0001
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 22/35
87
88
89
90
91
92
t2:add ncr,ax
ret
ncrp endp
code ends
end start DRIVE A STEPPER MOTOR INTERFACE TO ROTATE THE MOTOR INCLOCKWISE AND ANTICLOCKWISE DIRECTION BY N STEPS.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
data segment
portc equ 282h
cwr equ 283h
n equ 10
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov al,80h
mov dx,cwr
out dx,al
mov dx,portc
mov al,77h
mov cx,n
again: out dx,al
call delay
ror al,1
dec cx
jnz again
mov cx,n
again1: out dx,al
call delay
rol al,1
dec cx
jnz again1
int 3h
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 23/35
36
37
38
39
40
41
42
43
44
45
46
47
delay proc
mov si,0ffffh
t2: mov di,123h
t1: dec di
jnz t1
dec si jnz t2
ret
delay endp
code ends
end start
SCAN A 8*3 KEYPAD FOR KEY CLOSURE AND STORE THE CODE OF THEKEY PRESSED ;IN A MEMORY LOCATION OR DISPLAY ON SCREEN.ALSODISPLAY ROW AND COLUMN ;NUMBERS POF TH
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
data segment
cwr equ 283h
porta equ 280h
portc equ 282h
cod db ?
rowcol db ?
table db
00h,01h,02h,03h,04h,05h,06h,07h,10h,11h,12h,13h,14h,15h,16h,17h,
db 20h,21h,22h,23h,24h,25h,26h,27h
data ends
code segment
assume ds:data,cs:code
start: mov ax,data
mov ds,ax
mov al,90h
mov dx,cwr
out dx,al
again: mov ch,00h
mov al,01h
mov dx,portc
out dx,al
call scan
cmp al,00h
jne exit
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 24/35
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
mov ch,08h
mov al,02h
mov dx,portc
out dx,al
call scan
cmp al,00h jne exit
mov ch,10h
mov al,04h
mov dx,portc
out dx,al
call scan
cmp al,00
jne exit
jmp again
exit: mov cod,ch
mov al,ch
lea bx,table
xlat
mov rowcol,al
int 3h
scan proc
mov dx,porta
in al,dx
mov bh,08h
repeat: ror al,1
jc yes
inc ch
dec bh
jnz repeat
yes: ret
scan endp
code ends
end start
PGM TO FIND OUT WHETHER A GIVEN SUB-STRING IS PRESENT OR NOT INS MAIN STRING OF CHARACTERS
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 25/35
?
1
2
3
4
56
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
stack segment
dw 64 dup(0)
stack ends
data segment char db 'yz'
result dw ?
l1 dw 0004
data ends
extra segment
string db 'xyzp'
extra ends
code segment
assume cs:code,ds:data,ss:stack,es:extra
start:mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
lea di,string
mov cx,l1
mov al,char
dec cx
repeat:scasw
je yes
inc di
dec cx
jnz repeat
mov result,0000h
jmp stop
yes:mov result,1111h
stop:int 3h
code ends end start
PGM TO GENERATE THE FIRST N FIBONACCI NUMBERS
?
1
2
3
stack segment
dw 64 dup(0)
stack ends
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 26/35
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
data segment
fib dw 50 dup(0)
n dw 0010
data ends
code segment
assume cs:code,ds:data,ss:stack
start:mov ax,data
mov ds,ax
lea si,fib
mov cx,n
mov ax,0000h
mov bx,0001h
mov[si],ax
add si,2
mov [si],bx
add si,2
sub cx,2
again:cmp cx,0000
je exit
mov bx,[si-4]
add bx,[si-2]
mov [si],bx
add si,2
dec cx
jnz again
exit:int 3h
code ends
end start
stack segment
dw 64 dup(0)
stack ends
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 27/35
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
data segment
fib dw 50 dup(0)
n dw 0010
data ends
code segment assume cs:code,ds:data,ss:stack
start:mov ax,data
mov ds,ax
lea si,fib
mov cx,n
mov ax,0000h
mov bx,0001h
mov[si],ax
add si,2
mov [si],bx
add si,2
sub cx,2
again:cmp cx,0000
je exit
mov bx,[si-4]
add bx,[si-2]
mov [si],bx
add si,2
dec cx
jnz again
exit:int 3h code ends
end start
SCAN A 8*3 KEYPAD FOR KEY CLOSURE AND SIMULATE ADD ANDSUBTRACT ;OPERATIONS AS IN A CALCULATOR.
?
1 data segment
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 28/35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
cwr equ 283h
porta equ 280h
portc equ 282h
sum db 0
key db 20 dup(0)
data ends
code segment
assume ds:data,cs:code
start: mov ax,data
mov ds,ax
mov al,90h
mov dx,cwr
out dx,al
lea si,key
again: cmp ch,0ah
je calc
mov ch,00h
mov al,01h
mov dx,portc
out dx,al
call scan
cmp al,00h
jne exit
mov ch,08h
mov al,02h
mov dx,portc
out dx,al
call scan
cmp al,00h
jne exit
mov ch,10h
mov al,04h mov dx,portc
out dx,al
call scan
cmp al,00
jne exit
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 29/35
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
jmp again
exit: cmp ch,[si-1]
je t3
mov [si],ch inc si
t3: jmp again
calc: mov [si],ch
lea si,key
mov bl,00h
add bl,[si]
inc si
next: mov al,[si]
cmp al,0ah
je stop
cmp al,0bh
je addition
inc si
sub bl,[si]
inc si
jmp next
addition:inc si
add bl,[si]
inc si
jmp next
stop: mov sum,bl
int 3h
scan proc
mov dx,porta in al,dx
mov bh,08h
repeat:ror al,1
jc yes
inc ch
dec bh
jnz repeat
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 30/35
92
93
94
95
96
97
98
yes:ret
scan endp
code ends end start
PGM TO READ A CURRENT TIME FROM THE SYSTEM
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
stack segment
dw 64 dup(0)
stack ends
code segment
assume ss:stack,cs:code
start:mov ah,2ch
int 21h
push cx
mov al,ch
call display
mov dl,':'
mov ah,02h
int 21h
pop cx
mov al,cl
call display
mov ah,4ch int 21h
display proc
aam
mov cx,ax
mov dx,cx
add dh,30h
mov dl,dh
mov ah,02h
int 21h
mov dx,cx
add dl,30h
mov ah,02h
int 21h
ret
display endp
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 31/35
36
37
38
code ends
end start
PGM TO STIMULATE A DECIMAL UP-COUNTER TO DISPLAY 00-99
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
stack segment
dw 64 dup(0)
stack ends
data segment
x db 00
count db 100
data ends
code segment
assume cs:code,ds:data,ss:stack
start:mov ax,data
mov ds,ax
again:mov ch,x
call curset
mov al,ch
call display
call delay
inc x
dec count
jnz again
mov ah,4ch
int 21h
display proc
aam
mov cx,ax
mov dx,cx
add dh,30h
mov dl,dh
mov ah,02h
int 21h
mov dx,cx
add dl,30h
mov ah,02h
int 21h
ret
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 32/35
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
display endp
delay proc
mov si,0100h
t1:mov di,0ffffh t2:dec di
jnz t2
dec si
jnz t1
ret
delay endp
curset proc
mov ah,02h
mov bh,00h
mov dh,15h
mov dl,20h
int 10h
ret
curset endp
code ends
end start
PGM TO CREATE A FILE(INPUT FILE)AND TO DELETE AN EXISTING FILE?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
data segment
ftbc db 'ac.asm',0
ftbd db 'eg.asm',0
data ends
code segment
assume cs:code,ds:data,ss:stack
start:mov ax,data
mov ds,ax
mov cx,0020h
lea dx,ftbc
mov ah,3ch
int 21h
lea dx,ftbd
mov ah,41h
int 21h
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 33/35
17
18
19
int 3h
code ends
end start
DRIVE AN ELEVATOR INTERFACE IN THE WAY TO MOVE AN ELEVATORFROM GROUND ;TO TOP FLOOR AND TOP TO GROUND FLOOR.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
data segment
pa equ 280h
cwr equ 283h
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov al,80h
mov dx,cwr
out dx,al
mov bl,00
top: mov al,bl
mov dx,pa
out dx,al
call delay
inc bl
cmp bl,0ah
jb top
top1: dec bl mov al,bl
out dx,al
call delay
cmp bl,00h
jne top1
int 3h
delay proc
push bx
mov cx,0ffffh
loop1: mov bx,123h
t1: dec bx
jnz t1
loop loop1
pop bx
ret
delay endp
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 34/35
39
40
41
42
exit: mov ah,4ch
int 21h
code ends end start
PGM TO READ A PAIR OF I/P CO-ORDINATES IN BCD
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
stack segment
dw 64 dup(0)
stack ends
data segment
row db ?
col db ?
data ends
code segment
assume cs:code,ds:data,ss:stack
start:mov ax,data
mov ds,ax
call readdigit
mov row,bl
call readdigit
mov col,bl
call clearscreen
mov dl,row
mov dh,col
call curset
mov ah,01h
int 21h
mov ah,4ch
int 21h
readdigit proc
mov ah,01h
int 21h
mov cl,04h
8/6/2019 Vtu Microprocessor Lab Programs
http://slidepdf.com/reader/full/vtu-microprocessor-lab-programs 35/35
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
shl al,cl
mov bl,al
mov ah,01h
int 21h
sub al,30h
add bl,al ret
readdigit endp
clearscreen proc
mov cx,0000
mov dx,184fh
mov al,00
mov bh,01
mov ah,06h
int 10h
ret
clearscreen endp
curset proc
mov ah,02h
mov bh,0h
int 10h
ret
curset endp
code ends
end start