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\n", strspn( "abbbc", "ab")); // 4
printf("%d\n", astrspn("abbbc", "ab")); // 4
return 0;
}

最新文章

  1. Codeforces Round #346 (Div. 2)
  2. gradle android
  3. 1071: [SCOI2007]组队 - BZOJ
  4. UVA 1658 Admiral 海上将军(最小费用流,拆点)
  5. IntelliJ IDEA 中module的dependencies是其它module时的注意事项
  6. Velocity知识点总结
  7. POJ1094 拓扑排序
  8. C#基础之------控制台进程
  9. jquery的clone办法bug修复
  10. BZOJ 1355: [Baltic2009]Radio Transmission( kmp )
  11. react+webpack开发环境配置
  12. [最短路][部分转]P1027 Car的旅行路线
  13. python学习之路基础篇(第六篇)
  14. iOS常见控件的基本使用
  15. VSCode与Deepin资源管理器冲突
  16. MYSQL 比较集
  17. 原码、补码,反码以及JAVA中数值采用哪种码表示
  18. autoMapper的介绍
  19. Linux 4.21包含对AMD Rome处理器中新的Zen 2架构重要的新优化
  20. CodeMix入门基础知识

热门文章

  1. python 9学习 高级特性
  2. three.js cannon.js物理引擎之制作拥有物理特性的汽车
  3. hive-2.2.0 伪分布式环境搭建
  4. Go语言学习-main和init
  5. pythonchallenge总述
  6. 使用C#实现数据结构堆
  7. Vuejs 基础学习教程
  8. JavaHomeWorkList
  9. hdu4126Genghis Khan the Conqueror (最小生成树+树形dp)
  10. UVA 10480 Sabotage (最大流最小割)