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 ...
随机推荐
- AtomicInteger类
今天写代码.尝试使用了AtomicInteger这个类,感觉使用起来非常爽,特别适用于高并发訪问.能保证i++,++id等系列操作的原子性. ++i和i++操作并非线程安全的.非常多人会用到synch ...
- ios UITextView 提示文本
定义两个UITextView,一个用于输入文本,一个用于显示提示信息,当输入文本为空时显示提示信息,否则不显示提示信息. //6.3.1文字内容提示 _contentTextViewTip = [[U ...
- javascript创建对象的方法--动态原型模式
javascript创建对象的方法--动态原型模式 一.总结 1.作用:解决组合模式的属性和函数分离问题 2.思路:基本思路和组合模式相同:共用的函数和属性用原型方式,非共用的的函数和属性用构造函数 ...
- IE中实现placeholder
简介:IE本身不支持Placeholder这种先进的特性,但是我们又必须且仅仅支持IE,所以网上找了一个支持placeholder的方法 考虑版权,以及知识产权原因,只放链接: http://blog ...
- Flume的client
Client:生产数据,运行在一个独立的线程.
- Linux平台下使用AdventNet ManageEngine OpUtils监控网络
AdventNet ManageEngine OpUtils 是一套系统和网络监视工具,它有Linux/Windows系统平台的免费版和企业版,该软件是一款用于监视诸如路由器,交换机,服务器或者桌面这 ...
- java 三次样条插值 画光滑曲线 例子
java 三次样条插值 画光滑曲线 例子 主要是做数值拟合,根据sin函数采点,取得数据后在java中插值并在swing中画出曲线,下面为截图 不光滑和光滑曲线前后对比: 代码: 执行类: p ...
- gomail发送附件
采用github.com/go-gomail/gomail/ 的邮件功能,可以发送附件 以及html文档,下面是其给出的demo,测试通过. package main //cmd: go get go ...
- Js 栈和堆的实现
一.队列和堆栈的简单介绍 1.1.队列的基本概念 队列:是一种支持先进先出(FIFO)的集合,即先被插入的数据,先被取出! 1.2.堆栈的基本概念 堆栈:是一种支持后进先出(LIFO)的集合,即后被插 ...
- 解读OpenRTB(实时竞价)生态系统
最近3年,广告实时竞价(RealTimeBidding)模式逐渐流行起来. 2012年大致了解过,最近一段时间,重新温习下. 半壁江山 生态系统总的来说分为2个部分,卖方和买方. 卖方:媒体,即拥有广 ...