⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ifindrep.asm

📁 还是一个词法分析程序
💻 ASM
字号:

;   FILENAME: IFINDREP.ASM
;
;   Copyright (c) 1988, 1992 by Borland International, Inc.
;
;   DESCRIPTION: This module implements the routine FindAndReplace. The
;   routine will search through an array of bytes replacing all instances
;   of a particular value with an alternative value. This module uses
;   ideal mode syntax.
;
;   ASSEMBLY INSTRUCTIONS: To assemble this module use the following TASM
;   command line:
;
;       TASM /dMDL=memorymodel Ifindrep
;
;   'memorymodel' in the above command line may be replaced by TINY, SMALL,
;   MEDIUM, COMPACT, LARGE or HUGE.

%tabsize 4

ifndef  MDL
    display "Error: This module requires that you provide a memory model"
    display "       definition on the command line. I.E. /dMDL=SMALL."
    err ; Force a fatal error
else

    ideal           ; Use TASM's Ideal mode
%   model   MDL     ; Define the memory model

    codeseg

    global  FindAndReplace:proc ; Declare public proc

    proc    FindAndReplace

    ;   This routine searches through an array of byte values looking for
    ;   the value indicated in al. Whenever it finds a match it replaces the
    ;   byte with the value stored in ah. Note that this routine assumes that
    ;   the pointer passed to it is normalized if the array being searched
    ;   is longer than 0FFF0h bytes.
    ;
    ;   Input
    ;       ArrayPtr - far pointer to array
    ;       al - unsigned byte value to search for
    ;       ah - unsigned byte value to replace with
    ;       cx - maximum number of bytes to search.
    ;   Output
    ;       none
    ;   Calling convention
    ;       Pascal
    ;   Registers modified
    ;       cx, di, es, Flags

    arg ArrayPtr:dword=PARM_SIZE    ; Define parameter passed on stack

        push    bp                  ; Set up the stack to access parameters
        mov     bp, sp
        les     di, [ArrayPtr]      ; Get the address of the array
        cld                         ; Search from low address to high address
    ReplaceLoop:
        repne   scasb               ; Find a matching byte
        jcxz    Exit                ; At end of array
        mov     [byte es:di], ah    ; Replace byte
        jmp     ReplaceLoop         ; Replace next byte
    Exit:
        pop     bp                  ; Restore stack pointer
        ret     PARM_SIZE           ; Clean up stack since we're using Pascal
                                    ; calling conventions
    endp    FindAndReplace

endif   ; ifndef MDL

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -