查询最大与最小值

;
; 
;查询最大与最小值
; author:  wangguolaing
; date:  revised 4/14

.386
.MODEL FLAT

INCLUDE io.h
includelib Kernel32.lib
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

cr          EQU    0dh  
Lf          EQU    0ah      

.STACK      4096

.DATA
Array    DWORD  34,-34,5,4,2,-5,0,-45
count    DWORD  ?
max      DWORD  ?
min      DWORD  ?
flaga    BYTE 'The max :'
flag1          BYTE 11 DUP (?)
          BYTE cr,Lf,Lf
flagb     BYTE 'The min :'
flag2     BYTE  11  DUP (?)
          BYTE  cr,Lf,Lf,0
.CODE
_start:
         lea ebx,Array
         mov eax,[ebx]     ;max
         mov edx,[ebx]      ;min
whileup    :
         mov ecx,count
         cmp ecx,8
         je  endwhile
         add ebx,4
         inc count
         cmp eax,[ebx]
         jl  maxlable
         cmp edx,[ebx]
         jg  minlable
         jmp whileup

maxlable   :
          mov eax,[ebx]
          jmp whileup

minlable   :
          mov edx,[ebx]
          jmp whileup
endwhile   :
           dtoa flag1,eax   
           dtoa flag2,edx
           output flaga
                                         
quit:       INVOKE ExitProcess, 0   ; exit with return code 0

PUBLIC _start                       ; make entry point public
            END                     ; end of source code  

你可能感兴趣的:(汇编语言,80x86)