xxx.asm:

%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16 section .text
global dllmain
export astricmp dllmain:
mov eax,1
ret 12 ;-------------------------------------------;
; 对字符串(char)进行不区分大小写的比较。
;-------------------------------------------;
astricmp:
push ebp
mov ebp,esp
sub esp,12 %define pStr1 edx
%define pStr2 ecx mov pStr1,[p1] ; char ptr1
mov pStr2,[p2] ; char ptr2 mov [ebp-12],ebx .for:
mov [ebp-4],pStr1
mov [ebp-8],pStr2 mov bh,[pStr1]
mov bl,[pStr2] mov al,bh
push eax
call _toLowerCase
mov bh,al mov al,bl
push eax
call _toLowerCase
mov bl,al test bh,bl
jz .identical cmp bh,bl
jc .less
jne .greater ; 不相等跳 mov pStr1,[ebp-4]
mov pStr2,[ebp-8]
inc pStr1
inc pStr2
jmp .for ;-----------------------------------------------------;
; <0 string1 less than string2
;-----------------------------------------------------;
.less:
xor eax,eax
not eax
jmp .return ;-----------------------------------------------------;
; 0 string1 identical to string2
;-----------------------------------------------------;
.identical:
xor eax,eax
jmp .return ;-----------------------------------------------------;
; >0 string1 greater than string2
;-----------------------------------------------------;
.greater:
mov eax,1
jmp .return .return:
mov ebx,[ebp-12]
add esp,12
mov esp,ebp
pop ebp
ret 8 _toLowerCase:
push ebp
mov ebp,esp mov al,[p1] ; char
;----------------------------------------;
; 如果 < 0x41 return
;----------------------------------------;
cmp al,41h
jb .return ;----------------------------------------;
; 如果 > 0x5A return
;----------------------------------------;
cmp al,5Ah
ja .return add al,20h .return:
mov esp,ebp
pop ebp
ret 4

c++:

#include <iostream>
#include <Windows.h> typedef size_t (CALLBACK* astricmp_t)(const char* str1, const char* str2); astricmp_t astricmp; int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astricmp = (astricmp_t)GetProcAddress(myDLL, "astricmp"); printf("%d\n", _stricmp("a", "a")); // 0
printf("%d\n", _stricmp("a", "A")); // 0
printf("%d\n", _stricmp("", "")); // 0
printf("%d\n", _stricmp("a", "b")); // -1
printf("%d\n", _stricmp("b", "a")); // 1 printf("//----------------------------------------\n"); printf("%d\n", astricmp("aaaa", "AaA")); // 0
printf("%d\n", astricmp("a", "A")); // 0
printf("%d\n", astricmp("", "")); // 0
printf("%d\n", astricmp("a", "b")); // -1
printf("%d\n", astricmp("b", "aaaaa")); // 1
return 0;
}

nasm astricmp函数 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 astrcspn函数 x86

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

  3. nasm astrchr函数 x86

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

  4. nasm astrlen函数 x86

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

  5. nasm aat函数 x86

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

  6. nasm astrstr函数 x86

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

  7. nasm astrset_s函数 x86

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

  8. nasm astrrev函数 x86

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

  9. nasm astrrchr函数 x86

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

随机推荐

  1. Python 2.x 和 Python 3.x

    Python 2.x 默认不支持中文,具体原因,等到介绍 字符编码 时给大家讲解 Python 2.x 的解释器名称是 python Python 3.x 的解释器名称是 python3 目前市场上有 ...

  2. Pod和容器的LimitRange原理和实践总结

    一.背景介绍 通常情况下,Pod中的容器可以无限制的使用节点上的CPU和内存资源,在共享资源和资源有限的情况下,若不加以限制,某个集群或命名空间的资源可能会消耗殆尽,导致其他节点上优先级低的Pod发生 ...

  3. CentOS 安装TFTP

    1.当然是使用yum安装最直接,一共会安装3个东东tftp.i386tftp-server.i386xinetd.i386[root@localhost CentOS]# yum -y install ...

  4. mysql-mysqli_fetch_all(错误)

    mysql-mysqli_fetch_all(错误) 问题:使用mysql-mysqli_fetch_all获取返回的数组时失败/报错 原因及解决方法: mysqli_fetch_all函数只存在于m ...

  5. php小项目-web在线文件管理器

    php小项目-web在线文件管理器 一 项目结果相关视图 二 项目经验 通过简单的实现小项目,对php的文件相关操作更加熟悉,主要用于熟悉文件的相关操作 三 源代码下载地址 http://files. ...

  6. Docker容器管理平台Rancher高可用部署——看这篇就够了

    记得刚接触Rancher时,看了官方文档云里雾里,跟着官网文档部署了高可用Rancher,发现不管怎么折腾都无法部署成功(相信已尝试的朋友也有类似的感觉),今天腾出空来写个总结,给看到的朋友留个参考( ...

  7. CF-311B Cats Transport(斜率优化DP)

    题目链接 题目描述 小S是农场主,他养了 \(M\)只猫,雇了 \(P\) 位饲养员. 农场中有一条笔直的路,路边有 \(N\) 座山,从 \(1\) 到 \(N\)编号. 第 \(i\) 座山与第 ...

  8. Codeforces750E. New Year and Old Subsequence (线段树维护DP)

    题意:长为2e5的数字串 每次询问一个区间 求删掉最少几个字符使得区间有2017子序列 没有2016子序列 不合法输出-1 题解:dp i,p(0-4)表示第i个数匹配到2017的p位置删掉的最少数 ...

  9. 【noi 2.2_8758】2的幂次方表示(递归)

    题意:将正整数N用2的幂次方表示(彻底分解至2(0),2). 解法:将层次间和每层的操作理清楚,母问题分成子问题就简单了.但说得容易,操作没那么容易,我就打得挺纠结的......下面附上2个代码,都借 ...

  10. 一文弄懂使用Jmeter来进行性能测试

    该文章是基于上一次文章的 软件测试漫谈(web测试,自动化测试,Jmeter) 的续篇, 主要是详细讲解 Jmeter 的入门教程. 因为上次的文章只是简单地讲解了 Jmeter 的使用和一些概念,所 ...