;*******************************************************************************
proc          findmin     ; The return value (index of the minimum) will be in ax
              push bp
              mov  bp,sp 
; save registers used in proc, to be restored upon return to the main program
              push cx
              push dx
              push si
;--------------------------------------------------------------------------------        
              mov  cx,[bp+6]   ; array size
              dec  cx
              xor  dx,dx
              mov  bx,[bp+4]   ; array's address
              xor  ax,ax
              mov  dl,[byte ptr bx]     ; dl will always have the minimum
              mov  si,1
loop1:        cmp  dl,[byte ptr bx+si]  
              jl   cont
              mov  dl,[byte ptr bx+si]
              mov  ax,si                ; ax will have the index of the minimum
cont:         inc  si
              loop loop1
; restore registers to the way they were before calling the proc
              pop  si
              pop  dx
              pop  cx
;-------------------------------------------------------------------------------
              pop  bp
              ret  4
endp          findmin 
;*******************************************************************************