You are on page 1of 41

NAME-ANUKRITI SRIVASTAVA

ID-BTBTC19287
ROLL-1912928
B.TECH 6 SEMESTER
COMPUTER SCIENCE(SEC-A)

ELE 306L MICROPROCESSOR


AND MICROCONTROLLER (LAB
RECORD)

1
INDEX

S.No Programs

1 Write an ALP to copy the 8/16-bit data from one location to another
location, both locations should be in different memory segment.
2 Write an ALP to exchange the 8/16-bit data from one location to
another location, both locations should be in different memory
segment.

3 Write an ALP to perform 8/16-bit addition and store the result in


consecutive location of data-segment.
4 Write an ALP to perform 32-bit addition and store the result in
consecutive location of data-segment.
5 Write an ALP to perform 8/16-bit subtraction and store the result in
consecutive location of data-segment.
6 Write an ALP to perform 32-bit subtraction and store the result in
consecutive location of data-segment.
7 Write an ALP to perform 8/16-bit addition and store the result in
consecutive location of extra-segment.
8 Write an ALP to perform 32-bit addition and store the result in
consecutive location of extra-segment.
9 Write an ALP to perform 8/16-bit subtraction and store the result in
consecutive location of extra-segment.
10 Write an ALP to perform 32-bit subtraction and store the result in
consecutive location of extra-segment.
11 Write an ALP to move the each 8/16-bit data byte of the given array
in the AL register repetitively.
12 Write an ALP to move the each 16-bit data byte of the given array
in the AX register repetitively.
13 Write an ALP to move the 8-bit data block of an array into another
location of memory block.
14 Write an ALP to move the 16-bit data block given in array into
another location of memory block.

2
15 Write an ALP to reverse the string of your FULL NAME which is
stored in the given memory location.
16 Write an ALP to print the string of your FULL NAME available at
memory.
17 Write an ALP to implement PUSH and POP operation in 8086.
18 Write an ALP to implement Unsigned and Signed multiplication of
8/16 bit operands.
19 Write an ALP to implement unsigned and signed division of 8/16 bit
operands.

20 Write an ALP to calculate factorial of a number stored at given memory location.


21 Write an ALP to find the sum of numbers in the given array of byte type.
22 Write an ALP to find the sum of numbers in the given array of word type.
23 Write an ALP to find EVEN and ODD numbers in the given array of byte type and
displayit on the screen.
24 Write an ALP to find EVEN and ODD numbers in the given array of wordtype and
displayit on the screen.
25 Write an ALP to find the minimum number in the given array of byte type.
26 Write an ALP to find the minimum number in the given array of word type.
27 Write an ALP to find the maximum number in the given array of byte type.
28 Write an ALP to find the maximum number in the given array of word type.
29 Write an ALP to find POSITIVE and NEGETIVE numbers in the given array of byte
typeand display it on the screen.
30 Write an ALP to find POSITIVE and NEGETIVE numbers in the given array of word
typeand display it on the screen.
31 Write an ALP to sort an array of byte type in ascending order using Bubble Sort.
32 Write an ALP to sort an array of word type in ascending order using Bubble Sort.
33 Write an ALP to sort an array of byte type in descending order using Bubble Sort.
34 Write an ALP to sort an array of word type in descending order using Bubble Sort.
35 Write an ALP to generate Fibonacci series of byte type and store it at
consecutivememory locations.
36 Write an ALP to generate Fibonacci series of word type and store it at
consecutivememory locations.
37 Write an ALP to calculate square of each numbers stored in the array of byte type.
38 Write an ALP to calculate square of each numbers stored in the array of word type.
39 Write an ALP to search a number (byte type) from the given array of byte type.
40 Write an ALP to search a number (byte type) from the given array of word type.
41 Write an ALP to find ODD-EVEN number using MACRO.
42 Write an ALP to find POSITIVE-NEGETIVE number using MACRO.
43 Write an ALP to print Z-character on screen using MOV instruction

