xxx.asm

  1. %define p1 ebp+8
  2. %define p2 ebp+12
  3. %define p3 ebp+16
  4. section .text
  5. global dllmain
  6. export astrcspn
  7. dllmain:
  8. mov eax,1
  9. ret 12
  10. ;---------------------------------------------------;
  11. ; 返回属于一组字符的字符在字符串中第一次出现的索引
  12. ;---------------------------------------------------;
  13. astrcspn:
  14. push ebp
  15. mov ebp,esp
  16. sub esp,8
  17. mov edx,[p1] ; char ptr 1
  18. mov ecx,[p2] ; char ptr 2
  19. xor eax,eax
  20. ; 保存str2指针,和ebx寄存器
  21. mov [ebp-4],ecx
  22. mov [ebp-8],ebx
  23. ;-------------------------------------;
  24. ; 遍历 str1
  25. ;-------------------------------------;
  26. .forStr1:
  27. mov bh,[edx]
  28. test bh,bh
  29. jz .return
  30. ;-------------------------------------;
  31. ; 遍历str2,如果相等退出函数
  32. ;-------------------------------------;
  33. .forStr2:
  34. mov bl,[ecx]
  35. test bl,bl
  36. jz .forbreak
  37. cmp bh,bl
  38. je .return
  39. inc ecx
  40. jmp .forStr2
  41. .forbreak:
  42. mov ecx,[ebp-4]
  43. inc edx
  44. inc eax
  45. jmp .forStr1
  46. ;-------------------------------------;
  47. ; 恢复ebx寄存器,恢复堆栈
  48. ;-------------------------------------;
  49. .return:
  50. mov ebx,[ebp-8]
  51. add esp,8
  52. mov esp,ebp
  53. pop ebp
  54. ret 8

c++:

  1. #include <iostream>
  2. #include <Windows.h>
  3. typedef size_t (CALLBACK* astrcspn_t)(const char* str1, const char* str2);
  4. astrcspn_t astrcspn;
  5. int main()
  6. {
  7. HMODULE myDLL = LoadLibraryA("xxx.dll");
  8. astrcspn = (astrcspn_t)GetProcAddress(myDLL, "astrcspn");
  9. const char* str1 = "fcba73";
  10. const char* str2 = "1234567890";
  11. printf("%d\n", strcspn(str1, str2)); // 4
  12. printf("%d\n", astrcspn(str1, str2)); // 4
  13. return 0;
  14. }

nasm astrcspn函数 x86的更多相关文章

  1. nasm astrspn函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  2. nasm astrchr函数 x86

    xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...

  3. nasm astrlen函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  4. nasm aat函数 x86

    xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain dllmain: ...

  5. nasm astrstr函数 x86

    xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...

  6. nasm astrset_s函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  7. nasm astrrev函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  8. nasm astrrchr函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  9. nasm astrncmp函数 x86

    xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...

随机推荐

  1. Centos虚拟机上安装部署Tenginx,以及部署过程中遇到的问题

    Tenginx下载网址: Tenginx 官网地址:http://tengine.taobao.org/ Tenginx的官方网址中可以阅读Nginx的文档,可以选择中文进行阅读.下载Tengine- ...

  2. 阿里一面,给了几条SQL,问需要执行几次树搜索操作?

    前言 有位朋友去阿里面试,他说面试官给了几条查询SQL,问:需要执行几次树搜索操作?我朋友当时是有点懵的,后来冷静思考,才发现就是考索引的几个基础知识点~~ 本文我们分九个索引知识点,一起来探讨一下. ...

  3. Flink-v1.12官方网站翻译-P004-Flink Operations Playground

    Flink操作训练场 在各种环境中部署和操作Apache Flink的方法有很多.无论这种多样性如何,Flink集群的基本构件保持不变,类似的操作原则也适用. 在这个操场上,你将学习如何管理和运行Fl ...

  4. 理解了这三点,才敢说自己会写Python代码

    某同学应聘Python岗位被录用.上班第一天,Leader吩咐他写一个获取次日日期信息的函数.该同学信心满满地写下了这样一段代码, 然后就没有然后了. import time def get_next ...

  5. 一周精彩内容分享(第 1 期):"世纪逼空大战"

    这里记录过去一周,我看到的值得分享的东西. 一方面是整理记录一下自己一周的学习,另一方面也是期待自己有更多的输出,有更多的价值. 周刊开源(Github:wmyskxz/weekly),欢迎提交 is ...

  6. HDU-3240(卡特兰数+分解质因数后求逆元)

    卡特兰数相关公式 : \(H_n = {C_{2n}^n \over n+1)}\) \(H_n = {(4n-2)\over n+1}\times H_{n-1}\) \(H_n = C_{2n}^ ...

  7. poj3415 Common Substrings (后缀数组+单调队列)

    Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 9414   Accepted: 3123 Description A sub ...

  8. Codeforces Round #652 (Div. 2) E. DeadLee 贪心

    题意: 派会上有n种食物,每种食物有wi份.有m个朋友,每一个朋友有两种他喜欢吃的食物xi,yi.你需要判断他的朋友是否都能吃到食物.如果都能吃到食物,那么要输出朋友来的顺序,不能的话输出" ...

  9. Atcoder ABC162 D - RGB Triplets

    传送门:D - RGB Triplets  题意:给你一个只含'R','G','B'的字符串,求有多少个长度为3且每个字符都不相等,并且第一第二和第二第三的区间长度不同的子序列. 题解:统计每个字符各 ...

  10. tomacat服务器上web资源访问流程、web应用打成war包发布、Context的reloadable属性、tomacat体系架构

    一.web资源访问流程 二.web应用打成war包发布到服务器 好处:打成war包发布到服务器,那么服务器会自动把它拆解成文件夹 jar命令是java自带的一个命令,如果之前配置过Java编译环境就可 ...