You are on page 1of 24

Microprocessor Architecture and programming 21BECE30308

Practical 8
Aim-Write ALP to copy array numbers from source to destination.

Code:

org 100h
MOV SI,800H
MOV DI,900H
MOV CL,[SI]
INC SI
BACK: MOV BL,[SI]
MOV [DI],BL
INC SI
INC DI
DEC CL
JNZ BACK
Ret

Output:

Input Memory Block of Source Index

Output Memory Block of Destination Index


LDRP-ITR Page No-
Microprocessor Architecture and programming 21BECE30308

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 9
Aim-Write ALP to average of three Numbers (8 bit).

Code:
org 100h
MOV SI,600H
MOV CL,03H
MOV BL,CL
BACK: ADD AL,[SI]
ADC AH,00H
INC SI
DEC CL
JNZ BACK
DIV BL
MOV [700H],AX
Ret
Output:

Input Memory Block

Output Memory Block


LDRP-ITR Page No-
Microprocessor Architecture and programming 21BECE30308

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 10
Aim-Write ALP to Average of N Numbers (8 bit)

Code:
org 100h
MOV SI,700H
MOV CL,[SI]
MOV BL,CL
INC SI
MOV AL,00H
BACK: ADD AL,[SI]
ADC AH,00H
INC SI
DEC CL
JNZ BACK
DIV BL
MOV [900H],AX
Ret

Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 11
Aim-Write ALP to find Largest and Smaller Number from array of data.
Aim-Largest Number
Code:
org 100h
MOV SI,700H
MOV CL,[SI]
MOV CH,00H
INC SI
MOV AL,[SI]
INC SI
BACK: CMP AL,[SI]
JNC L1
MOV AL,[SI]
L1: INC SI
LOOP BACK
MOV [500H],AL
Ret
Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308

Aim-Smallest Number
Code:

org 100h
MOV SI,400H
MOV CL,[SI]
MOV CH,00H
INC SI
MOV AL,[SI]
DEC CL
INC SI
BACK: CMP AL,[SI]
JC L1
MOV AL,[SI]
L1: INC SI
LOOP BACK
MOV [500H],AL
Ret
Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 12

Aim-Write ALP to sort given elements in Ascending Order

Code:
MOV SI,1000h
MOV CL,[SI]
DEC CL
REPEAT:
MOV SI,1000h
MOV CH,[SI]
dec CH
INC SI
REPCOM:
MOV AL, [SI]
INC SI
CMP AL,[SI]
JC AHEAD
XCHG AL,[SI]
XCHG AL,[si-1]
AHEAD:
dec ch
jnz repcom
DEC CL
JNZ REPEAT
HLT

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308

Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 13

Aim-Write ALP to find Factorial of given number

Code:
org 100h
.DATA
ANS DB ?
.CODE
MAIN PROC
mov cx,[800h]
mov ax,0001
mov dx,0000
l1:
mul cx
loop l1
mov [0600h],ax
mov [0601h],dx
mov ANS,al
hlt
END MAIN
ret
LDRP-ITR Page No-
Microprocessor Architecture and programming 21BECE30308

Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 14

Aim-Write ALP to print Fibonacci series (e.g. 10 elements).

Code:
org 100h
.DATA
ANS DB ?
.CODE
MAIN PROC
mov al,00h
mov si,700h
mov [si],al
add si,01h
add al,01h
mov [si],al
mov cx,[900h]
sub cx,0002h
l1:
mov al,[si-1]
add al,[si]
add si,01h
mov [si],al
mov ans,al
loop l1
hlt
END MAIN
ret

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 15

Aim-Write ALP to Search a number from given data array.

Code:
org 100h
mov si, 700h
mov di, 800h
mov dl,[di]
mov bl,01h
mov al,[si]
again:
cmp al,dl
jz avail
inc si
inc bl
mov al,[si]
cmp al,20h
jnz again
nodata:
mov cx,0000h
mov [di+1],cx
mov [di+3],cx
jmp over
avail:
mov bh,0ffh
mov [di+1],bh
mov [di+2],bl
mov [di+3],si
over:
hlt
LDRP-ITR Page No-
Microprocessor Architecture and programming 21BECE30308

Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 16

Aim-Write ALP to Display Array elements on screen.

Code:
include 'emu8086.inc'
org 100h
.model small
.data
arr db 8 dup(?)
.code
main proc
mov ax,@data
mov ds,ax
mov cx,8
mov si,offset arr
print "Enter the elements in array: "
loopIn:
mov ah,1
int 21h
mov [si],al
inc si
loop loopIn
mov ah,2
mov dl,10
int 21h
mov dl,13
int 21h
mov si,offset arr
mov cx,8
print "Array elements are : "
loopOut:
mov dl,[si]
mov ah,2
int 21h
mov dl,32
mov ah,2
int 21h
inc si
loop loopOut
main endp
ret
LDRP-ITR Page No-
Microprocessor Architecture and programming 21BECE30308

Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 17

Aim-Write ALP to find whether the number is Odd or Even.

Code:
.DATA
MSG1 DB 10,13,'Enter number: $'
MSG2 DB 10,13,'Result:Number is Even$'
MSG3 DB 10,13,'Result:Number is Odd$'
DATA ENDS
DISPLAY MACRO MSG
MOV AH, 9
LEA DX, MSG
INT 21H
ENDM
.CODE
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
DISPLAY MSG1
MOV AH, 1
INT 21H
MOV AH, 0
CHECK:
MOV DL, 2
DIV DL
CMP AH, 0
JNE ODD
EVEN:
DISPLAY MSG2
JMP DONE
ODD:
DISPLAY MSG3
DONE:
MOV AH, 4CH
INT 21H
CODE ENDS
END START
LDRP-ITR Page No-
Microprocessor Architecture and programming 21BECE30308

Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308
Practical 18

Aim-Write ALP to Perform Addition of two Arrays.

Code:
org 100h
mov si,700h
mov cl,[si]
mov ch,00h
inc si
mov di,750h
l1:
mov al,[si]
add al,[di]
mov [si],al
inc si
inc di
loop l1
hlt
Output:

LDRP-ITR Page No-


Microprocessor Architecture and programming 21BECE30308

LDRP-ITR Page No-

You might also like