What the difference between assembly instructio...

2011/09/30 12:04
阅读数 150

Most lines will normally have an actual assembly language instruction, to be converted by the tool into its binary equivalent, but can also be a directive which tells the assembler to do something. It can also be a pseudo-instruction (one which will be converted into one or more real instructions by the assembler). We’ll look at the actual instructions available in hardware in the next chapter and focus mainly on the assembler directives here. These perform a wide range of tasks. They can be used to place code or data at a particular address in memory, create references to other programs and so forth.

--  from 《Cortex-A Series Program Guide》

A directive communicates with the assembler or linker (or some other tool in the
chain, such as a code-reorganizer, etc.) but usually does not get executed on
the target at runtime.  It may address pretty printing/formatting, or help to
assign segment/section names to code or data, or ask the assembler/linker to use
a particular alignment, etc.  But whatever the exact purpose, a directive's
general purpose is for the programmer to inform some tool in the development
chain about some particular intent that may not otherwise be clear from just
reading nearby data and code statements.

A pseudo-op or pseudo-instruction is typically something that "looks like" an
instruction statement but instead where it maps to a different and possibly less
obvious construction of a regular instruction found in the cpu architecture
description (which is NOT the same thing as the assembler's.)  For example, in
the MSP430 microcontroller from TI, there is no NOP (no-operation) instruction
in the micro.  But there is a NOP recognized by the assembler, which is instead
mapped to a genuine instruction found in the architecture, namely "MOV #0, R3".
So NOP is a pseudo-op.  Actually, there are a number of possible formulations of
NOP on the MSP430, with different cycle times.  But that is the one chosen by
the assembler tool coders.  Similarly, the MSP430 assembler accepts "INC ..."
an instruction, but it really translates into "ADD #1, ..."  Another pseudo-op.
-- from Ask.com


0 收藏
0 评论
0 收藏