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

    xxx.asm

    %define p1 ebp+8
    %define p2 ebp+12
    %define p3 ebp+16
    
    section .text
      global dllmain
      export astrspn
    
    dllmain:
      mov eax,1
      ret 12
    
    ;---------------------------------------------------;
    ; 返回不属于一组字符的字符串中第一个字符的索引
    ;---------------------------------------------------;
    astrspn:
      push ebp
      mov ebp,esp
      sub esp,8
      
      mov edx,[p1]	; const char *str
      mov ecx,[p2]	; const char *strCharSet
      xor eax,eax
      
      ; 临时变量
      mov [ebp-4],ecx
      mov [ebp-8],ebx
      
      ;-------------------------------------;
      ; 遍历 str
      ;-------------------------------------;
      .forStr:
      mov bh,[edx]
      test bh,bh
      jz .return
      
      ;-------------------------------------;
      ; 遍历 strCharSet
      ;-------------------------------------;
      .forStrCharSet:
      mov bl,[ecx]
      test bl,bl
      jz .return	; 没找到退出函数
      
      cmp bh,bl
      je .forbreak	; 相等 next str
      
      inc ecx
      jmp .forStrCharSet	; 不相等 next strCharSet
      
      .forbreak:
      mov ecx,[ebp-4]
      inc edx
      inc eax
      jmp .forStr
      
      .return:
      mov ebx,[ebp-8]
      add esp,8
      mov esp,ebp
      pop ebp
      ret 8
    

    c++:

    #include <iostream>
    #include <Windows.h>
    
    typedef int (CALLBACK* astrspn_t)(const char* str, const char* strCharSet);
    astrspn_t astrspn;
    
    int main()
    {
      HMODULE myDLL = LoadLibraryA("xxx.dll");
      astrspn = (astrspn_t)GetProcAddress(myDLL, "astrspn");
    
      printf("%d
    ", strspn( "abbbc", "ab")); // 4
      printf("%d
    ", astrspn("abbbc", "ab")); // 4
      return 0;
    }
    
  • 相关阅读:
    vsCode_1.27.2
    前端图片压缩(纯js)
    chrome浏览器表单自动填充默认样式(背景变黄)-autofill
    前端Table数据导出Excel使用HSSFWorkbook(Java)
    linux下安装python3.6
    linux 下启动tomca慢问题
    linux下nginx配置ssl证书(https)
    spring+mybatis多数据源
    css3实现小箭头,各种图形
    Windows 环境搭建Redis集群(win 64位)
  • 原文地址:https://www.cnblogs.com/ajanuw/p/13743312.html
Copyright © 2011-2022 走看看