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 ...
随机推荐
- Hyper-v安装centos后的网络配置
修改配置文件 进入目录:cd /etc/sysconfig/network-scripts/ 修改ifcfg-eth0文件(不通机器文件名可能不同,可以通过 ip addr 命令查看网卡名) HWAD ...
- flutter--Dart基础语法(一)
一.前言 Flutter 是 Google 开源的 UI 工具包,帮助开发者通过一套代码库高效构建多平台精美应用,Flutter 开源.免费,拥有宽松的开源协议,支持移动.Web.桌面和嵌入式平台. ...
- Calendar 日期判断 等于 。小于。大于
public static void main(String[] args) throws Exception { String startTime = "2012-12-12 12:45: ...
- libuv事件循环
目录 1.说明 2.数据类型 2.1.uv_loop_t 2.2.uv_walk_cb 3.API 3.1.uv_loop_init 3.2.uv_loop_configure 3.3.uv_loop ...
- CPU中的程序是怎么运行起来的
总述 最近一位朋友问我,开发的代码是怎么在芯片运行起来的,我就开始给他介绍代码的预编译.汇编.编译.链接然后到一般的文件属性,再到代码运行.但是大佬问了我一句,CPU到底是怎么执行到每一个逻辑的,就讲 ...
- c++中几种swap
在c与c++中,有多种办法可以通过函数交换传入的两数的值,但有容易有一些问题产生,因而本文将几种交换方式及容易出错的点进行了分类. 1.传引用这是c++中最常见方式如下: int swap1 (int ...
- 2019牛客多校 Round3
Solved:3 Rank:105 治哥出题了 我感动哭了 A Graph Game (分块) 题意:1e5个点 2e5条边 s(x)表示与x点直接相邻的点集合 有两种操作 1种将按输入顺序的边第l条 ...
- hdu3341Lost's revenge (AC自动机+变进制dp)
Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submissio ...
- JSR-303 实现参数校验
参考 1. 什么是JSR-303 JSR-303 是 JAVA EE 6 中的一项子规范,叫做 Bean Validation,官方参考实现是Hibernate Validator. 此实现与 Hib ...
- 一篇文章搞懂G1收集器
一.何为G1收集器 The Garbage-First (G1) garbage collector is a server-style garbage collector, targeted for ...