Write an assembly language program to find the smallest element from an array.



Experiment Name: Write an assembly language program to find the smallest element from an array.

Objective:
          (i) To know about several command in the Assembly language.
          (ii) Input a Character.
          (iii) Output a Character.

Source Code:
.model small
.stack
.data
          msg1db0dh,0ah, “smallest element is:$”
          arraydb5,9,6,7,1,3
          smallestdb?
.code

main proc
          mov ax,@data
          mov ds,ax
          lea di,array

          mov cx,5 ; 5 times count
          mov al,[di] ; memory location send ‘di’ registerar data ‘al’
          mov smallest,al

          step:  ;level
                   inc di
                   mov bl,[di]

                   cmp smallest,bl
                   jlel1  ;jge= jump gratherthan equal ,

                   mov smallest,bl
          l1:
                   loop step
                   add smallest,30h ; integer to character (add30 for asii value)

                   lea dx,msg1

                   mov ah,09h
                   int 21h

                   mov dl,smallest
                   mov ah,02h
                   int 21h
         
          mov ah,4ch
          int 21h
main endp
end main

Input/output:

          SMALLESTELEMENT IS: 1

No comments

Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....

Theme images by ideabug. Powered by Blogger.