nasm astrncmp函数 x86
xxx.asm:
%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16
section .text
global dllmain
export astrncmp
dllmain:
mov eax,1
ret 12
;------------------------------------------------;
; 比较最多两个字符串的指定字符数。
;------------------------------------------------;
astrncmp:
push ebp
mov ebp,esp
push ebx
mov ecx,[p1] ; const char *string1
mov eax,[p2] ; const char *string2
mov edx,[p3] ; size_t count
.for:
test edx,edx
jz .identical
mov bl,[ecx]
cmp bl,[eax]
jc .less
jne .greater
inc ecx
inc eax
dec edx
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:
pop ebx
mov esp,ebp
pop ebp
ret 12
c++:
#include <iostream>
#include <Windows.h>
typedef int (CALLBACK* astrncmp_t)(const char* string1, const char* string2, size_t count);
astrncmp_t astrncmp;
int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrncmp = (astrncmp_t)GetProcAddress(myDLL, "astrncmp");
printf("%d\n", strncmp( "a1", "a2", 0)); // 0
printf("%d\n", astrncmp("a1", "a2", 0)); // 0
printf("%d\n", strncmp( "a1", "a2", 1)); // 0
printf("%d\n", astrncmp("a1", "a2", 1)); // 0
printf("%d\n", strncmp( "a1", "a2", 2)); // -1
printf("%d\n", astrncmp("a1", "a2", 2)); // -1
return 0;
}
nasm astrncmp函数 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 ...
随机推荐
- Spring MVC—数据绑定机制,数据转换,数据格式化配置,数据校验
Spring MVC数据绑定机制 数据转换 Spring MVC处理JSON 数据格式化配置使用 数据校验 数据校验 Spring MVC数据绑定机制 Spring MVC解析JSON格式的数据: 步 ...
- 9. Linux用户身份和能力
root 拥有最高的系统所有权,能够管理系统的各项功能,如添加/删除用户.启动/关闭服务进程.开启/禁用硬件设备等.以root 管理员的身份工作时不会受到系统的限制 在Linux 系统中,UID 有唯 ...
- UML——构件图
宏观导图: 细节探究: 一.What 构件:是一个应用很广的名词,在建筑工程.机械工程.软件工程中等都有该概念.其实,说道底表达的都是一个意思.就像是标准化生产出来的零部件一样,具有可替换性.同质性, ...
- (5)U盘安装Linux系统
1.前期准备 使用 U 盘安装 Linux 系统,需要准备以下工具: 大容量的U盘(安装 CentOS 6.x 系统,U 盘容量至少 8 G): UltraISO 工具,用来制作 U 盘启动盘.除此之 ...
- 静态代理和jdk动态代理
要说动态代理,必须先聊聊静态代理. 静态代理 假设现在项目经理有一个需求:在项目现有所有类的方法前后打印日志. 你如何在不修改已有代码的前提下,完成这个需求? 我首先想到的是静态代理.具体做法是: 1 ...
- 深度解读.NET5 授权中间件执行策略
前文提要 2021.1月份我写了一个<这难道不是.NET5 的bug? 在线求锤?>, 讲述了我在实现[全局授权访问+特例匿名访问] 遇到的技术困惑: [特例匿名访问,还是走了认证流程]. ...
- TcaplusDB 10周年 风雨兼程破浪行 自研存储见成长
从找不到需求险些被叫停,到支撑亿级DAU的数据库行业标杆,腾讯云数据库TcaplusDB在风雨中走过了整整10年.辉映日月破风浪,十年一剑破九天.百万行代码就像淙淙流淌的数据溪流,终于在十年后汇成不可 ...
- Codeforces Round #626 Div2 D,E
比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...
- 2019牛客暑期多校训练营(第二场)E.MAZE(线段树+dp)
题意:给你一个n*m的矩阵 你只能向左向右相下走 有两种操作 q次询问 一种是把一个单位翻转(即可走变为不可走 不可走变为可走) 另一种是询问从(1,x) 走到 (n,y)有多少种方案 思路:题目n为 ...
- 洛谷 P2880 [USACO07JAN]Balanced Lineup G (ST表模板)
题意:给你一组数,询问\(q\)次,问所给区间内的最大值和最小值的差. 题解:经典RMQ问题,用st表维护两个数组分别记录最大值和最小值然后直接查询输出就好了 代码: int n,q; int a[N ...