Program 1:

Write an ALP to copy the 8/16-bit data from one location to another location, both locations should
be in different memory segment.

3
data segment
; add your data here!
; pkeydb "press any key...$"
ends
stack segment
;dw 128 dup(0)
ends

code segment
start:
; set segment registers:
mov ax,1234h
mov ss,ax
mov ax,2134h
mov es,ax
ss:mov [1000h],6234h
ss:movax,[1000h]
es:mov [2000h],ax
ends
end start ; set entry point and stop the assembler.

Program 2:

Write an ALP to exchange the 8/16-bit data from one location toanother location, both locations
should be in different memory segment.

data segment
; add your data here!
; pkeydb "press any key...$"
ends

stack segment

4
;dw 128 dup(0)
ends

code segment
start:
; set segment registers:
mov ax,1234h
mov ss,ax
mov ax,2134h
mov es,ax
ss:mov [1000h],1001h
ss:movax,[1000h]
es:mov [2000h],1004h
es:movbx,[2000h]
ss:mov [1000h],bx
es:mov [2000h],ax
ends
end start ; set entry point and stop the assembler.

Program 3:

Write an ALP to perform 8/16-bit addition and store the result in consecutive location of data-
segment.

code segment
start:

mov ax, 1234h


mov ds, ax
mov bx, 1021h
mov cx,2042h
add bx,cx

5
mov [1001h], bx
ends
end start

Program 4:

Write an ALP to perform 32-bit addition and store the result in consecutive location of data-
segment.

code segment
start:
mov ax, 1111h ;first word: 11111111h
mov bx, 1111h
mov cx, 2222h ;second word: 22222222h
mov dx, 2222h
add bx,dx
add ax,cx
mov [1011h],ax
mov [1013h],bx
ends
end start

Program 5:

Write an ALP to perform 8/16-bit subtraction and store the result in consecutive location of data-
segment.

code segment
start:

mov ax, 1234h


mov ds, ax
mov bx, 2042h
mov cx,1021h

6
sub bx,cx
mov [1001h], bx

ends

end start

Program 6:

Write an ALP to perform 32-bit subtraction and store the result in consecutive location of data-
segment.

code segment
start:

mov ax, 3434h ;first word: 34343434h


mov bx, 3434h
mov cx, 1010h ;second word: 10101010h
mov dx, 1010h
sub bx,dx
sub ax,cx
mov [1011h],ax
mov [1013h],bx
ends
end start

Program 7:

Write an ALP to perform 8/16-bit addition and store the result in consecutive location of extra-
segment.

7
code segment
start:
mov ax, 1234h
mov es, ax
mov bx, 1021h
mov cx,2042h
add bx,cx
es:mov [1001h], bx
ends
end start

Program 8:

Write an ALP to perform 32-bit addition and store the result in consecutive location of extra-
segment.

code segment
start:
mov ax, 1234h
mov es, ax
mov ax, 1111h ;first word: 11111111h
mov bx, 1111h
mov cx, 2222h ;second word: 22222222h
mov dx, 2222h
add bx,dx
add ax,cx
es:mov [1011h],ax
es:mov [1013h],bx
ends
end start

8
Program 9:

Write an ALP to perform 8/16-bit subtraction and store the result in consecutive location of extra-
segment.

code segment
start:

mov ax, 1234h


mov es, ax
mov bx, 2042h
mov cx,1021h
sub bx,cx
es:mov [1001h], bx
ends
end start

Program 10:

Write an ALP to perform 32-bit subtraction and store the result in consecutive location of extra-
segment.

code segment
start:

mov ax, 1234h


mov es, ax
mov ax, 3434h ;first word: 34343434h
mov bx, 3434h
mov cx, 2222h ;second word: 22222222h
mov dx, 2222h
sub bx,dx
sub ax,cx

9
es:mov [1011h],ax
es:mov [1013h],bx
ends
end start

Program 11:

