namefpth.asm

来自「工欲善其事」· 汇编 代码 · 共 57 行

ASM
57
字号
; #########################################################################

    .386
    .model flat, stdcall  ; 32 bit memory model
    option casemap :none  ; case sensitive

    .code

; ########################################################################

NameFromPath proc lpPath:DWORD,lpBuffer:DWORD

    push edi

    mov ecx, lpPath

  ; -------------------------------------------------------
  ; Scan path buffer for "\" and put each offset + 1 from
  ; ecx into edx. Offset of last occurrence of "\" + 1 will
  ; be in edx when loop exits on zero.
  ; -------------------------------------------------------

  @@:
    mov al, [ecx]
    inc ecx
    cmp al, 0           ; exit condition for 1st loop
    je @F
    cmp al, "\"         ; test for "\"
    jne @B
    mov edx, ecx        ; if "\" put ecx+1 offset in edx
    jmp @B
  @@:

    sub ecx, lpPath     ; length in ecx
    add ecx, edx        ; create exit condition

  ; ---------------------------
  ; copy file name to lpBuffer
  ; ---------------------------
    mov edi, lpBuffer
  @@:
    mov al, [edx]
    inc edx
    mov [edi], al
    inc edi
    cmp edx, ecx
    jne @B

    pop edi

    ret

NameFromPath endp

; #########################################################################

end

⌨️ 快捷键说明

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