查找键值为key的元素

; 
;查找键值为key的元素
; 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   
maxNbrs     EQU    100   

.STACK      4096

.DATA
Array    DWORD   23,12,5,-78,27,33,4,32
count    DWORD   ?
Lable    BYTE    cr,Lf,'Can not find the key',cr,Lf,Lf,0

keyLable BYTE    cr,Lf,Lf,'The key is in : '
su       BYTE    11 DUP (?)

.CODE
_start:
       mov eax,27          ;键值key
       mov edx,0
       lea ebx,Array

whilenot    :  
             inc edx
             ;mov ecx,count
             cmp edx,9
             je  endthat
     
             cmp eax,[ebx]
             je endwhile
             add ebx,4
             jmp whilenot
             
endwhile    :     
            mov eax,edx
            dtoa su,eax
            output keyLable
            jmp quit

endthat     :
             output Lable
            

quit:       INVOKE ExitProcess, 0   ; exit with return code 0

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

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