Write an ALP to move the each 8/16-bit data byte of the given array in the AL register repetitively.

data segment
list db 12h, 87h, 0ACh, 45h, 81h
ends
code segment
start:
mov ax, data
mov ds, ax
mov es, ax
mov ah, 67h
lea si, list
mov cx,5

rep lodsb
ends
end start

Program 12:

Write an ALP to move the each 16-bit data byte of the given array in the AX register repetitively.

data segment
list dw1234h, 5634h, 8945h, 7890h, 0ABCh
ends

10
code segment
start:
mov ax, data
mov ds, ax
mov es, ax
lea si, list
mov cx,5
rep lodsw
ends
end start

Program 13:

Write an ALP to move the 8-bit data block of an array into another location of memory block.

data segment
a1 db 12h, 56h, 89h, 78h, 0Ch
ends
extra segment
a2 db 5 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov ax, extra
mov es, ax
mov cx,5

11
lea si, a1
lea di, a2
m:movsb
loop m
ends
end start
Program 14:

Write an ALP to move the 16-bit data block given in array into another location of memory block.

data segment
a1 dw 1234h, 5634h, 8945h, 7890h, 0ABCh
ends
extra segment
a2 dw 5 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov ax, extra
mov es, ax
mov cx,5
lea si, a1
lea di, a2
m:movsw
loop m
ends
end start

12
Program 15:

Write an ALP to reverse the string of your FULL NAME which is stored in the given memory location.

data segment
a1 db 'A','N','U','K','R','I','T',’I’,'S','R','I','V','A','S','T','A','V','A'
ends
extra segment
a2 db 18dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov ax, extra
mov es, ax
mov cx, 18
lea si, a1
lea di, a2+17
mov ah, 0Eh
m:movsb
mov al,[di-1]
dec di
dec di
int 10h
loop m
hlt
ends
end start

13
Program 16:

Write an ALP to print the string of your FULL NAME available at memory.

data segment
a1 db‘A','N','U','K','R','I','T',’I’,'S','R','I','V','A','S','T','A','V','A'
ends
extra segment
a2 db 18dup(0)
ends
code segment
start:
mov ax, data
mov ds, ax
mov ax, extra
mov es, ax
mov cx, 18
lea si, a1
lea di, a2
mov ah, 0Eh
m:movsb
mov al,[di-1]
int 10h
loop m
hlt

ends

end start

14
Program 17:

Write an ALP to implement PUSH and POP operation in 8086.

; multi-segment executable file template.

stack segment

ends

code segment
start:
; set segment registers:
mov ax, stack
mov ss, ax
mov ax, 1234h
mov sp, 1234h
mov bx, 2236h
mov cx, 1111h
push ax
push bx
push cx
pop cx
ends
end start

Program 18:

Write an ALP to implement Unsigned and Signed multiplication of 8/16 bit operands.

15
data segment

ends

code segment

start:

mov ax, data

mov ds, ax

; for unsigned we use mul instruction

mov ax, -4

mov bx, 3

mulbx

;for signed we use imul instruction

mov ax, -4

mov bx, 3

imulbx

ends

end start

Program 19:

Write an ALP to implement unsigned and signed division of 8/16 bit operands.

data segment
ends
code segment
start:

mov ax, data


mov ds, ax
; for unsigned we use div instruction
mov ax, 100
mov bl, 5
div bl

16
; for signed we use idiv instruction
mov ax, -100
mov bl, 5
idiv bl
ends
end start
Program 20

Write an ALP to calculate factorial of a number stored at given memory location.

data segment

fact dw 0008h

res dd dup(0)

ends

code segment

start:

; set segment registers:

mov ax, data

mov ds, ax

mov es, ax

lea si, fact

lea di ,res

mov cx,07h

mov ax,[si]

l:

mul cx

loop l

mov [di],ax

mov [di+2],dx

ends

end start

17
Program 21

Write an ALP to find the sum of numbers in the given array of byte type.

data segment

arrdb 1,2,3,4,5

