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 ...
随机推荐
- LibreOJ #10047
应同机房某大佬的要求来写这篇题解 Description 给定一个字符串 \(S\) 和一个数 \(K\),要求求出 \(S\) 的所有形似 \(A+B+A\) 的子串数量,其中 \(\mid A\m ...
- loj10153二叉苹果树
有一棵二叉苹果树,如果数字有分叉,一定是分两叉,即没有只有一个儿子的节点.这棵树共 N 个节点,标号 1 至 N,树根编号一定为 1. 我们用一根树枝两端连接的节点编号描述一根树枝的位置.一棵有四根树 ...
- toggle() 隐藏和收缩
<!DOCTYPE html><html><head><script src="/jquery/jquery-1.11.1.min.js" ...
- 数据库备份和恢复---MariaDB
定义 数据备份:将源数据再次存储到新的位置 数据恢复:将备份好的数据重新应用到数据库系统 常见的备份类型: 按照是否备份整个数据集来分 完全备份:备份从开始到执行备份这一时刻的所有数据集 增量备份:备 ...
- cassandra权威指南读书笔记--性能调优
cassandra自带测试工具cassandra-stress.nodetool proxyhistograms可以在多个节点运行,发现最慢的协调节点.nodetool tablehistograms ...
- vulnhub靶机练习-Os-hackNos-1,超详细使用
第一次写自己总结的文章,之后也会有更新,目前还在初学阶段. 首先介绍一下靶机,靶机是 vulnhub Os-hackNos-1 简介: 难度容易到中, flag 两个 一个是普通用户的user.txt ...
- 安装python的selenium库和驱动
对于使用selenium来进行python爬虫操作可以简化好多操作,它实际上的运行就是通过打开一个浏览器来一步一步的按照你的代码来执行 如果安装过python编译器后应该pip工具也是有的,验证pyt ...
- Codeforces Round #646 (Div. 2) C. Game On Leaves (贪心,博弈)
题意:给你一棵树,每次可以去掉叶节点的一条边,Ayush先开始,每回合轮流来,问谁可以第一个把\(x\)点去掉. 题解:首先如果\(x\)的入度为\(1\),就可以直接拿掉,还需要特判一下入度为\(0 ...
- tkinter 实现爬虫的UI界面
使用python的内置模块tkinter编写了爬取51Ape网站(无损音乐的百度云链接)的UI界面 tkinter入门简单, 但同时在编写的过程中因为文档的缺少很不方便. 下面是UI界面模块的编写,由 ...
- Codeforces Round #515 (Div. 3) C. Books Queries (模拟)
题意:有一个一维的书架,\(L\)表示在最左端放一本书,\(R\)表示在最右端放一本书,\(?\)表示从左数或从右数,最少数多少次才能得到要找的书. 题解:我们开一个稍微大一点的数组,从它的中间开始模 ...