; CS2011, A Term 1999
; Prof. Sergio A. Alvarez

title Example of If-Then Using Conditional Jumps 

.model small
.stack

.data
array db 0,4,8,2,3,9,5
arraylength = $-array
max db ?

.code
.startup

; basic if-then structure used below is:
; if (A>B) then action
;   cmp A,B
;   jle not_action
;   action:
   ; code for action goes here
;   not_action:

; finding the max of an array using the above
   mov al,array[0]
   mov max,al
   mov di,1
   mov cx,arraylength
   maxloop:
      mov al,array[di]
      cmp al,max
      jle endloop
      mov max,al
   endloop:
      inc di
   loop maxloop

.exit
end


