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