diff --git a/archetypes/posts.md b/archetypes/posts.md new file mode 100644 index 0000000..8c41340 --- /dev/null +++ b/archetypes/posts.md @@ -0,0 +1,8 @@ +--- +title: "{{ replace .Name "-" " " | title }}" +date: {{ .Date }} +draft: true +toc: true +images: +tags: [untagged] +--- \ No newline at end of file diff --git a/config.toml b/config.toml index 2c9eb9a..9fcd112 100644 --- a/config.toml +++ b/config.toml @@ -13,11 +13,14 @@ enableEmoji = true # Shorthand emojis in content files - https://gohugo.io/func # googleAnalytics = "UA-123-45" # disqusShortname = "yourdiscussshortname" +[permalinks] + # posts = "/:year/:month/:title/" + [author] name = "lniwn" [blackfriday] - # hrefTargetBlank = true + hrefTargetBlank = true # noreferrerLinks = true # nofollowLinks = true @@ -30,7 +33,7 @@ enableEmoji = true # Shorthand emojis in content files - https://gohugo.io/func dateform = "Jan 2, 2006" dateformShort = "Jan 2" dateformNum = "2006-01-02" - dateformNumTime = "2006-01-02 15:04 -0700" + dateformNumTime = "2006-01-02 15:04" # Metadata mostly used in document's head # description = "" @@ -69,21 +72,21 @@ enableEmoji = true # Shorthand emojis in content files - https://gohugo.io/func [menu] [[menu.main]] - name = "Posts" + name = "文章" url = "posts/" weight = 1 [[menu.main]] - name = "Categories" + name = "分类" url = "categories/" weight = 2 [[menu.main]] - name = "Tags" + name = "标签" url = "tags/" weight = 3 [[menu.main]] - name = "About" + name = "关于" url = "about/" weight = 4 diff --git a/content/about.md b/content/about.md index b188b2a..1d4adfd 100644 --- a/content/about.md +++ b/content/about.md @@ -1,17 +1,7 @@ +++ -title = "About Hugo" -date = "2014-04-09" +title = "关于" +date = "2019-07-26" +++ -Hugo is the **world’s fastest framework for building websites**. It is written in Go. - -It makes use of a variety of open source projects including: - -* https://github.com/russross/blackfriday -* https://github.com/alecthomas/chroma -* https://github.com/muesli/smartcrop -* https://github.com/spf13/cobra -* https://github.com/spf13/viper - -Learn more and contribute on [GitHub](https://github.com/gohugoio). +此处应该有文字 diff --git a/content/posts/2017/CMake学习笔记/CMake-Projects.png b/content/posts/2017/CMake学习笔记/CMake-Projects.png new file mode 100644 index 0000000..e177871 Binary files /dev/null and b/content/posts/2017/CMake学习笔记/CMake-Projects.png differ diff --git a/content/posts/2017/CMake学习笔记/VS-to-CMake-Mapping.png b/content/posts/2017/CMake学习笔记/VS-to-CMake-Mapping.png new file mode 100644 index 0000000..308ac6a Binary files /dev/null and b/content/posts/2017/CMake学习笔记/VS-to-CMake-Mapping.png differ diff --git a/content/posts/CMake学习笔记.md b/content/posts/2017/CMake学习笔记/index.md similarity index 97% rename from content/posts/CMake学习笔记.md rename to content/posts/2017/CMake学习笔记/index.md index acb6e4d..c9a2f91 100644 --- a/content/posts/CMake学习笔记.md +++ b/content/posts/2017/CMake学习笔记/index.md @@ -7,7 +7,7 @@ categories: cmake 本文主要记录CMake学习过程的一些笔记。 - + ## 基本文件结构 编写CMakeLists.txt @@ -51,8 +51,8 @@ add_executable(Demo ${DIR_SRCS}) ### 编译选项命令 - Visual Studio to CMake Mapping - {% asset_img VS-to-CMake-Mapping.png VS-to-CMake-Mapping %} - {% asset_img CMake-Projects.png CMake-Projects %} + ![VS-to-CMake-Mapping](VS-to-CMake-Mapping.png) + ![CMake-Projects](CMake-Projects.png) > ZERO_CHECK will rerun cmake. You can/should execute this after changing something on your CMake files. > ALL_BUILD is simply a target which builds all and everything project in the active solution, I guess one can compare it to "make all". > 可以通过`set(CMAKE_SUPPRESS_REGENERATION true)`不生成`ZERO_CHECK`工程。 diff --git a/content/posts/CMake项目添加预编译头.md b/content/posts/2017/CMake项目添加预编译头.md similarity index 94% rename from content/posts/CMake项目添加预编译头.md rename to content/posts/2017/CMake项目添加预编译头.md index db37971..bfb9abf 100644 --- a/content/posts/CMake项目添加预编译头.md +++ b/content/posts/2017/CMake项目添加预编译头.md @@ -2,13 +2,12 @@ title: CMake项目添加预编译头 date: 2017-12-28 11:46:13 +08:00 tags: [cmake, visual studio] -images: ["apple-touch-icon.png"] categories: cmake --- 本文主要记录为CMake项目添加预编译头支持,以及过程中遇到的坑,比如`set_target_properties`连续调用两次失效的问题。 - + 各个编译器支持预编译头指令不同,这里仅以Visual Studio为例进行说明。 @@ -61,17 +60,13 @@ use_precompiled_header(${PROJECT_NAME} 在`PrecompiledHeader.cmake`文件中,最开始使用了如下的代码 -{% note danger %} - -{% codeblock lang:cmake %} +```cmake if (MSVC AND NOT NMAKE AND NOT OGRE_UNITY_BUILD) set_target_properties(${TARGET} PROPERTIES COMPILE_FLAGS /Yu"${HEADER}") set_target_properties(${TARGET} PROPERTIES COMPILE_FLAGS /FI"${HEADER}") set_source_files_properties(${SRC_FILE} PPROPERTIES COMPILE_FLAGS /Yc"${HEADER}" ) -{% endcodeblock %} - -{% endnote %} +``` 可是发现永远只有/FI生效,后来查找了大量资料,替换为了`set_property APPEND`的形式,才最终解决。 \ No newline at end of file diff --git a/content/posts/Cef-Bug-Fix-List.md b/content/posts/2017/Cef-Bug-Fix-List.md similarity index 99% rename from content/posts/Cef-Bug-Fix-List.md rename to content/posts/2017/Cef-Bug-Fix-List.md index 722ed5b..18c6c36 100644 --- a/content/posts/Cef-Bug-Fix-List.md +++ b/content/posts/2017/Cef-Bug-Fix-List.md @@ -7,7 +7,7 @@ categories: cplusplus 本文主要记录在cef开发过程中发现的bug及解决方法。 - + ## 解决CEF中html页面不显示鼠标tips的bug diff --git a/content/posts/一句话Windows.md b/content/posts/2017/一句话Windows.md similarity index 99% rename from content/posts/一句话Windows.md rename to content/posts/2017/一句话Windows.md index 751862e..d204659 100644 --- a/content/posts/一句话Windows.md +++ b/content/posts/2017/一句话Windows.md @@ -7,7 +7,7 @@ categories: windows 本文主要记录windows开发中遇到的一句话技巧和知识点。 - + --- ## 为VC++ 2008添加application compatibility段 diff --git a/content/posts/为Hexo博客Next主题添加Schnack评论.md b/content/posts/2017/为Hexo博客Next主题添加Schnack评论.md similarity index 98% rename from content/posts/为Hexo博客Next主题添加Schnack评论.md rename to content/posts/2017/为Hexo博客Next主题添加Schnack评论.md index cec325f..0a4dac6 100644 --- a/content/posts/为Hexo博客Next主题添加Schnack评论.md +++ b/content/posts/2017/为Hexo博客Next主题添加Schnack评论.md @@ -5,7 +5,7 @@ tags: [vps, hexo] categories: vps --- 本文主要记录schnack评论搭建步骤(服务端搭建未完成)。 - + > **Step 1** diff --git a/content/posts/为Hexo博客Next主题添加Wildfire评论系统.md b/content/posts/2017/为Hexo博客Next主题添加Wildfire评论系统.md similarity index 85% rename from content/posts/为Hexo博客Next主题添加Wildfire评论系统.md rename to content/posts/2017/为Hexo博客Next主题添加Wildfire评论系统.md index 00104aa..a62e749 100644 --- a/content/posts/为Hexo博客Next主题添加Wildfire评论系统.md +++ b/content/posts/2017/为Hexo博客Next主题添加Wildfire评论系统.md @@ -7,15 +7,15 @@ categories: vps 本文主要记录[Wildfire](https://github.com/cheng-kang/wildfire)评论系统搭建的过程。 - + ## Hexo配置步骤 -{% note primary %} Step 1 {% endnote %} +### Step 1 -关于wildfire的设置,请直接参考{% link 官方帮助文档 https://wildfire.js.org/#/zh-cn/usage?id=%e4%bd%bf%e7%94%a8%e8%af%b4%e6%98%8e %}。 +关于wildfire的设置,请直接参考[官方帮助文档](https://wildfire.js.org/#/zh-cn/usage?id=%e4%bd%bf%e7%94%a8%e8%af%b4%e6%98%8e)。 -{% note primary %} Step 2 {% endnote %} +### Step 2 在`%BLOG_PATH%\themes\next\layout\_third-party\comments`路径下创建`wildfire.swig`文件 @@ -44,14 +44,14 @@ categories: vps {% endif %} ``` -{% note primary %} Step 3 {% endnote %} +### Step 3 -在{% quote %}%BLOG_PATH%\themes\next\layout\_third-party\comments\index.swig{% endquote %}文件中添加wildfire.swig的引用: -{% code lang:swig %} +在`%BLOG_PATH%\themes\next\layout\_third-party\comments\index.swig`文件中添加wildfire.swig的引用: +```swig {% raw %}{% include 'wildfire.swig' %}{% endraw %} -{% endcode%} +``` -{% note primary %} Step 4 {% endnote %} +### Step 4 在`%BLOG_PATH%\themes\next\layout\_partials\comments.swig`文件中,添加一个elseif代码块: diff --git a/content/posts/在vps上搭建hexo.md b/content/posts/2017/在vps上搭建hexo.md similarity index 94% rename from content/posts/在vps上搭建hexo.md rename to content/posts/2017/在vps上搭建hexo.md index 15cd87d..6daa09f 100644 --- a/content/posts/在vps上搭建hexo.md +++ b/content/posts/2017/在vps上搭建hexo.md @@ -7,7 +7,7 @@ categories: vps 本文记录在[vps](https://www.vultr.com/?ref=7276933)上搭建hexo的过程。 - + 在vps上搭建hexo,网络上已经有不少教程了,但是全部套路都是一样,大致流程如下: @@ -20,7 +20,7 @@ categories: vps 在远程仓库的hooks目录,创建post-receive文件,在这里进行hexo的渲染和部署: ```shell -#! /bin/bash +#!/bin/bash git --work-tree=/home/lniwn/hexo/source/ --git-dir=/home/git/repo/blog.git/ checkout -f hexo --cwd /home/lniwn/hexo/ clean @@ -29,7 +29,6 @@ cp -Rf /home/lniwnxxx/hexo/public/* /var/www/oaoa.me/ ``` 这样可以在任何地方编写md文件,写完之后通过git提交即可看到自动部署的信息 -{% asset_img TortoiseGit-message.png TortoiseGit打印的远程部署信息 %} 由于我创建了一个git用户,仅用于git相关操作,而我的登陆用户是lniwn,部署时经常会遇到权限问题,所以需要进行一些权限分配: @@ -40,7 +39,7 @@ cp -Rf /home/lniwnxxx/hexo/public/* /var/www/oaoa.me/ 虽然每次git的push操作都会触发post-receive,从而进行自动部署,但是有时候还是希望手动部署下,所以写了个部署脚本auto-deploy-hexo,脚本很简单,就是以git用户执行post-receive文件: ```shell -#! /bin/bash +#!/bin/bash sudo -H -u git bash -c '/home/git/repo/blog.git/hooks/post-receive' ``` \ No newline at end of file diff --git a/content/posts/注释大全.md b/content/posts/2017/注释大全.md similarity index 99% rename from content/posts/注释大全.md rename to content/posts/2017/注释大全.md index b209d01..27e8c30 100644 --- a/content/posts/注释大全.md +++ b/content/posts/2017/注释大全.md @@ -7,7 +7,7 @@ categories: daily 各种神奇注释,顺便推荐个在线生成ascii码注释的网站。 - + ## 佛祖保佑 diff --git a/content/posts/Python模块timezone学习笔记.md b/content/posts/2018/Python模块timezone学习笔记.md similarity index 99% rename from content/posts/Python模块timezone学习笔记.md rename to content/posts/2018/Python模块timezone学习笔记.md index 8ff7832..83f0424 100644 --- a/content/posts/Python模块timezone学习笔记.md +++ b/content/posts/2018/Python模块timezone学习笔记.md @@ -5,7 +5,7 @@ tags: [python] categories: python --- 本文基于python3,记录了datetime包中的timezone用法。 - + 使用第三方扩展包pytz,构造指定时区。 diff --git a/content/posts/SQLAlchemy学习笔记.md b/content/posts/2018/SQLAlchemy学习笔记.md similarity index 99% rename from content/posts/SQLAlchemy学习笔记.md rename to content/posts/2018/SQLAlchemy学习笔记.md index 6dc8b22..c35809f 100644 --- a/content/posts/SQLAlchemy学习笔记.md +++ b/content/posts/2018/SQLAlchemy学习笔记.md @@ -7,7 +7,7 @@ categories: python 本文记录SQLAlchemy学习及使用笔记。 - + - **如何替换一个已有主键的记录?** diff --git a/content/posts/Vim快捷键备忘录.md b/content/posts/2018/Vim快捷键备忘录/index.md similarity index 96% rename from content/posts/Vim快捷键备忘录.md rename to content/posts/2018/Vim快捷键备忘录/index.md index 1d7effb..9eb4449 100644 --- a/content/posts/Vim快捷键备忘录.md +++ b/content/posts/2018/Vim快捷键备忘录/index.md @@ -5,7 +5,7 @@ tags: [vim] categories: daily --- Vim快捷键查询。 - + ## 光标移动 @@ -131,5 +131,5 @@ Vim快捷键查询。 ## 在线文档 - [VIM QUICK REFERENCE CARD](http://tnerual.eriogerg.free.fr/vimqrc.pdf) -- {% asset_img morden1.png 增强版 %} -- {% asset_img text1.png 文字版 %} +- ![增强版](morden1.png) +- ![文字版](text1.png) diff --git a/content/posts/2018/Vim快捷键备忘录/morden1.png b/content/posts/2018/Vim快捷键备忘录/morden1.png new file mode 100644 index 0000000..955962a Binary files /dev/null and b/content/posts/2018/Vim快捷键备忘录/morden1.png differ diff --git a/content/posts/2018/Vim快捷键备忘录/text1.png b/content/posts/2018/Vim快捷键备忘录/text1.png new file mode 100644 index 0000000..98be313 Binary files /dev/null and b/content/posts/2018/Vim快捷键备忘录/text1.png differ diff --git a/content/posts/2018/Win32汇编学习.md b/content/posts/2018/Win32汇编学习.md new file mode 100644 index 0000000..54800e1 --- /dev/null +++ b/content/posts/2018/Win32汇编学习.md @@ -0,0 +1,572 @@ +--- +title: Win32汇编学习 +date: 2018-02-12 17:48:00 +tags: [win32, 汇编] +categories: windows +--- + +本文记录了C函数调用过程,以及常用的汇编函数指令集。 + + + +## 函数调用过程 + +栈帧,即stack frame,其本质就是一种栈,只是这种栈专门用于保存函数调用过程中的各种信息,栈帧有栈顶(TOS)和栈底之分,其中栈顶的地址最低,栈底的地址最高,增长方向为高地址向低地址方向。在x86-32bit中,用esp(extended stack pointer)一直指向栈顶,ebp(extended base pointer)指向栈底。 + +![栈帧方向](stackframe.png) + +一般来说,ebp和esp之间的区域叫做栈帧,每调用一个函数,就会生成一个新的栈帧。在函数调用过程中,我们将调用函数称为“调用者(caller)”,将被调用的函数称为“被调用者(callee)”。 + +函数调用过程如下: + +```asm +push ebp ; 保存ebp的值 +mov ebp,esp ; 将esp的值赋给ebp,使新的ebp指向栈顶 +sub esp,0d8h ; 分配额外的空间给局部变量,对于大内存,使用call __alloca_probe (010FD4EAh) 的方式来分配 +``` + +windows平台,返回值保存在eax中。 + +## x86汇编指令 + +### 寄存器 + +![x86寄存器](x86-registers.png) + +X86处理器中有8个32位的通用寄存器。由于历史的原因,EAX通常用于计算,ECX通常用于循环变量计数。ESP和EBP有专门用途,ESP指示栈指针(用于指示栈顶位置),而EBP则是基址指针(用于指示子程序或函数调用的基址指针)。如图中所示,EAX、EBX、ECX和EDX的前两个高位字节和后两个低位字节可以独立使用,其中两位低字节又被独立分为H和L部分,这样做的原因主要是考虑兼容16位的程序,具体兼容匹配细节请查阅相关文献。 + +应用寄存器时,其名称大小写是不敏感的,如EAX和eax没有区别。 + +### 内存和寻址模式 + +#### 声明静态数据区 + +可以在X86汇编语言中用汇编指令.DATA声明静态数据区(类似于全局变量),数据以单字节、双字节、或双字(4字节)的方式存放,分别用DB,DW, DD指令表示声明内存的长度。在汇编语言中,相邻定义的标签在内存中是连续存放的。 + +| .DATA | | | +| ----- | -------- | ------------------------------------- | +| var | DB 64 | ;声明一个字节,并将数值64放入此字节中 | +| var2 | DB ? | ; 声明一个未初始化的字节. | +| | DB 10 | ; 声明一个没有label的字节,其值为10. | +| X | DW ? | ; 声明一个双字节,未初始化. | +| Y | DD 30000 | ; 声明一个4字节,其值为30000. | + +还可以声明连续的数据和数组,声明数组时使用DUP关键字。 + +| .DATA | | | +| ----- | ------------- | ------------------------------------------------------------ | +| Z | DD 1, 2, 3 | ; Declare three 4-byte values, initialized to 1, 2, and 3. The value of location Z + 8 will be 3. | +| bytes | DB 10 DUP(?) | ; Declare 10 uninitialized bytes starting at location *bytes*. | +| arr | DD 100 DUP(0) | ; Declare 100 4-byte words starting at location arr, all initialized to 0 | +| str | DB 'hello',0 | ; Declare 6 bytes starting at the address str, initialized to the ASCII character values for hello and the null (0) byte. | + +#### 寻址模式 + +现代X86处理器具有232字节的寻址空间。在上面的例子中,我们用标签(label)表示内存区域,这些标签在实际汇编时,均被32位的实际地址代替。除了支持这种直接的内存区域描述,X86还提供了一种灵活的内存寻址方式,即利用最多两个32位的寄存器和一个32位的有符号常数相加计算一个内存地址,其中一个寄存器可以左移1、2或3位以表述更大的空间。下面例子是汇编程序中常见的方式。 + +| 指令 | 说明 | +| -------------------- | ----------------------------------------------- | +| mov eax, [ebx] | ; 将ebx值指示的内存地址中的4个字节传送到eax中 | +| mov [var], ebx | ; 将ebx的内容传送到var的值指示的内存地址中. | +| mov eax, [esi-4] | ; 将esi-4值指示的内存地址中的4个字节传送到eax中 | +| mov [esi+eax], cl | ; 将cl的值传送到esi+eax的值指示的内存地址中 | +| mov edx, [esi+4*ebx] | ; 将esi+4*ebx值指示的内存中的4个字节传送到edx | + +#### 长度规定 + +在声明内存大小时,在汇编语言中,一般用DB,DW,DD均可声明的内存空间大小,这种现实声明能够很好地指导汇编器分配内存空间,但是,对于`mov [ebx], 2`,如果没有特殊的标识,则不确定常数2是单字节、双字节,还是双字。对于这种情况,X86提供了三个指示规则标记,分别为`BYTE PTR`, `WORD PTR`, and `DWORD PTR`,如上面例子写成:`mov BYTE PTR [ebx], 2`, `mov WORD PTR [ebx], 2`, `mov DWORD PTR [ebx], 2`,则意思非常清晰。 + +### 汇编指令 + +汇编指令通常可以分为数据传送指令、逻辑计算指令和控制流指令。本节将讲述其中最重要的指令,以下标记分别表示寄存器、内存和常数。 + +| 标识 | 描述 | +| ------- | --------------------------------------------------------- | +| | 32位寄存器 (EAX, EBX, ECX, EDX, ESI, EDI, ESP, or EBP) | +| | 16位寄存器 (AX, BX, CX, or DX) | +| | 8位寄存器(AH, BH, CH, DH, AL, BL, CL, or DL) | +| | 任何寄存器 | +| | 内存地址 (e.g., [eax], [var + 4], or dword ptr [eax+ebx]) | +| | 32为常数 | +| | 16位常数 | +| | 8位常数 | +| | 任何8位、16位或32位常数 | + +#### 数据传送指令 + +- **mov** — Move (Opcodes: 88, 89, 8A, 8B, 8C, 8E, ...) + +mov指令将第二个操作数(可以是寄存器的内容、内存中的内容或值)复制到第一个操作数(寄存器或内存)。mov不能用于直接从内存复制到内存,其语法如下所示: + +``` asm +mov , +mov , +mov , +mov , +mov , +``` + +*Examples* +`mov eax, ebx — 将ebx的值拷贝到eax` +`mov byte ptr [var], 5 — 将5保存找var指示内存中的一个字节中` + +- **push**— Push stack (Opcodes: FF, 89, 8A, 8B, 8C, 8E, ...) + +push指令将操作数压入内存的栈中,栈是程序设计中一种非常重要的数据结构,其主要用于函数调用过程中,其中ESP只是栈顶。在压栈前,首先将ESP值减4(X86栈增长方向与内存地址编号增长方向相反),然后将操作数内容压入ESP指示的位置。其语法如下所示: + +```asm +push +push +push +``` + +*Examples* +`push eax — 将eax内容压栈` +`push [var] — 将var指示的4直接内容压栈` + +- **pop**— Pop stack + +pop指令与push指令相反,它执行的是出栈的工作。它首先将ESP指示的地址中的内容出栈,然后将ESP值加4. 其语法如下所示: + +```asm +pop +pop +``` + +*Examples* +`pop edi — pop the top element of the stack into EDI.` +`pop [ebx] — pop the top element of the stack into memory at the four bytes starting at location EBX.` + +- **lea**— Load effective address + + lea实际上是一个载入有效地址指令,将第二个操作数表示的地址载入到第一个操作数(寄存器)中。其语法如下所示: + +*Syntax* +`lea ,` + +*Examples* +`lea eax, [var] — var指示的地址载入eax中.` +`lea edi, [ebx+4*esi] — ebx+4*esi表示的地址载入到edi中,这实际是上面所说的寻址模式的一种表示方式.` + +#### 算术和逻辑指令 + +- **add**— Integer Addition + +add指令将两个操作数相加,且将相加后的结果保存到第一个操作数中。其语法如下所示: + +```asm +add , +add , +add , +add , +add , +``` + +*Examples* +`add eax, 10 — EAX ← EAX + 10` +`add BYTE PTR [var], 10 — 10与var指示的内存中的一个byte的值相加,并将结果保存在var指示的内存中` + +- **sub**— Integer Subtraction + +sub指令指示第一个操作数减去第二个操作数,并将相减后的值保存在第一个操作数,其语法如下所示: + +```asm +sub , +sub , +sub , +sub , +sub , +``` + +*Examples* +`sub al, ah — AL ← AL - AH` +`sub eax, 216 — eax中的值减26,并将计算值保存在eax中` + +- **inc, dec**— Increment, Decrement + +inc,dec分别表示将操作数自加1,自减1,其语法如下所示: + +```asm +inc +inc +dec +dec +``` + +*Examples* +`dec eax — eax中的值自减1.` +`inc DWORD PTR [var] — *var指示内存中的一个4-byte值自加1`* + +- **imul**— Integer Multiplication + +整数相乘指令,它有两种指令格式,一种为两个操作数,将两个操作数的值相乘,并将结果保存在第一个操作数中,第一个操作数必须为寄存器;第二种格式为三个操作数,其语义为:将第二个和第三个操作数相乘,并将结果保存在第一个操作数中,第一个操作数必须为寄存器。其语法如下所示: + +```asm +imul , +imul , +imul ,, +imul ,, +``` + +*Examples* + +`imul eax, [var] — eax→ eax * [var]` + +`imul esi, edi, 25 — ESI → EDI * 25` + +- **idiv**— Integer Division + +idiv指令完成整数除法操作,idiv只有一个操作数,此操作数为除数,而被除数则为EDX:EAX中的内容(一个64位的整数),操作的结果有两部分:商和余数,其中商放在eax寄存器中,而余数则放在edx寄存器中。其语法如下所示: + +*Syntax* +`idiv ` +`idiv ` + +*Examples* + +`idiv ebx` + +`idiv DWORD PTR [var]` + +- **and, or, xor**— Bitwise logical and, or and exclusive or + +逻辑与、逻辑或、逻辑异或操作指令,用于操作数的位操作,操作结果放在第一个操作数中。其语法如下所示: + +```asm +and , +and , +and , +and , +and , +or , +or , +or , +or , +or , +xor , +xor , +xor , +xor , +xor , +``` + +*Examples* +`and eax, 0fH — 将eax中的钱28位全部置为0,最后4位保持不变.` +`xor edx, edx — 设置edx中的内容为0.` + +- **not**— Bitwise Logical Not + +位翻转指令,将操作数中的每一位翻转,即0->1, 1->0。其语法如下所示: + +`not ` +`not ` + +*Example* +`not BYTE PTR [var] — *将var指示的一个字节中的所有位翻转*.` + +- **neg**— Negate + +取负指令。语法为: + +`neg ` +`neg ` + +*Example* +`neg eax — EAX → - EAX` + +- **shl, shr**— Shift Left, Shift Right + +位移指令,有两个操作数,第一个操作数表示被操作数,第二个操作数指示位移的数量。其语法如下所示: + +```asm +shl , +shl , +shl , +shl , +shr , +shr , +shr , +shr , + +``` + +*Examples* + +`shl eax, 1 — Multiply the value of EAX by 2 (if the most significant bit is 0),左移1位,相当于乘以2` + +`shr ebx, cl — Store in EBX the floor of result of dividing the value of EBX by 2*n* where *n* is the value in CL.` + +#### 控制转移指令 + +X86处理器维持着一个指示当前执行指令的指令指针(IP),当一条指令执行后,此指针自动指向下一条指令。IP寄存器不能直接操作,但是可以用控制流指令更新。 + +> ``` +> mov esi, [ebp+8] +> begin: xor ecx, ecx +> mov eax, [esi] +> +> ``` + +如第二条指令用begin指示,这种标签的方法在某种程度上简化了汇编程序设计,控制流指令通过标签实现程序指令跳转。 + +- **jmp** — Jump + +控制转移到label所指示的地址,(从label中取出执行执行),如下所示: + +`jmp