NASM Syntax
NASM has a simplified syntax designed to let the user code with minimum overhead. In its simplest form, a NASM program needs nothing more than the assembly-language instructions; no assembler directives are necessary. NASM also makes some improvements to the Intel instruction syntax, removing ambiguity and improving consistency. The overall goal is to allow the user, as far as possible, to predict the machine-level opcode of each instruction without referring to the surrounding labels, directives, or instructions.
Like most assemblers, NASM supports the standard four-part source line:
label: instruction operands ;comment
The following pseudo-instructions cause the assembler to emit data into the output stream:
- DB – Write bytes (8 bits)
- DW – Write words (16 bits)
- DD – Write double words (32 bits)
- DQ – Write 64-bit floating-point constant
- DT – Write 80-bit floating-point constant
- INCBIN – Write the data found in the specified binary data file
These pseudo-instructions cause the assembler to reserve space in the uninitialized data section:
- RESB - Reserve bytes (8 bits)
- RESW – Reserve words (16 bits)
- RESD – Reserve double words (32 bits)
- RESQ – Reserve space for 64-bit floating-point constants
- REST – Reserve space for 80-bit floating-point constants
NASM supports the EQU pseudo-instruction, which allows the user to create names for numeric constants.
Finally, NASM offers the TIMES prefix for all instructions and pseudo-instructions. The TIMES prefix causes NASM to repeat the associated instruction a specified number of times.
Any NASM instruction or pseudo-instruction may have a corresponding label. In NASM, labels are numeric constants equal to the instruction's location in memory. They are virtually identical to constants defined with EQU, and may be used in the same way. This is a key difference from other assemblers, where labels contain additional information about the type of the pointed-to data. By treating labels as simple numeric constants, NASM vastly simplifies its instruction syntax, as discussed in the next section.
NASM also supports a local-label mechanism. This system prevents naming conflicts by allowing labels of the same name to exist in different contexts. Label names beginning with a dot (.) become "local" to the last non-local label NASM sees. The label remains valid until the next non-local label comes along, at which point NASM resets the list of local labels. This allows the user to re-use short label names such as ".else" or ".loop" in multiple places without naming conflicts.
To support macros, NASM supports a third kind of label beginning with "..@". These labels have non-local scope, but do not reset the list of local labels.
NASM has a simple rule for dealing with memory addressing in instructions: Everything in square brackets is a reference to a memory address, while everything outside of square brackets is a constant. For example:
data: dd 1234
mov ebx, data
mov eax, [data]
When this code finishes executing, the register ebx will contain the memory address of the data, while eax will contain the contents of that memory address, namely the number 1234. This is different from other assemblers such as MASM, where the first instruction might act like the second instruction depending on the type of label. NASM's syntax is much more consistent in this regard.
See [http://www.tortall.net/projects/yasm/manual/html/nasm.html Part I, NASM Syntax] of the Yasm User Manual. It's also available in PDF, see Yasm documentation.
SRC=https://github.com/yasm/yasm/wiki/NasmSyntax
NASM Syntax的更多相关文章
- GAS Syntax
GAS or GNU as syntax is a different form of syntax for assembly language files, known also as AT& ...
- asm 32 /64
我使用NASM编写的,运行在32位windows和linux主机上,但后来需求增加了,需要在64位windows和linux上运行,windows自身有个wow(windows on windows) ...
- Yasm 1.3.0 Release Notes
Yasm 1.3.0 Release Notes http://yasm.tortall.net/releases/Release1.3.0.html Target Audience Welcome ...
- bsdasm
bsdasm 来源 http://www.int80h.org/bsdasm/ Preface by G. Adam StanislavWhiz Kid Technomagic Assembly la ...
- YASM User Manual
This document is the user manual for the Yasm assembler. It is intended as both an introduction and ...
- NASM mode for Emacs
NASM mode for Emacs Quick post for those Emacs users out there. The common assembler used on GNU ...
- 如何在Open Live Writer(OLW)中使用precode代码高亮Syntax Highlighter
早先Microsotf的Windows Live Writer(WLW)现在已经开源了,并且更名为Open Live Writer,但是现在Windows Live Writer还是可以现在,Open ...
- Linix登录报"/etc/profile: line 11: syntax error near unexpected token `$'{\r''"
同事反馈他在一测试服务器(CentOS Linux release 7.2.1511)上修改了/etc/profile文件后,使用source命令不能生效,让我帮忙看看,结果使用SecureCRT一登 ...
- 获取文件的缩略图Thumbnail和通过 AQS - Advanced Query Syntax 搜索本地文件
演示如何获取文件的缩略图 FileSystem/ThumbnailAccess.xaml <Page x:Class="XamlDemo.FileSystem.ThumbnailAcc ...
随机推荐
- hdp spark beeline
thriftserver端口号10016 hdp所用端口号由10000改为10016 !connect jdbc:hive2://localhost:10016
- 在Vue单页面应用中使用Promise链式调用
eg: this.commonLoginFun().then((res) => { if (res.errNo === 0) { const { isLogin } = res.data; if ...
- UVa10397_Connect the Campus(最小生成树)(小白书图论专题)
解题报告 题目传送门 题意: 使得学校网络互通的最小花费,一些楼的线路已经有了. 思路: 存在的线路当然全都利用那样花费肯定最小,把存在的线路当成花费0,求最小生成树 #include <ios ...
- JAVASE学习笔记:第十章 SWing经常使用控件类(二)
7.JComboBox 下拉列表 /* * 初始化下拉列表 */ public void addcomb(){ String[] area = {"山西省&qu ...
- Qt之界面换肤
简述 常用的软件基本都有换肤功能,例如:QQ.360.迅雷等.换肤其实很简单,并没有想象中那么难,利用前面分享过的QSS系列文章,沃我们完全可以实现各种样式的定制! 简述 实现原理 效果 新建QSS文 ...
- Elasticsearch之插件扩展
Elasticsearch之插件介绍及安装 Elasticsearch之head插件安装之后的浏览详解 Elasticsearch之kopf插件安装之后的浏览详解 Elasticsearch-2.4. ...
- Objective-C基础笔记(9)Foundation常用类NSArray
NSArray用来存储对象的有序列表,它是不可变的 NSArray不能存储C语言中的基本数据类型,如int.float.enum.struct,也不能存储nil,nil代表数组元素的结束 // // ...
- 如何修复和检测Windows系统漏洞
本文为<如何给系统打补丁(知识篇)>一文实战文章. 本文出自 "李晨光原创技术博客" 博客,谢绝转载!
- Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一
Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,大家可以查看RFC2045-RFC2049,上面有MIME的详细规范.Base64编码可用于在HTTP环境下传递较长的标识信息.例如 ...
- 【Good Bye 2017 B】 New Year and Buggy Bot
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举一下全排列.看看有多少种可以到达终点即可. [代码] #include <bits/stdc++.h> using ...