ends

stack segment

dw128 dup(0)

ends

code segment

start:

; set segment registers:

mov ax, data

mov ds, ax

mov es, ax

mov ax,0

; add your code here

lea si,arr

mov cx,5

sum:

add ax,[si]

incsi

loop sum

ends

end start

Program 22

Write an ALP to find the sum of numbers in the given array of word type.

arrdw 100,200,300,400

ends

18
stack segment

dw128 dup(0)

ends

code segment

start:

; set segment registers:

mov ax, data

mov ds, ax

mov es, ax

mov ax,0

; add your code here

lea si,arr

mov cx,4

sum:

add ax,[si]

incsi

incsi

loop sum

ends

end start

Program 23

Write an ALP to find EVEN and ODD numbers in the given array of byte type and displayit on the
screen.

data segment

arrdb 83h ,45h ,01h ,24h ,62h

ends

code segment

start:

19
; set segment registers:

mov ax, data

mov ds, ax

lea si,arr

mov cx,5

here:

lodsb

rcr al,1

jc label

mov ah, 0eh

mov al,'E'

int 10h

loop here

label:

mov ah,0eh

mov al,'o'

int 10h

loop here

hlt

ends

end start

Program 24

Write an ALP to find EVEN and ODD numbers in the given array of word type and displayit on the
screen.

data segment
arrdw 1010h,3288h,1004h,9876h,0014h
ends

code segment
start:

20
; set segment registers:
mov ax, data
mov ds, ax
lea si,arr
mov cx,5
here:
lodsw
rcr al,1
jc label
mov ah, 0eh
mov al,'E'
int 10h
loop here
label:
mov ah,0eh
mov al,'o'
int 10h
loop here
hlt
ends

end start
Program 25

Write an ALP to find the minimum number in the given array of byte type.

sdata segment
n1 db 83h ,45h ,01h ,24h ,62h ,97h
res dbdup(0)
ends

21
extra segment
ends

code segment
start:
mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
lea si,n1
lea di,res
mov cx,05
mov al,[si]
m:
mov bl,[si+1]
cmpal,bl
jc next
mov al,bl
next:
incsi
loop m
mov [si+1],al

ends
end start
Program 26

Write an ALP to find the minimum number in the given array of word type.

; multi-segment executable file template.

22
data segment
list dw 1010h,3288h,1004h,9876h,0014h,8834h
ends

extra segment
res dwdup(0)
ends

code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov ax,extra
mov es, ax
mov cx,05h

lea si,list
mov bx,[si]
label:
mov ax,[si+2]
cmpax,bx
jnc next
mov bx,ax
next:
incsi
incsi

23
dec cx
jnz label
lea di,res
es:
mov [di],bx

ends

end start ; set entry point and stop the assembler.

Program 27

Write an ALP to find the maximum number in the given array of byte type.

data segment
; add your data here!
ARR db 55,32,98,21
MAX db ?
ends

stack segment
dw128 dup(0)
ends

code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov bx, 0
mov al, ARR[BX]
mov MAX,al

24
COMPARE:
incbx
cmp bx,4
je EXIT
mov al,ARR[bx]
cmpal,MAX
jg UPDATE
jmp COMPARE

UPDATE:
mov MAX,al
jmp COMPARE
EXIT:

ends

end start

Program 28

Write an ALP to find the maximum number in the given array of byte type.

data segment
list dw 1010h,3288h,1004h,9876h,0014h,8834h
ends

extra segment
res dwdup(0)

25
ends

code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov ax,extra
mov es, ax
mov cx,5

lea si,list
mov bx,[si]
label:
mov ax,[si+2]
cmpax,bx
jc next
mov bx,ax
next:
incsi
incsi
dec cx
jnz label
lea di,res
es:
mov [di],bx

ends

end start

26
Program 29

Write an ALP to find POSITIVE and NEGETIVE numbers in the given array of byte typeand display it
on the screen.

include 'emu8086.inc'

