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 ...
随机推荐
- loj10173
炮兵阵地 司令部的将军们打算在 N×M 的网格地图上部署他们的炮兵部队.一个 N×M的地图由 N 行 M 列组成,地图的每一格可能是山地(用 H 表示),也可能是平原(用 P表示),如下图.在每一格平 ...
- SpringMvc获取getbean
import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; i ...
- Java 复习整理day04
在我们的日常生活中,方法可以理解为要做某件事情, 而采取的解决办法. 如:小明同学在路边准备坐车来学校学习.这就面临 着一件事情(坐车到学校这件事情)需要解决,解决办法 呢?可采用坐公交车或坐出租车的 ...
- springBoot之 spring-boot-starter-parent 引入详解
springBoot中引入 <parent> <groupId>org.springframework.boot</groupId> <artifactId& ...
- 2019牛客暑期多校训练营(第二场)E.MAZE(线段树+dp)
题意:给你一个n*m的矩阵 你只能向左向右相下走 有两种操作 q次询问 一种是把一个单位翻转(即可走变为不可走 不可走变为可走) 另一种是询问从(1,x) 走到 (n,y)有多少种方案 思路:题目n为 ...
- POJ 1743 Musical Theme【SAM】
POJ1743 Musical Theme 要找长度\(\ge 5\)且出现次数\(\ge 2\)并且第一次出现和最后一次出现不重叠的最长子串. 题目条件中,如果对于两个串,在一个串的每个数上都加上相 ...
- hdu 2089不要62 (数位dp)
Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer). 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来 ...
- Codeforces Round #575 (Div. 3) F. K-th Path
传送门 题意: 这道题把我看得懵懵的(不敢相信),其实就是给你n个点和m条边(无向图),你要找出来任意两点之间的的最短距离,然后再从其中找出来第k个最小值 题解: 正常思维就是floyd多源最短路算法 ...
- 3.PowerShell DSC核心概念
PowerShell DSC有三个核心概念 配置 配置是声明性的PowerShell 脚本,用于定义和配置资源实例. DSC 配置是幂等的. 资源 资源是 DSC 的"实现器"部分 ...
- VS2010的单元测试(一)
在VS2010中,单元测试的功能很强大,使得建立单元测试和编写单元测试代码,以及管理和运行单元测试都变得简单起来,通过私有访问器可以对私有方法也能进行单元测试,并且支持数据驱动的单元测试. 一.创建单 ...