zoukankan      html  css  js  c++  java
  • nasm astrrchr函数 x86

    xxx.asm

    %define p1 ebp+8
    %define p2 ebp+12
    %define p3 ebp+16
    
    section .text
      global dllmain
      export astrrchr
    
    dllmain:
      mov eax,1
      ret 12
    
    ;------------------------------------------------;
    ;	扫描字符串以查找字符的最后一次出现。
    ;------------------------------------------------;
    astrrchr:
      push ebp
      mov ebp,esp
      push ebx
    
      mov ecx,[p1]	; const char *str
      mov eax,[p2]	; int c
      
      .for:
      mov dl,[ecx]
      test dl,dl
      jz .return
      cmp dl,al
      jne .next
      mov ebx,ecx
      .next:
      inc ecx
      jmp .for
      
      .return:
      mov eax,ebx
      pop ebx
      mov esp,ebp
      pop ebp
      ret 8
    

    c++:

    #include <iostream>
    #include <Windows.h>
    #include <tchar.h>
    #include <string>
    
    typedef int (CALLBACK* astrrchr_t)(const char* str, int c);
    
    astrrchr_t astrrchr;
    
    int main()
    {
      HMODULE myDLL = LoadLibraryA("xxx.dll");
      astrrchr = (astrrchr_t)GetProcAddress(myDLL, "astrrchr");
    
      printf("%s
    ", strrchr( "hello world", "o"[0])); // orld
      printf("%s
    ", astrrchr("hello world", "o"[0])); // orld
    
      printf("%s
    ", strrchr( "hello world", "l"[0])); // ld
      printf("%s
    ", astrrchr("hello world", "l"[0])); // ld
      return 0;
    }
    
  • 相关阅读:
    MyISAM 和InnoDB 区别 转
    beautifulsoup
    爬虫学习
    python操作数据库
    爬虫
    python爬虫
    PHP中“简单工厂模式”实例讲解
    PERL 实现微信登录
    PERL 实现微信登录
    NLS_LANG SIMPLIFIED CHINESE_CHINA.AL32UTF8 和american_america.AL32UTF8
  • 原文地址:https://www.cnblogs.com/ajanuw/p/13742549.html
Copyright © 2011-2022 走看看