data segment

n1 db 76h,-9h,43h,-65h,11h

ends

code segment

start:

; set segment registers:

mov ax, data

mov ds, ax

mov es, ax

lea si,n1

mov cx,5

m:lodsb

rol al,1

jc l1

print 'Positive'

jmp exit

l1:

print 'Negative'

exit: loop m

hlt

ends

end start

Program 30

Write an ALP to find POSITIVE and NEGETIVE numbers in the given array of word typeand display it
on the screen.

include 'emu8086.inc'

data segment

27
n1 dw -7826h,5439h,4003h,-1265h,1521h

ends

code segment

start:

; set segment registers:

mov ax, data

mov ds, ax

mov es, ax

lea si,n1

mov cx,5

m:lodsw

rol ax,1

jc l1

print 'Positive'

jmp exit

l1:

print 'Negative'

exit: loop m

hlt

ends

end start

Program 31

Write an ALP to sort an array of byte type in ascending order using Bubble Sort.

data segment

arrdb 54h,04h,12h,87h,18h,65h,0ABh

count dw 07h

ends

code segment

28
start:

mov ax, data

mov ds, ax

lea si,count

mov dx,[si]

dec dx

L1:

mov cx,dx

lea si,arr

L2:

mov al,[si]

cmpal,[si+1]

jc next

xchg [si+1],al

xchg [si],al

next:

incsi

loop L2

dec dx

jnz L1

hlt

ends

end start

Program 32

Write an ALP to sort an array of word type in ascending order using Bubble Sort.

data segment

29
arrdw 012FEh,0764h,012CDh,8787h,0018h,1265h,00ABh

count dw 07h

ends

code segment

start:

mov ax, data

mov ds, ax

lea si,count

mov dx,[si]

dec dx

L1:

mov cx,dx

lea si,arr

L2:

mov ax,[si]

cmpax,[si+2]

jc next

xchg [si+2],ax

xchg [si],ax

next:

incsi

incsi

loop L2

dec dx

jnz L1

hlt

30
ends

end start

Program 33

Write an ALP to sort an array of byte type in descending order using Bubble Sort.

data segment

arrdb 54h,04h,12h,87h,18h,65h,0ABh

count dw 07h

ends

code segment

start:

mov ax, data

mov ds, ax

lea si,count

mov dx,[si]

dec dx

L1:

mov cx,dx

lea si,arr

L2:

mov al,[si]

cmpal,[si+1]

jnc next

xchg [si+1],al

xchg [si],al

next:

31
incsi

loop L2

dec dx

jnz L1

hlt

ends

end start

Program 34

Write an ALP to sort an array of word type in descending order using Bubble Sort.

data segment

arrdw 012FEh,0764h,012CDh,8787h,0018h,1265h,00ABh

count dw 07h

ends

code segment

start:

mov ax, data

mov ds, ax

lea si,count

mov dx,[si]

dec dx

L1:

mov cx,dx

lea si,arr

L2:

mov ax,[si]

cmpax,[si+2]

32
jnc next

xchg [si+2],ax

xchg [si],ax

next:

incsi

incsi

loop L2

dec dx

jnz L1

hlt

ends

end start

Program 35

Write an ALP to generate Fibonacci series of byte type and store it at consecutive memory locations.

data segment

n1 db 30 dup(0)

ends

code segment

start:

; set segment registers:

mov ax, data

mov ds, ax

lea si,n1

mov cx,015h

mov [si],00h

33
mov [si+1],01h

m:

mov al,[si]

mov bl,[si+1]

add al,bl

mov [si+2],al

incsi

loop m

hlt

ends

end start

Program 36

Write an ALP to generate Fibonacci series of word type and store it at consecutive memory
locations.

data segment

n1 dw 30 dup(0)

ends

code segment

start:

; set segment registers:

mov ax, data

mov ds, ax

lea si,n1

mov cx,021h

mov [si],0000h

mov [si+2],0001h

m:

