0% found this document useful (0 votes)
6 views15 pages

MIC Programs

The document contains multiple assembly language programs written for the 8086 microprocessor, including programs to find the 2's complement of a number, add and subtract BCD numbers, sum a series of numbers, find the smallest and largest numbers in an array, sort an array, transfer a block of numbers, and separate positive and negative numbers from an array. Each program is structured with a model definition, data segment, and code segment, followed by appropriate assembly instructions. The programs utilize various instructions such as MOV, ADD, CMP, and LOOP to perform their respective tasks.

Uploaded by

Dipak Dumbe
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)
6 views15 pages

MIC Programs

The document contains multiple assembly language programs written for the 8086 microprocessor, including programs to find the 2's complement of a number, add and subtract BCD numbers, sum a series of numbers, find the smallest and largest numbers in an array, sort an array, transfer a block of numbers, and separate positive and negative numbers from an array. Each program is structured with a model definition, data segment, and code segment, followed by appropriate assembly instructions. The programs utilize various instructions such as MOV, ADD, CMP, and LOOP to perform their respective tasks.

Uploaded by

Dipak Dumbe
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/ 15

Q.

3 program in 8086 to to find 2's complement of a number stored


in 0100H Location using NEG instruction

.model small
.data
.code
mov ax, @data
mov ds, ax

mov al, [0100H]


neg al
mov [0100H], al
mov ah, 4Ch
int 21H
end
Q.4 Program to add two BCD numbers
Q.5 Program to subtract two BCD numbers
Q.7 Program in 8086 to sum of a series of 10 numbers stored from
memory location 4000H and store result to next location

.model small
.data
.code
mov ax, @data
mov ds, ax
mov si, 4000H
mov cx, 10
mov ax, 0
sum_loop:
add ax, [si]
inc si
loop sum_loop

mov [400Ah], ax
mov ah, 4Ch
int 21H
end
Q.8 Program in 8086 to to find smallest number in an array of 10
numbers stored from memory location 0101h
OR
Q. 12 program in 8086 to to find smallest number in an array of 10
numbers stored from memory location 1000 h

.model small
.data
.code
mov ax, @data
mov ds, ax
mov si, 0101H ; OR 1000H
mov cx, 10
mov ax, [si]
inc si
dec cx

find_smallest:
cmp ax, [si]
jle next_num ; If AX <= [SI], go to next number
mov ax, [si]
next_num:
inc si
loop find_smallest

mov [0115H], ax
mov ah, 4Ch ; Exit program
int 21H
end
Q. 13 program in 8086 to to find Largest number in an array of 10
numbers stored from memory location 1000 h

.model small
.data
.code
mov ax, @data
mov ds, ax
mov si, 1000H
mov cx, 10
mov ax, [si]
inc si
dec cx
find_largest:
cmp ax, [si]
memory [SI]
jge next_num ; If AX >= [SI], go to next number
mov ax, [si]
next_num:
inc si
loop find_largest
mov [1010H], ax
mov ah, 4Ch ; Exit program
int 21H
end
Q.9 program in 8086 to to sort number in an array of 5 numbers in
ascending order which is stored from 2000H memory location

.model small
.data
.code
mov ax, @data
mov ds, ax
mov si, 2000H
mov cx, 5
mov bx, cx
outer_loop:
dec bx
mov si, 2000H
mov di, si
mov dx, bx
inner_loop:
mov ax, [si]
cmp ax, [di]
jbe no_swap ; If AX <= [DI], no need to swap
xchg ax, [di]
mov [si], ax
no_swap:
inc si
inc di
loop inner_loop

mov cx, bx
loop outer_loop

mov ah, 4Ch


int 21H
end
Q. 11 WAP in 8086 to transfer a block of 10 numbers from memory
location 0201H to 0401H.model small
.data
.code
mov ax, @data
mov ds, ax
mov si, 0201H
mov di, 0401H
mov cx, 10
copy_loop:
mov al, [si]
mov [di], al

inc si
inc di
loop copy_loop

mov ah, 4Ch


int 21H
end
Q.14 Count no of Zeros in 16 bit number
Q.10 Separate Positive and Negative numbers from an array

.model small
.stack 100h
.data
array db 2, -3, 5, -8, 7, -1, 4, -2
size db $ - array ; Size of the array

; Arrays to store positive and negative numbers


pos_array db 8 dup(0) ; Array to store positive numbers
neg_array db 8 dup(0) ; Array to store negative numbers
pos_count db 0 ; Counter for positive numbers
neg_count db 0 ; Counter for negative numbers

.code
start:
; Initialize data segment
mov ax, @data
mov ds, ax

; Initialize pointers to the arrays


lea si, array ; SI points to the original array
lea di, pos_array ; DI points to the positive array
lea bx, neg_array ; BX points to the negative array
mov cl, size ; Load the size of the array into CL

separate_numbers:
mov al, [si] ; Load the current array element into AL
cmp al, 0 ; Compare with 0
jge store_positive ; If AL >= 0, jump to store positive number

store_negative:
mov [bx], al ; Store the negative number in the negative array
inc bx ; Move the pointer to the next negative position
inc neg_count ; Increment negative count
jmp next_element

store_positive:
mov [di], al ; Store the positive number in the positive array
inc di ; Move the pointer to the next positive position
inc pos_count ; Increment positive count
next_element:
inc si ; Move to the next element in the array
loop separate_numbers ; Repeat until the whole array is processed

; Terminate the program


mov ah, 4ch
int 21h

end start

You might also like