MP practical programs

Views:



These are the Microprocessor practical codes for the students of Computer Engineering of Mumbai. 

University.

1) DS – ES-String

data segment
src db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah
data ends

extra segment
dest db ?
extra ends

code segment
assume cs:code,ds:data,es:extra
start:
mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
mov cl,0Ah
LEA si,src
LEA di,dest
Rep MOVSB
int 03h
code ends
end start


 2) DS – ES

data segment
src db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah
data ends

extra segment
dest db ?
extra ends

code segment
assume cs:code,ds:data,es:extra
start:
mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
mov cl,0Ah
LEA si,src
LEA di,dest
up:mov al,[si]
mov es:[di],al
inc si
inc di
dec cl
jnz up
int 03h
code ends
end start


 3) PALINDROME.

data segment
string db 'KATAKA$'
p db ?
data ends
code segment
assume cs:code, ds:data
start:
            mov ax,data
            mov ds,ax
            mov cl,00h
            lea si,string
      up: mov al,[si]
            cmp al,24h
            jz down

            inc cl
            inc si
            jmp up
    down:mov bl,00h
             dec si
             lea di,string
     up1:mov al,[di]
             cmp [si],al
             jnz exit
             inc di
             dec si
             dec cl
             jnz up1
             mov bl,01h
    exit:mov p,bl
             int 03h
code ends
end start


4) ASCENDING BUBBLE SORT.

data segment
no db 08h,02h,01h,03h,05h,06h,07h,09h,04h,0Ah
data ends
code segment
assume ds:data, cs:code
start:
mov ax,data
mov ds,ax
mov ch,09h
up1:lea si,no
lea di,no
inc di
mov cl,09h
up:mov dl,[di]
cmp [si],dl
jb down
xchg [si],dl
mov [di],dl
down:inc si
inc di
dec cl
jnz up
dec ch
jnz up1
int 03h
code ends
end start



 5) DESCENDING BUBBLE SORT.

data segment
no db 08h,02h,01h,03h,05h,06h,07h,09h,04h,0Ah
data ends
code segment
assume ds:data, cs:code
start:
mov ax,data
mov ds,ax
mov ch,09h
up1:lea si,no
lea di,no
inc di
mov cl,09h
up:mov dl,[di]
cmp [si],dl
ja down
xchg [si],dl
mov [di],dl
down:inc si
inc di
dec cl
jnz up
dec ch
jnz up1
int 03h
code ends
end start




 6) REVERSE

DATA SEGMENT
SRC DB "MAMA$"
DST DB ?
C DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
MOV CL,00H
LEA SI,SRC
MOV AL ,24H
UP:CMP [SI],AL
JZ DOWN
INC CL
INC SI
JMP UP
DOWN:MOV C,CL
DEC SI
LEA DI,DST
UP1: MOV AL,[SI]
MOV [DI],AL
DEC SI
INC DI
DEC CL
JNZ UP1
INT 03H
CODE ENDS
END START


 7) CONVERT CASE

data segment
string db "coMPUteRs$"
data ends
code segment
assume cs:code, ds:data
start:
mov ax,data
mov ds,ax
lea si,string
up:mov al,[si]
cmp al,24h
jz exit
cmp al,60h
jnc down
add al,20h
jmp skip
down: sub al,20h
skip: mov [si],al
 inc si
 jmp up
 exit: int 03h
code ends
end start



8a) MAXIMUM

data segment
src db 01h,02h,03h,04h,05h,55h,07h,08h,09h,0Ah
res db ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea si,src
mov cl,0ah
mov bl,[si]
up:mov al,[si]
cmp bl,al
jnc down
mov bl,al
down:inc si
dec cl
jnz up
mov res,bl
int 03h
code ends
end start



 8b) MINIIMUM