mov ax,[si]

mov bx,[si+2]

add ax,bx

34
mov [si+4],ax

incsi

incsi

loop m

hlt

ends

end start

Program 37

Write an ALP to calculate square of each number stored in the array of byte type.

data segment

n1 db 02h,03h,09h,40h,06h,07h

ends

code segment

start:

; set segment registers:

mov ax, data

mov ds, ax

lea si,n1

mov cx,06h

m:

mov al,[si]

mul al

incsi

loop m

hlt

ends

Program 38

Write an ALP to calculate square of each number stored in the array of word type.

include 'emu8086.inc'

data segment

35
n1 dw 2172h,5663h,7329h,4210h,1111h,0011h

res

ends

code segment

start:

; set segment registers:

mov ax, data

mov ds, ax

lea si,n1

mov cx,06h

m:

mov ax,[si]

mulax

incsi

loop m

hlt

ends

end start

Program 39

Write an ALP to search a number (byte type) from the given array of byte type.

data segment

ends

extra segment

n1 db 75h ,0A5h ,21h ,0B7h ,0CCh ,34h

ends

code segment

start:

; set segment registers:

mov ax,extra

36
mov es,ax

mov cx,06h

lea di ,n1

mov al,033h

m:scasb

jz found

loop m

Print 'Number is not Found'

jmp exit

found:

Print 'Number is Found'

exit:hlt

ends

end start

Program 40

Write an ALP to search a number (word type) from the given array of word type.

include 'emu8086.inc'

data segment

ends

extra segment

n1 dw 8007h ,0A569h ,2121h ,6432h ,1145h ,3724h

ends

code segment

start:

; set segment registers:

mov ax,extra

mov es,ax

mov cx,06h

37
lea di ,n1

mov ax,8017h

m:scasw

jz found

loop m

Print 'Number is not Found'

jmp exit

found:

Print 'Number is Found'

exit:hlt

ends

Program 41

Write an ALP to find ODD-EVEN number using MACRO.

display macro msg

mov ax,segmsg

mov ds,ax

mov dx, offset msg

mov ah, 09h

int 21h

endm

data segment

; add your data here!

a1 dw 1357h,9871h,4324h,5000h,5211h

msg1 db 0Ah,0Dh, "Even",0Ah,0Dh, "$"

msg2 db 0Ah,0Dh, "Odd",0Ah,0Dh, "$"

ends

code segment

start:

; set segment registers:

38
mov ax, data

mov ds, ax

lea si, a1

mov cx,5

m: lodsw

ror ax,1

jc l1

display msg1

jmp exit

l1:

display msg2

exit:loop m

hlt

ends

end start

Program 42

Write an ALP to find POSITIVE-NEGATIVE number using MACRO.

display macro msg

mov ax,segmsg

mov ds,ax

mov dx, offset msg

mov ah, 09h

int 21h

endm

data segment

a1 dw -7826h,5439h,4003h,-1265h,1521h

msg1 db 0Ah,0Dh, "Positive",0Ah,0Dh, "$"

msg2 db 0Ah,0Dh, "Negative",0Ah,0Dh, "$"

39
ends

code segment

start:

mov ax, data

mov ds, ax

lea si, a1

mov cx,5

m: lodsw

rol ax,1

jc l1

display msg1

jmp exit

l1:

display msg2

exit:loop m

hlt

ends

end start

Program 43

Write an ALP to print Z-character on screen using MOV instruction


data segment

ends

code segment

start: MOV AX, 0B800h ;

set AX = B800h (VGA memory).

MOV DS, AX ; copy value of AX to DS.

MOV CL, 'Z' ; CL = 41h (ASCII code).

MOV CH, 0111011b ; CL = color attribute.

Blue color MOV BX, 0FEh ; BX = position on screen.

MOV [BX], CX ; w.[0B800h:015Eh] = CX.

40
RET ; returns to operating system.

ends

end start ; set entry point and stop the assemble

41

You might also like