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 ...
随机推荐
- 扒一扒ELF文件
ELF文件(Executable Linkable Format)是一种文件存储格式.Linux下的目标文件和可执行文件都按照该格式进行存储,有必要做个总结. 目录 1. 链接举例 2. ELF文件类 ...
- NodeJS入门学习教程
一.概念 1.什么是nodejs Node.js是JavaScript 运行时环境,通俗易懂的讲,Node.js是JavaScript的运行平台 Node.js既不是语言,也不是框架,它是一个平台 2 ...
- 洛谷 P3704 SDOI2017 数字表格
题意: 给定两个整数 \(n, m\),求: \[\prod_{i = 1} ^ n \prod_{j = 1} ^ m \operatorname{Fib}_{\gcd\left(n, m\righ ...
- 最简单直接地理解Java软件设计原则之接口隔离原则
理论性知识 定义 接口隔离原则, Interface Segregation Principle,(ISP). 一个类对应一个类的依赖应该建立在最小的接口上: 建立单一接口,不要建立庞大臃肿的接口: ...
- Centos搭建spark
Centos搭建spark 一.spark介绍 二.spark安装前提 三.集群规划 四.spark安装 五.修改spark环境变量 六.修改spark-env.sh 七.修改slaves 八.将安装 ...
- (7)Linux使用注意事项
1.Linux 严格区分大小写 和 Windows 不同,Linux 是严格区分大小写的,包括文件名和目录名.命令.命令选项.配置文件设置选项等. 2.Windows 下的程序不能直接在 Linux ...
- Left join查询为空
这两个查询,上面查询返回空,下面能正常返回记录 两个表结构: left join 没有匹配上得到的b.dates,b.game_id和b.uid都是null值,在按b.dates=20200317 a ...
- C - C(换钱问题)
换钱问题: 给出n种钱,m个站点,现在有第 s种钱,身上有v 这么多: 下面 m行 站点有a,b两种钱,rab a->b的汇率,cab a-->b的手续费, 相反rba cba : 问在 ...
- HDU-6881 Tree Cutting (HDU多校D10T5 点分治)
HDU-6881 Tree Cutting 题意 \(n\) 个点的一棵树,要求删除尽量少的点,使得删点之后还是一棵树,并且直径不超过 \(k\),求删除点的数量 分析 补题之前的一些错误想法: 尝试 ...
- python+selenium+bs4爬取百度文库内文字 && selenium 元素可以定位到,但是无法点击问题 && pycharm多行缩进、左移
先说一下可能用到的一些python知识 一.python中使用的是unicode编码, 而日常文本使用各类编码如:gbk utf-8 等等所以使用python进行文字读写操作时候经常会出现各种错误, ...