nasm astrcmp函数 x86
xxx.asm:
%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16
section .text
global dllmain
export astrcmp
dllmain:
mov eax,1
ret 12
astrcmp:
push ebp
mov ebp,esp
push ebx
mov eax,[p1] ; char ptr 1
mov ecx,[p2] ; char ptr 2
.for:
mov dl,[eax]
mov bl,[ecx]
cmp dl,bl
jc .r1
jne .r3
test dl,bl
jz .r2
inc eax
inc ecx
jmp .for
;-----------------------------------------------------;
; <0 第一个不匹配的字符在ptr1中的值比在ptr2中的值低
;-----------------------------------------------------;
.r1:
xor eax,eax
not eax
jmp .return
;-----------------------------------------------------;
; 0 两个字符串的内容相等
;-----------------------------------------------------;
.r2:
xor eax,eax
jmp .return
;-----------------------------------------------------;
; >0 第一个不匹配的字符在ptr1中的值大于在ptr2中的值
;-----------------------------------------------------;
.r3:
mov eax,1
jmp .return
.return:
pop ebx
mov esp,ebp
pop ebp
ret 8
c++:
#include <iostream>
#include <Windows.h>
typedef int(CALLBACK* astrcmp_t)(const char* str1, const char* str2);
astrcmp_t astrcmp;
int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrcmp = (astrcmp_t)GetProcAddress(myDLL, "astrcmp");
printf("%x\n", astrcmp("12", "22")); // -1
printf("%x\n", astrcmp("12", "12")); // 0
printf("%x\n", astrcmp("22", "12")); // 1
return 0;
}
nasm astrcmp函数 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 ...
- Kafka Fetch Session剖析
1.概述 最近有同学留言在使用Kafka的过程中遇到一些问题,比如在拉取的Topic中的数据时会抛出一些异常,今天笔者就为大家来分享一下Kafka的Fetch流程. 2.内容 2.1 背景 首先,我们 ...
- ESRI,空间数据处理,WKT,GeoJson
ESRI,空间数据处理,WKT,GeoJson 一.WKT 二.GeoJson 三.WKT转GeoJson 四.GeoJson 转 WKT 一.WKT WKT(well-known text)是一种文 ...
- Django(orm)转
转载自 https://www.jianshu.com/p/d92ecd3644f7?utm_campaign=hugo&utm_medium=reader_share&utm_con ...
- 织梦dedecms用户注册时笔名去掉的方法
修改目的:用户注册时不用输入笔名,实现系统自动同步用户名和用户笔名. 负责织梦dedecms用户注册的php文件是member/reg_new.php ,不难发现,用户注册时的用户名$userid,和 ...
- hdu4460 Friend Chains(记忆化广度优先搜索)
题意: 任意两点间最短路中的最长距离. 思路: BFS遍历每个点能到达的最远距离. Tips: vector的clear要与resize联用. #include <bits/stdc++.h&g ...
- hdu3565 Bi-peak Number (有上界和下界的数位dp)
Problem Description A peak number is defined as continuous digits {D0, D1 - Dn-1} (D0 > 0 and n & ...
- Who Gets the Most Candies?
Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 11303 Accepted: 3520 Case Time Limit ...
- Bubble Cup 13 - Finals [Online Mirror, unrated, Div. 1] K. Lonely Numbers (数学)
题意:定义两个数\(a,b\)是朋友,如果:\(gcd(a,b)\),\(\frac{a}{gcd(a,b)}\),\(\frac{b}{gcd(a,b)}\)能构成三角形,现在给你一个正整数\(n\ ...
- Codeforces Round #643 (Div. 2) C. Count Triangles (数学公式)
题意:给你四个正整数\(A,B,C,D\),且\(A\le B\le C \le D\),有\(A\le x\le B\le y\le C \le z\le D\),求最多有多少组\((x,y,z)\ ...