nasm astricmp函数 x86
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的更多相关文章
- nasm astrspn函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrcspn函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrchr函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...
- nasm astrlen函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm aat函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain dllmain: ...
- nasm astrstr函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...
- nasm astrset_s函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrrev函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrrchr函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
随机推荐
- WebServices 与 Web API 的区别
WebServices : WebServices 是可以通过 Internet 访问并通过 XML 编码规范其通信的任何服务. 客户通过发送请求(大部分是 XML消息)来召唤 WebServices ...
- 在ubuntu编写helloworld
安装vim 打开终端 输入sudo apt-get install vim-gtk 输入登陆密码 等待安装完成 编译C 创建.c文件:vim helloworld.c 编写代码,保存并退出 编译:gc ...
- 莫队/se 优雅的暴力
莫队算法 发明者:队爷莫涛 基于分块的一种暴力算法, 复杂度最慢可以被卡到\(n^2\)正常情况下的复杂度大约在\(O(n\sqrt{n})\)左右分块的大小对复杂的影响很大其中最优分块的大小为\(\ ...
- koa2+koa-generator+mysql快速搭建nodejs服务器
koa2+koa-generator+mysql快速搭建nodejs服务器 用koa的脚手架koa-generator可以快速生成项目骨架,可以用于发开或者测试接口 https://github.co ...
- UVA-257 哈希算法
UVA-257 题意: 给你很多串,你需要找到这个串内有没有两个长度大于3的回文字符串,且要保证这两个回文字符串不相同,也不能完全覆盖,但可以重合一部分 题解: 首先判断回文的话可以通过马拉车算法(M ...
- .net面试--值类型和引用类型
注:下面的示意图主要是为了辅助理解,不代表内存真实情况. Introduction 类型基础是C#的基础概念,了解类型基础及背后的工作原理更有助于我们在编码的时候明白数据在内存中的分配与传递.C#提供 ...
- Python 读Excel数据
一.读取Excel数据的步骤及方式: 1.打开Excel文件 data = xlrd.open_workbook(r'D:\Interface_test\test_data\测试用例.xlsx') 2 ...
- Jenkins+ant+Jmeter接口自动化框架搭建
工具准备 JDK: jdk1.8.0_111 Ant: apache-ant-1.9.9 Jmeter: apache-jmeter-3.1 Jenkins: jenkins-2.7.4 JDK安装 ...
- read()、readline()、readlines() -- Python
文本文件:readfile.txt 详细描述: read() #一次性读取文本中全部的内容,以字符串的形式返回结果 readline() #只读取 ...
- 关于HashMap遍历,为什么要用entry
Map.entrySet() 这个方法返回的是一个Set<Map.Entry<K,V>>,Map.Entry 是Map中的一个接口,他的用途是表示一个映射项(里面有Key和Va ...