data segment
src db 0Ah,20h,30h,40h,05h,60h,70h,80h,90h,50h
res db ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea si,src
mov cl,0Ah
mov bl,[si]
up:mov al,[si]
cmp bl,al
jc down
mov bl,al
down:inc si
dec cl
jnz up
mov res,bl
int 03h
code ends
end start



 9) EVEN - ODD from 10 bytes using DIV


        data segment
        series db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah
        count db 0Ah
        even db 00h
        odd db 00h
        data ends

 code segment
        Assume   cs:code,ds:data
                start: mov ax ,data
               mov ds,ax
               lea si,series
               mov bh,02
             up: mov al,[si]
               mov ah,0000h
               div bh
               cmp ah,00h
               je down
               inc odd
               jmp down1
            down:inc even
            down1:inc si
               dec count
               jnz up
               int 03h
    code ends
    end start



 10) SEARCH

data segment
src db 23h, 12h, 34h, 23h, 35h, 64h, 34h, 04h, 20h, 11h
c db ?
no db 35h
found db 00h
data ends

code segment
assume cs:code,ds:data
start:mov ax,data
      mov ds,ax
      mov c,0Ah
      lea si,src

up:   mov al,[si]
      cmp al,no
      jz f
      inc si
      dec c
      jnz up
      jmp exit

f: mov found,01h

exit:int 03h
code ends
end start



 11) EVEN - ODD from 10 bytes using Rotate

data segment
     series db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah
        count db 0Ah
        even db 00h
        odd db 00h
        data ends

 code segment
        Assume   cs:code,ds:data
             start: mov ax ,data
               mov ds,ax
               lea si,series
               mov bh,02
              up: mov al,[si]
               rcr al,01h
               jnc down
               inc odd
               jmp down1     
           down:inc even
           down1:inc si
               dec count
               jnz up
                int 03h         
    code ends
    end start



 12) EVEN – ODD using DOS

data segment
cr equ 0dh
lf equ 0ah
message db cr,lf,'Enter no or press "q" to quit',cr,lf,'$'
evn db cr,lf,'No is Even',cr,lf,'$'
odd db cr,lf,'No is Odd',cr,lf,'$'
no db 02h
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
up:lea dx,message
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,'q'
jz exit
mov ah,00h
cmp al,40h
jge up
cmp al,30h
jl up
sub al,30h
div no
cmp ah,00h
jnz odd1
lea dx,evn
mov ah,09h
int 21h
jmp up
odd1:lea dx,odd
mov ah,09h
int 21h
jmp up
exit:mov ah,4ch
int 21h
code ends
end start




13) PRIME using DOS

data segment
cr equ 0dh
lf equ 0ah
str1 db cr,lf,'Enter a no or "q" to exit : ', cr,lf,'$'
str2 db cr,lf,'No is Prime', cr,lf,'$'
str3 db cr,lf,'No is not prime', cr,lf,'$'
data ends
code segment
assume cs:code, ds:data
start:
mov ax,data
mov ds,ax
up:mov dx,offset str1
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,'q'
jz exit
cmp al,40h
jge up
cmp al,30h
jbe up
sub al,30h
cmp al,03h
jbe prime
mov bl,01h
mov dl,al
l1:inc bl
cmp dl,bl
jz prime
mov ah,00h
div bl
cmp ah,00h
jz np
mov al,dl
jmp l1
prime:lea dx,str2
mov ah,09h
int 21h
jmp up
np:lea dx,str3
mov ah,09h
int 21h
jmp up
exit:mov ah,4ch
int 21h
code ends
end start //end of Prime



14) FIBBONACCI
data segment
no db 08h
data ends

code segment
assume ds:data,cs:code
start:
mov ax,data
mov ds,ax
mov cl,00h
mov ch,01h
mov DI,2000h
mov [DI],cl
inc DI
mov [DI],ch
dec no
dec no
inc DI
up:mov al,cl
add al,ch
mov [DI],al
mov cl,ch
mov ch,al
inc DI
dec no
jnz up
int 03h
code ends
end start


 15) FACTORIAL

data segment
no db 05h
output1 dw ?
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov cx,0001h
mov dx,0000h
mov ax,0001h
up:mul cx
inc cx
dec no
jnz up
mov output1,ax
int 03H
code ends
end start

0 comments :

Post a Comment

Like "Jitu's Pensieve" on Facebook
×