IUP Computer Science
COSC 300    Fall 03

Quiz #4
(24 April 2002)

Below is the declaration of an array of word-length integers (DATA), a variable containing the number of elements in DATA (THESIZE), and a variable to hold the smallest number in the array (TINY). A procedure named LEAST is to be written to find the value of TINY. Arguments to the procedure must be passed on the stack (by reference for DATA and TINY and by value for THESIZE). LEAST is being called from main. Fill in the missing statements in main and in LEAST to make the procedure do its job.

DATA        DW	200 dup(?)
THESIZE	    DW	?
TINY        DW	?






CALL		LEAST


_______________________________
LEAST	proc






          mov	cx, [bp+6]	; Set loop counter
          mov	si, [bp+8]	; Point to first array element
          mov	ax, [si]	; Get initial smallest value
   top:	  cmp	[si], ax	; Check if value is less than
          jge	skip
          mov	ax, [si]	; Save new lower value
  skip:	  add	si, 2		; Move to next element
         loop	top
          mov	si, [bp+4]	; Return least value
          mov	[si], ax








LEAST 	endp