The machine instruction sets are (almost by definition) different on
each machine where as
runs. Floating point representations
vary as well, and as
often supports a few additional
directives or command-line options for compatibility with other
assemblers on a particular platform. Finally, some versions of
as
support special pseudo-instructions for branch
optimization.
This chapter discusses most of these differences, though it does not include details on any machine's instruction set. For details on that subject, see the hardware manufacturer's manual.
as
has no additional command-line options for the AMD
29K family.
The macro syntax used on the AMD 29K is like that described in the AMD
29K Family Macro Assembler Specification. Normal as
macros should still work.
`;' is the line comment character.
The character `?' is permitted in identifiers (but may not begin an identifier).
General-purpose registers are represented by predefined symbols of the
form `GRnnn' (for global registers) or `LRnnn'
(for local registers), where nnn represents a number between
0
and 127
, written with no leading zeros. The leading
letters may be in either upper or lower case; for example, `gr13'
and `LR7' are both valid register names.
You may also refer to general-purpose registers by specifying the register number as the result of an expression (prefixed with `%%' to flag the expression as a register number):
%%expression
---where expression must be an absolute expression evaluating to a
number between 0
and 255
. The range [0, 127] refers to
global registers, and the range [128, 255] to local registers.
In addition, as
understands the following protected
special-purpose register names for the AMD 29K family:
vab chd pc0 ops chc pc1 cps rbp pc2 cfg tmc mmu cha tmr lru
These unprotected special-purpose register names are also recognized:
ipc alu fpe ipa bp inte ipb fc fps q cr exop
The AMD 29K family uses IEEE floating-point numbers.
.block size , fill
.cputype
.file
Warning: in other versions of the GNU assembler,
.file
is used for the directive called.app-file
in the AMD 29K support.
.line
.sect
.use section name
.text
, .data
,
.data1
, or .lit
. With one of the first three section
name options, `.use' is equivalent to the machine directive
section name; the remaining case, `.use .lit', is the same as
`.data 200'.
as
implements all the standard AMD 29K opcodes. No
additional pseudo-instructions are needed on this family.
For information on the 29K machine instruction set, see Am29000 User's Manual, Advanced Micro Devices, Inc.
as
has no additional command-line options for the Hitachi
H8/300 family.
`;' is the line comment character.
`$' can be used instead of a newline to separate statements. Therefore you may not use `$' in symbol names on the H8/300.
You can use predefined symbols of the form `rnh' and `rnl' to refer to the H8/300 registers as sixteen 8-bit general-purpose registers. n is a digit from `0' to `7'); for instance, both `r0h' and `r7l' are valid register names.
You can also use the eight predefined symbols `rn' to refer to the H8/300 registers as 16-bit registers (you must use this form for addressing).
On the H8/300H, you can also use the eight predefined symbols `ern' (`er0' ... `er7') to refer to the 32-bit general purpose registers.
The two control registers are called pc
(program counter; a
16-bit register, except on the H8/300H where it is 24 bits) and
ccr
(condition code register; an 8-bit register). r7
is
used as the stack pointer, and can also be called sp
.
as understands the following addressing modes for the H8/300:
rn
@rn
@(d, rn)
@(d:16, rn)
@(d:24, rn)
@rn+
@-rn
@
aa
@
aa:8
@
aa:16
@
aa:24
aa
. (The address size `:24' only makes
sense on the H8/300H.)
#xx
#xx:8
#xx:16
#xx:32
as
neither
requires this nor uses it--the data size required is taken from
context.
@
@
aa
@
@
aa:8
as
neither requires this nor uses it.
The H8/300 family has no hardware floating point, but the .float
directive generates IEEE floating-point numbers for compatibility
with other development tools.
as
has only one machine-dependent directive for the
H8/300:
.h8300h
.int
emit 32-bit numbers rather than the usual (16-bit)
for the H8/300 family.
On the H8/300 family (including the H8/300H) `.word' directives generate 16-bit numbers.
For detailed information on the H8/300 machine instruction set, see H8/300 Series Programming Manual (Hitachi ADE--602--025). For information specific to the H8/300H, see H8/300H Series Programming Manual (Hitachi).
as
implements all the standard H8/300 opcodes. No additional
pseudo-instructions are needed on this family.
Four H8/300 instructions (add
, cmp
, mov
,
sub
) are defined with variants using the suffixes `.b',
`.w', and `.l' to specify the size of a memory operand.
as
supports these suffixes, but does not require them;
since one of the operands is always a register, as
can
deduce the correct size.
For example, since r0
refers to a 16-bit register,
mov r0,@foo is equivalent to mov.w r0,@foo
If you use the size suffixes, as
issues a warning when
the suffix and the register size do not match.
as
has no additional command-line options for the Hitachi
H8/500 family.
`!' is the line comment character.
`;' can be used instead of a newline to separate statements.
Since `$' has no special meaning, you may use it in symbol names.
You can use the predefined symbols `r0', `r1', `r2', `r3', `r4', `r5', `r6', and `r7' to refer to the H8/500 registers.
The H8/500 also has these control registers:
cp
dp
bp
tp
ep
sr
ccr
All registers are 16 bits long. To represent 32 bit numbers, use two
adjacent registers; for distant memory addresses, use one of the segment
pointers (cp
for the program counter; dp
for
r0
--r3
; ep
for r4
and r5
; and
tp
for r6
and r7
.
as understands the following addressing modes for the H8/500:
Rn
@Rn
@(d:8, Rn)
@(d:16, Rn)
@-Rn
@Rn+
@aa:8
@aa:16
#xx:8
#xx:16
The H8/500 family has no hardware floating point, but the .float
directive generates IEEE floating-point numbers for compatibility
with other development tools.
as
has no machine-dependent directives for the H8/500.
However, on this platform the `.int' and `.word' directives
generate 16-bit numbers.
For detailed information on the H8/500 machine instruction set, see H8/500 Series Programming Manual (Hitachi M21T001).
as
implements all the standard H8/500 opcodes. No additional
pseudo-instructions are needed on this family.
As a back end for GNU CC as
has been throughly tested and should
work extremely well. We have tested it only minimally on hand written assembly
code and no one has tested it much on the assembly output from the HP
compilers.
The format of the debugging sections has changed since the original
as
port (version 1.3X) was released; therefore,
you must rebuild all HPPA objects and libraries with the new
assembler so that you can debug the final executable.
The HPPA as
port generates a small subset of the relocations
available in the SOM and ELF object file formats. Additional relocation
support will be added as it becomes necessary.
as
has no machine-dependent command-line options for the HPPA.
The assembler syntax closely follows the HPPA instruction set reference manual; assembler directives and general syntax closely follow the HPPA assembly language reference manual, with a few noteworthy differences.
First, a colon may immediately follow a label definition. This is simply for compatibility with how most assembly language programmers write code.
Some obscure expression parsing problems may affect hand written code which
uses the spop
instructions, or code which makes significant
use of the !
line separator.
as
is much less forgiving about missing arguments and other
similar oversights than the HP assembler. as
notifies you
of missing arguments as syntax errors; this is regarded as a feature, not a
bug.
Finally, as
allows you to use an external symbol without
explicitly importing the symbol. Warning: in the future this will be
an error for HPPA targets.
Special characters for HPPA targets include:
`;' is the line comment character.
`!' can be used instead of a newline to separate statements.
Since `$' has no special meaning, you may use it in symbol names.
The HPPA family uses IEEE floating-point numbers.
as
for the HPPA supports many additional directives for
compatibility with the native assembler. This section describes them only
briefly. For detailed information on HPPA-specific assembler directives, see
HP9000 Series 800 Assembly Language Reference Manual (HP 92432-90001).
as
does not support the following assembler directives
described in the HP manual:
.endm .liston .enter .locct .leave .macro .listoff
Beyond those implemented for compatibility, as
supports one
additional assembler directive for the HPPA: .param
. It conveys
register argument locations for static functions. Its syntax closely follows
the .export
directive.
These are the additional directives in as
for the HPPA:
.block n
.blockz n
.call
.callinfo [ param=value, ... ] [ flag, ... ]
.code
.copyright "string"
.copyright "string"
.enter
.entry
.exit
.export name [ ,typ ] [ ,param=r ]
0
to 3
, and
indicates one of four one-word arguments); `rtnval' (the procedure's
result); or `priv_lev' (privilege level). For arguments or the result,
r specifies how to relocate, and must be one of `no' (not
relocatable), `gr' (argument is in general register), `fr' (in
floating point register), or `fu' (upper half of float register).
For `priv_lev', r is an integer.
.half n
as
directive .short
.
.import name [ ,typ ]
.export
; make a procedure available to call. The arguments
use the same conventions as the first two arguments for .export
.
.label name
.leave
.origin lc
portable directive .org
.
.param name [ ,typ ] [ ,param=r ]
.export
, but used for static procedures.
.proc
.procend
label .reg expr
.equ
; define label with the absolute expression
expr as its value.
.space secname [ ,params ]
.spnum secnam
.space
directive.)
.string "str"
.string
"str", for information on escape sequences you can use in
as
strings.
Warning! The HPPA version of .string
differs from the
usual as
definition: it does not write a zero byte
after copying str.
.stringz "str"
.string
, but appends a zero byte after copying str to object
file.
.subspa name [ ,params ]
.nsubspa name [ ,params ]
.space
, but selects a subsection name within the
current section. You may only specify params when you create a
subsection (in the first instance of .subspa
for this name).
If specified, the list params declares attributes of the subsection,
identified by keywords. The keywords recognized are `quad=expr'
("quadrant" for this subsection), `align=expr' (alignment for
beginning of this subsection; a power of two), `access=expr' (value
for "access rights" field), `sort=expr' (sorting order for this
subspace in link), `code_only' (subsection contains only code),
`unloadable' (subsection cannot be loaded into memory), `common'
(subsection is common block), `dup_comm' (initialized data may have
duplicate names), or `zero' (subsection is all zeros, do not write in
object file).
.nsubspa
always creates a new subspace with the given name, even
if one with the same name already exists.
.version "str"
For detailed information on the HPPA machine instruction set, see PA-RISC Architecture and Instruction Set Reference Manual (HP 09740-90039).
as
¿¡´Â ÇöÀç 80386¿¡ °ü·ÃµÈ ±â°è ÀÇÁ¸ÀûÀÎ ¿É¼ÇÀº ¾ø´Ù.
gcc¿Í as
ÀÇ Ãâ·Â°ú ÇÔ²² ȣȯ¼ºÀ» À¯ÁöÇÒ ¸ñÀûÀ¸·Î AT&T
½Ã½ºÅÛ V/386 ¾î¼Àºí·¯ ¹®¹ýÀ» Á¦°øÇÑ´Ù. ÀÌ°ÍÀº ÀÎÅÚ ¹®¹ý°ú ´Ù¼Ò°£ Â÷ÀÌ°¡
ÀÖ´Ù. °ÅÀÇ ´ëºÎºÐÀÇ 80386À» ¼³¸íÇÏ´Â ¹®¼µéÀº ÀÎÅÚ ¹®¹ý¸¸À» »ç¿ëÇϱâ
¶§¹®¿¡ ¿©±â ¼´Â ÀÌ·¯ÇÑ Â÷ÀÌÁ¡µé¿¡ ´ëÇؼ ¼³¸íÇÑ´Ù. µÎ ¹®¹ý¿¡¼ÀÇ
ÁÖ¸ñÇÒ ¸¸ÇÑ Â÷ÀÌÁ¡µéÀº ´ÙÀ½°ú °°´Ù.
ÀÛµ¿ÀÚ¿¡´Â ÇÇ¿¬»êÀÚÀÇ Å©±â¸¦ ¸í½ÃÇÏ´Â ÇϳªÀÇ ±ÛÀÚ°¡ ²¿¸®¿¡ ºÙ´Â´Ù.
`b',`w', `l'Àº °¢°¢ byte, word, long ÇÇ¿¬»êÀÚ¸¦ »ç¿ëÇÏ°í
ÀÖÀ½À» ¸í½ÃÇÑ´Ù. ¸¸¾à ¾î¶² Á¢¹Ì¾îµµ ¸í·É¿¡ ºÙÁö ¾Ê´Â´Ù¸é
as
´Â ´ë»ó ·¹Áö½ºÅÍ ÇÇ¿¬»êÀÚ(ÁýÇÕÀÇ ¸¶Áö¸· ÇÏ ³ª)¿¡ ±âÃÊÇØ
ºüÁø ²¿¸®¸¦ ºÙÀÏ °ÍÀÌ´Ù. ±×·¡¼ `mov %ax, %bx'´Â `movw %ax,
%bx' ¿Í °°°Ô µÈ´Ù. ¶ÇÇÑ `mov $1, %bx'´Â `movw $1, %bx'°¡ µÉ °ÍÀÌ´Ù.
±×·¯³ª AT&T À¯´Ð½º ¾î¼Àºí·¯¿¡¼ ÀÌ·¸°Ô ÀûÇÕÇÏÁö ¾Ê°Ô ²¿¸®°¡ ºüÁ³´Ù¸é
²¿¸®´Â ¾Ï½ÃÀû À¸·Î long ÇÇ¿¬»êÀÚ Å©±â·Î °¡Á¤µÈ´Ù. (ÀÌ·¯ÇÑ ºÒÀÏÄ¡¼º¿¡´Â
ÄÄÆÄÀÏ·¯°¡ Ç×»ó ¸í ¹éÇÏ°Ô ÀÛµ¿ÀÚ¿¡ ²¿¸®¸¦ ¸í½ÃÇÔÀ¸·Î½á ÄÄÆÄÀÏ·¯ÀÇ
Ãâ·Â¿¡´Â º° ¿µÇâÀ» ¹ÌÄ¡Áö ¸ø ÇÑ´Ù.)
Á¶±ÝÀÇ ¿¹¿Ü°¡ ÀÖ±äÇÏ´Ù. ºÎȣȮÀå°ú zero È®Àå ¸í·É¾îµéÀº ±×°ÍµéÀ» ¸í½ÃÇÒ µÎ °³ÀÇ Å©±â°¡ ÇÊ¿äÇÏ´Ù. ÀÌ·¯ÇÑ ¸í·É¾îµéÀº ºÎÈ£/Á¦·Î È®ÀåÀ» ÇÒ fromÀÇ Å©±â¿Í zero È®ÀåµÉ toÀÇ Å©±â Çϳª°¡ ÇÊ¿äÇÏ´Ù. ÀÌ·¯ÇÑ °ÍÀ» ÇØ°áÇϱâ À§ÇÏ¿© AT&T ¹®¹ý¿¡¼´Â µÎ °³ÀÇ ÀÛµ¿ÀÚ Á¢¹Ì¾î(suffix-²¿¸®)µéÀ» »ç¿ëÇÑ´Ù. AT&T ¹®¹ý¿¡ ¼ ºÎȣȮÀå°ú Á¦·ÎÈ®Àå¿¡¼ÀÇ ±âº»ÀûÀÎ ¸íĪÀº `movs...' ¿Í `movz...'°°Àº °ÍÀÌ ´Ù. (ÀÎÅÚ¹®¹ý¿¡¼ÀÇ `movsx'¿Í `movzx'). ÀÛµ¿ÀÚ Á¢¹Ì¾îµéÀº ÀÌ·¯ÇÑ ±âº» ¸íĪ ¿¡ °áÇյǰí, from Á¢¹Ì¾î°¡ to Á¢¹Ì¾îº¸´Ù ¸ÕÀú¿Â´Ù. ±×·¡¼ ÀÎÅÚ ¹®¹ýÀÇ `movsbl %al, %edx' Àº "move sign extend *from* %al *to* %edx"¸¦ ÀǹÌÇÑ´Ù. °¡´ÉÇÑ Á¢¹Ì¾î´Â `bl'(from byte to long),`bw'(from byte to word), `wl'(from word to long) ÀÌ µÈ´Ù.
ÀÎÅÚ ¹®¹ý¿¡¼ÀÇ ¾Æ·¡¿Í °°Àº º¯È¯ ¸í·ÉÀº
AT&T¿¡¼´Â `cbtw', `cwtl', `cwtd', `cltd'·Î È£ÃâµÈ´Ù.
as
¿¡¼´Â ÀÌ·¸°Ô À̸§ À» ºÎ¸£´Â °ÍÀ» Çã¿ëÇÑ´Ù.
Far call/jump ¸í·ÉÀº AT&T¿¡¼´Â `lcall', `ljmp'·Î ºÒ¸®¿ì³ª ÀÎÅÚ¿¡¼´Â `call far', `jump far'·Î ¸íĪµÈ´Ù.
·¹Áö½ºÅÍ ÇÇ¿¬»êÀÚ´Â Ç×»ó `%' Á¢µÎ¾î°¡ ºÙ´Â´Ù. 80386 ·¹Áö½ºÅÍÀÇ ±¸¼ºÀº ´ÙÀ½°ú °°´Ù.
ÀÛµ¿ÀÚÀÇ Á¢µÎ¾î´Â µÚµû¸£´Â ÀÛµ¿ÀÚ¸¦ º¯°æÇϱâ À§ÇØ »ç¿ëµÈ´Ù. ±×°ÍµéÀº ½ºÆ®¸µ ¸í·ÉÀ» ¹Ýº¹ÇÑ´Ù´øÁö, ¼½¼Ç ¿À¹ö¸®µå¸¦ Á¦°øÇÑ´Ù´øÁö, ¹ö½º ·Ï ÀÛµ¿À» ¼öÇàÇÑ´Ù´øÁö, ÇÇ¿¬»êÀÚ¿Í ÁÖ¼ÒÀÇ Å©±â¸¦ Á¦°øÇÏ´Â µ¥ »ç¿ëµÈ´Ù. (16-bit ÇÇ¿¬»êÀÚµéÀº ÀϹÝÀûÀ¸·Î ÇÇ¿¬»êÀÚ Å©±â ÀÛµ¿ÀÚ Á¢µÎ¾î·Î 32-bit ÇÇ¿¬»ê ÀÚ°¡ µÉ ¼ö ÀÖ´Â ¸í·É¾î¿¡¼ Á¢µÎ¾î¸¦ ºÙÀÓÀ¸·Î¼ ¸í½ÃµÈ´Ù.) ÀÛµ¿ÀÚ Á¢µÎ¾îµéÀº º¸Åë ÇÇ¿¬»êÀÚ°¡ ¾øÀÌ ÇϳªÀÇ Çà ¸í·ÉÀ¸·Î ÁÖ¾îÁö°í ¹Ýµå½Ã ¹Ù·Î ±×°ÍµéÀÌ ÀÇÁ¸ÇÏ´Â ¸í·É¾îµéÀÌ ¾Õ¼¾ß ÇÑ´Ù. ¿¹¸¦ µéÀÚ¸é `scas'(scan string) ¸í·ÉÀº ´ÙÀ½°ú °°ÀÌ ¹Ýº¹µÈ´Ù:
repne scas
¿©±â¿¡ ÀÛµ¿ÀÚ Á¢µÎ¾îµéÀÇ ¸ñ·ÏÀÌ ÀÖ´Ù.
ÀÎÅÚ¹®¹ý¿¡¼ ¸Þ¸ð¸®¸¦ °£Á¢ÀûÀ¸·Î ÂüÁ¶ÇÏ´Â Çü½ÄÀº ´ÙÀ½°ú °°´Ù.
section:[base + index*scale + disp]
ÀÌ°ÍÀº ´ÙÀ½°ú °°Àº AT&T ¹æ½ÄÀ¸·Î ÂüÁ¶µÈ´Ù.
section:disp(base, index, scale)
base¿Í index´Â 32ºñÆ® º£À̽º¿Í À妽º ·¹Áö½ºÅÍÀÌ°í,
disp¿Í ÇÔ²² ¼±ÅûçÇ×ÀÌ´Ù. scale Àº ÇÇ¿¬»êÀÚÀÇ ÁÖ¼Ò¸¦
°è»êÇϱâ À§ÇÏ¿© index¿¡ °öÇØÁö´Â 1, 2, 4, 8°ú °°Àº °ÍÀÌ´Ù.
scaleÀÌ ¸í½ÃµÇÁö ¾ÊÀ¸¸é ±×°ÍÀº 1·Î Ãë±Þ µÈ´Ù. section ¿¡´Â
¸Þ¸ð¸® ÇÇ¿¬»êÀÚ¸¦ À§ÇÑ ¼½¼Ç ·¹Áö½ºÅ͸¦ ¸í½ÃÇÑ´Ù. ÀÌ°ÍÀº ¾Æ¸¶µµ µðÆúÆ®
¼½¼Ç ·¹Áö½ºÅͷΠä¿öÁú °ÍÀÌ´Ù. (µðÆúÆ® ¼½¼Ç ·¹Áö½ºÅÍ´Â 80386 ¸Þ´º¾óÀ»
Âü°íÇ϶ó) ¹°·Ð À̰͵µ ¼±ÅûçÇ×ÀÌ´Ù. ÀÌ ¼½¼ÇÀº AT&T ¹®¹ý»ó¿¡¼´Â
¹Ýµå½Ã `%'°¡ ¾Õ¿¡ ³ª¿À´Â ÇüÅÂÀ̾î¾ß ÇÑ´Ù. ¸¸ÀÏ µðÆúÆ® ¼½¼Ç
·¹Áö½ºÅÍ¿Í °°ÀÌ µ¿½Ã¿¡ Çؼ®ÇÒ ¼ÒÁö°¡ ÀÖ´Â °ÍÀ¸·Î ¼½¼ÇÀ» ¸í½ÃÇÑ´Ù¸é,
as
´Â ÁÖ¾îÁø ¸í·ÉÀ» ¾î¼ÀºíÇÒ ¶§¿¡ ±× ºÎºÐÀ» µÚ´þ¾î ¹ö¸®´Â
¾î¶°ÇÑ Á¢µÎ¾î ¼½¼Ç ·¹Áö½ºÅ͵µ Ãâ·ÂÇÏÁö ¾ÊÀ» °ÍÀÌ´Ù. ±×·¡¼, ¼½¼Ç
¾²±â´Â ÁÖ¾îÁø ¸Þ¸ð¸®¸¦ ÂüÁ¶ÇÏ´Â µ¥ ÀÖ¾î¼ ¾î¶°ÇÑ ¼½¼Ç·¹Áö½ºÅÍ°¡ »ç¿ëµÉ
°ÍÀÎÁö¸¦ °Á¶ÇÏ¿© ¸í½ÃÇÒ ¼ö ÀÖ´Ù.
¿©±â¿¡ ÀÎÅÚ°ú AT&T ½ºÅ¸ÀÏÀÇ ¸Þ¸ð¸® ÂüÁ¶¸¦ ÇÏ´Â ¸î¸î ¿¹¸¦ ½Æ´Â´Ù.
Àý´ëÀûÀÎ(PC¿Í´Â ´Þ¸®) call°ú jump ÇÇ¿¬»êÀÚµéÀº ¹Ýµå½Ã `*'°¡ ¾Õ¿¡ ¿Í¾ß ÇÑ´Ù. `*'°¡ ¸í½ÃµÇÁö ¾ÊÀ¸¸é, as´Â Ç×»ó PC¿Í °°Àº ÇüÅÂÀÇ jump/call ¶óº§À» ¾îµå·¹½ÌÇÑ´Ù.
¸Þ¸ð¸® ÇÇ¿¬»êÀÚ¸¦ °¡Áö´Â ¾î¶² ¸í·É¾îµéµµ ¹Ýµå½Ã ±×°ÍÀÇ Å©±â(byte, word, long)¸¦ ÀÛµ¿ÀÚÀÇ Á¢¹Ì¾î(`b', `w', `l')·Î ¸í½ÃÇØ¾ß ÇÑ´Ù.
Á¡ÇÁ ¸í·É¾îµéÀº °¡´ÉÇÑ ÃÖ¼ÒÀÇ À̵¿ÀÌ ÀϾµµ·Ï ÃÖÀûȵȴÙ. ÀÌ°ÍÀº Á¡ÇÁ ´ë»óÀÌ ÃæºÐÈ÷ °¡±î¿ï ¶§´Â ¾ðÁ¦³ª 1¹ÙÀÌÆ®(8ºñÆ®) À§Ä¡À̵¿ Á¡ÇÁ¸¦ »ç¿ëÇÔÀ¸·Î½á °¡´ÉÇÏ´Ù. 1¹ÙÀÌÆ® À§Ä¡À̵¿ÀÌ ºÒÃæºÐ ÇÏ´Ù¸é long(32ºñÆ®) À§Ä¡À̵¿ Á¡ÇÁ°¡ »ç¿ëµÈ´Ù. ¿ì¸®´Â word(16ºñÆ®) À§Ä¡À̵¿ Á¡ÇÁ´Â Á¦°øÇÏ Áö ¾Ê´Â´Ù(`addr16' ÀÛµ¿ÀÚ Á¢µÎ¾î¿Í °°Àº Á¡ÇÁ ¸í·ÉÀÌ ¼±ÇàÇÏ´Â °Í°ú °° Àº..). 80386 ÀÌ `%eip'¸¦ 16 ºñÆ®·Î ¸¶½ºÅ·Çϱ⸦ ÁÖÀåÇÑ ÀÌÈÄ¿¡³ª ¿öµå À§Ä¡À̵¿ Á¡ÇÁ°¡ Ãß°¡µÇ¾ú´Ù.
`jcxz', `jecxz', `loop', `loopz', `loope', `loopnz', `loopne' ¸í·ÉµéÀº ´ÜÁö ¹ÙÀÌÆ® À§Ä¡À̵¿¿¡¼¸¸ »ç¿ëµÈ´Ù. ±×·¡¼ ÀÌ¿Í ºñ½ÁÇÑ ´Ù¸¥ ¸í·É¾îµéÀ» »ç¿ëÇÑ´Ù¸é ('gcc'´Â À̰͵éÀ» »ç¿ëÇÏÁö ¸øÇÑ´Ù) ¿¡·¯¸Þ¼¼Áö¿Í ÇÔ²² Ʋ¸° ÄÚµå ºÎºÐÀ» Ãâ·Â ÇÒ °ÍÀÌ´Ù. AT&T 80386 ¾î¼Àºí·¯¿¡¼´Â ÀÌ·¯ÇÑ ¹®Á¦Á¡ À» ´ÙÀ½°ú °°ÀÌ ÇØ°áÇÑ´Ù. `jcxz foo'¸¦.
jcxz cx_zero jmp cx_nonzero cx_zero: jmp foo cx_nonzero:
BCD °ü·ÃµÇ´Â °Í¸¸ Á¦¿ÜÇÏ°í´Â ¸ðµç 80387 ºÎµ¿¼Ò¼öÁ¡ ŸÀÔÀÌ Á¦°øµÈ´Ù. (BCD¸¦ Á¦°øÇÏ´Â °Íµµ ±×´ÙÁö ¾î·ÆÁö ¾ÊÀ» °ÍÀÌ´Ù). ÀÌ·¯ÇÑ µ¥ÀÌÅÍ Å¸ÀÔ Àº 16, 32, 64 ºñÆ® Á¤¼öÇü°ú, single (32ºñÆ®), double (64ºñÆ®), È®Àå (80ºñÆ®) Á¤¹ÐµµÀÇ ºÎµ¿ ¼Ò¼öÁ¡ÀÌ´Ù. Á¦°øµÇ´Â °¢°¢ÀÇ Å¸ÀÔÀº ÀÛµ¿ÀÚ Á¢¹Ì¾î °¡ µû¶ó ºÙÀ¸¸ç, ±×°Í°ú °áÇÕÇÑ »ý¼ºÀÚ¸¦ °¡Áø´Ù. ÀÛµ¿ÀÚÀÇ Á¢¹Ì¾î´Â ÇÇ¿¬»êÀÚ ÀÇ µ¥ÀÌÅÍ Å¸ÀÔÀ» ¸í½ÃÇÑ´Ù. »ý¼ºÀÚ´Â ÀÌ·¯ÇÑ µ¥ÀÌÅÍ Å¸ÀÔÀ» ¸Þ¸ð¸®¿¡ ¸¸µç´Ù.
·¹Áö½ºÅÍ¿¡¼ ·¹Áö½ºÅÍ·Î ÀÛµ¿ÇÏ´Â °Í¿¡´Â ÀÛµ¿ÀÚ µÚ¿¡ ºÙÀÌ´Â Á¢¹Ì¾î°¡ ÇÊ¿äÄ¡ ¾Ê´Ù. ±×·¡¼ `fst %st, %st(1)'Àº `fstl %st, %st(1)'°ú °°´Ù.
80387 ÀÌ ÀÚµ¿ÀûÀ¸·Î 80386ÀÇ `fwait'¸í·É°ú µ¿½Ã¿¡ ¹ß»ý½Ãų Çʿ伺Àº
°ÅÀÇ ÇÊ¿äÄ¡ ¾Ê´Ù (ÀÌ °æ¿ì´Â 80286/80287°ú 8086/8087 ÀÇ Â¦µé¿¡´Â ÇØ´çµÇÁö
¾Ê´Â´Ù.) ±×·¯¹Ç·Î as
´Â `fn...' ¸í·ÉÁßÀÇ Çϳª¿¡
ÀÇÇØ `fwait'°¡ ¾Ï½ÃÀûÀ¸·Î ¼±ÅõǾúÀ» ¶§¿¡´Â `fwait'¸í·ÉÀ»
¾ïÁ¦ÇÑ´Ù. ¿¹¸¦ µé¸é, `fsave'¿Í `fnsave'´Â ¶È°°ÀÌ Ãë±Þ µÈ´Ù.
ÀϹÝÀûÀ¸·Î, ¸ðµç `fn...' ¸í·ÉÀº `f...'¸í·É°ú µ¿µîÇÏ´Ù.
¸¸ÀÏ `fwait'¸¦ ¾² °íÀÚ ÇÑ´Ù¸é ±×°ÍÀº Á¤È®È÷ ÄÚµå¼Ó¿¡ Æ÷ÇÔÇÏ¿©¾ß
ÇÑ´Ù.
While GAS normally writes only "pure" 32-bit i386 code, it has limited support for writing code to run in real mode or in 16-bit protected mode code segments. To do this, insert a `.code16' directive before the assembly language instructions to be run in 16-bit mode. You can switch GAS back to writing normal 32-bit code with the `.code32' directive.
GAS understands exactly the same assembly language syntax in 16-bit mode as in 32-bit mode. The function of any given instruction is exactly the same regardless of mode, as long as the resulting object code is executed in the mode for which GAS wrote it. So, for example, the `ret' mnemonic produces a 32-bit return instruction regardless of whether it is to be run in 16-bit or 32-bit mode. (If GAS is in 16-bit mode, it will add an operand size prefix to the instruction to force it to be a 32-bit return.)
This means, for one thing, that you can use GNU CC to write code to be run in real mode or 16-bit protected mode. Just insert the statement `asm(".code16");' at the beginning of your C source file, and while GNU CC will still be generating 32-bit code, GAS will automatically add all the necessary size prefixes to make that code run in 16-bit mode. Of course, since GNU CC only writes small-model code (it doesn't know how to attach segment selectors to pointers like native x86 compilers do), any 16-bit code you write with GNU CC will essentially be limited to a 64K address space. Also, there will be a code size and performance penalty due to all the extra address and operand size prefixes GAS has to add to the instructions.
Note that placing GAS in 16-bit mode does not mean that the resulting code will necessarily run on a 16-bit pre-80386 processor. To write code that runs on such a processor, you would have to refrain from using any 32-bit constructs which require GAS to output address or operand size prefixes. At the moment this would be rather difficult, because GAS currently supports only 32-bit addressing modes: when writing 16-bit code, it always outputs address size prefixes for any instruction that uses a non-register addressing mode. So you can write code that runs on 16-bit processors, but only if that code never references memory.
¿©±â¼´Â `mul'°ú `imul' ¸í·É°ú °ü·ÃµÈ ¾ð±ÞÇÒ ¸¸ÇÑ ¸î°¡Áö
Æ®¸¯À» ¼³¸íÇÏ°Ú´Ù. 16, 32, 64 ºñÆ®·Î °á°ú¹°ÀÌ È®ÀåµÇ´Â °ö¼ÀÀº ´ÜÁö
ÇϳªÀÇ ÇÇ¿¬»êÀÚ¿¡ Ãâ·ÂµÉ °ÍÀÌ´Ù. ±×·¯¹Ç·Î, `imul %ebx, %eax'´Â
°ö¼ÀÀÇ °á°ú°¡ ¿øÇÏ´Â µ¥·Î È®ÀåµÇÁö ¾ÊÀ» °ÍÀÌ ´Ù; È®ÀåÀ» ±â´ëÇÏ´Â °ö¼ÀÀº
`%edx' ·¹Áö½ºÅ͸¦ µ¤¾î ¾µ °ÍÀ̸ç, gcc
°¡ Ãâ·ÂÀ»
ÇÏ°íÀÚ ÇÏ´Â µ¥ È¥¶õÀ» ÁÙ °ÍÀÌ´Ù. `%edx:%eax'¿¡ 64ºñÆ® °á°ú¹°À»
¾òÀ»·Á¸é `imul %ebx'¸¦ »ç¿ëÇ϶ó.
¿ì¸®´Â `imul'°ú °ü·ÃµÈ 2°³ÀÇ ÇÇ¿¬»êÀÚ ÇüÀ» Ãß°¡ÇÏ¿´´Ù. ±×°ÍÀº ù ¹ø° ÇÇ¿¬»ê ÀÚ°¡ Áï°¢ÀûÀÎ °ªÀ» °®´Â (¿ªÀÚÁÖ: »ó¼öÇüÅÂ¿Í ºñ½ÁÇÑ) Ç¥ÇöÀÌ°í µÎ ¹ø° ÇÇ¿¬»ê ÀÚ´Â ·¹Áö½ºÅÍÀÌ´Ù. `%eax'¿¡ 69¸¦ °öÇÏ´Â °ÍÀ» ¿¹·Î µé¸é, `imul $69, %eax, %eax'º¸´Ù´Â `imul $69, %eax'ÀÌ µÉ ¼ö ÀÖÀ» °ÍÀÌ´Ù.
-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
as
generates code
for any instruction or feature that is supported by some version of the
960 (even if this means mixing architectures!). In principle,
as
attempts to deduce the minimal sufficient processor type if
none is specified; depending on the object code format, the processor type may
be recorded in the object file. If it is critical that the as
output match a specific architecture, specify that architecture explicitly.
-b
call increment routine .word 0 # pre-counter Label: BR call increment routine .word 0 # post-counterThe counter following a branch records the number of times that branch was not taken; the differenc between the two counters is the number of times the branch was taken. A table of every such
Label
is also generated, so that the
external postprocessor gbr960
(supplied by Intel) can locate all
the counters. This table is always labelled `__BRANCH_TABLE__';
this is a local symbol to permit collecting statistics for many separate
object files. The table is word aligned, and begins with a two-word
header. The first word, initialized to 0, is used in maintaining linked
lists of branch tables. The second word is a count of the number of
entries in the table, which follow immediately: each is a word, pointing
to one of the labels illustrated above.
The first word of the header is used to locate multiple branch tables,
since each object file may contain one. Normally the links are
maintained with a call to an initialization routine, placed at the
beginning of each function in the file. The GNU C compiler
generates these calls automatically when you give it a `-b' option.
For further details, see the documentation of `gbr960'.
-no-relax
as
should generate errors instead, if the target displacement
is larger than 13 bits.
This option does not affect the Compare-and-Jump instructions; the code
emitted for them is always adjusted when necessary (depending on
displacement size), regardless of whether you use `-no-relax'.
as
generates IEEE floating-point numbers for the directives
`.float', `.double', `.extended', and `.single'.
.bss symbol, length, align
.lcomm symbol
, length.
.extended flonums
.extended
expects zero or more flonums, separated by commas; for
each flonum, `.extended' emits an IEEE extended-format (80-bit)
floating-point number.
.leafproc call-lab, bal-lab
callj
instruction to enable faster calls of leaf
procedures. If a procedure is known to call no other procedures, you
may define an entry point that skips procedure prolog code (and that does
not depend on system-supplied saved context), and declare it as the
bal-lab using `.leafproc'. If the procedure also has an
entry point that goes through the normal prolog, you can specify that
entry point as call-lab.
A `.leafproc' declaration is meant for use in conjunction with the
optimized call instruction `callj'; the directive records the data
needed later to choose between converting the `callj' into a
bal
or a call
.
call-lab is optional; if only one argument is present, or if the
two arguments are identical, the single argument is assumed to be the
bal
entry point.
.sysproc name, index
All Intel 960 machine instructions are supported; see section i960 Command-line Options for a discussion of selecting the instruction subset for a particular 960 architecture.
Some opcodes are processed beyond simply emitting a single corresponding instruction: `callj', and Compare-and-Branch or Compare-and-Jump instructions with target displacements larger than 13 bits.
callj
You can write callj
to have the assembler or the linker determine
the most appropriate form of subroutine call: `call',
`bal', or `calls'. If the assembly source contains
enough information--a `.leafproc' or `.sysproc' directive
defining the operand--then as
translates the
callj
; if not, it simply emits the callj
, leaving it
for the linker to resolve.
The 960 architectures provide combined Compare-and-Branch instructions that permit you to store the branch target in the lower 13 bits of the instruction word itself. However, if you specify a branch target far enough away that its address won't fit in 13 bits, the assembler can either issue an error, or convert your Compare-and-Branch instruction into separate instructions to do the compare and the branch.
Whether as
gives an error or expands the instruction depends
on two choices you can make: whether you use the `-no-relax' option,
and whether you use a "Compare and Branch" instruction or a "Compare
and Jump" instruction. The "Jump" instructions are always
expanded if necessary; the "Branch" instructions are expanded when
necessary unless you specify -no-relax
---in which case
as
gives an error instead.
These are the Compare-and-Branch instructions, their "Jump" variants, and the instruction pairs they may expand into:
as
ÀÇ Motorola 680x0 ¹öÀü¿¡´Â ±â°è ÀÇÁ¸ÀûÀÎ ¿É¼ÇÀÌ ¸î°³
ÀÖ´Ù.
Á¤ÀǵÇÁö ¾ÊÀº ½Éº¼¿¡ ´ëÇØ ÂüÁ¶ÇÏ´Â Å©±â¸¦ ÁÙÀÌ·Á¸é `-l' ¿É¼ÇÀ»
»ç¿ëÇÑ´Ù. `-l' ¿É¼ÇÀ» »ç¿ëÇÏÁö ¾ÊÀ¸¸é, Á¤ÀǵÇÁö ¾ÊÀº ½Éº¼¿¡ ´ëÇÑ
ÂüÁ¶´Â long
À» ¿ÏÀüÈ÷ ä¿ï¸¸Å Ŭ °ÍÀÌ´Ù. (as
´Â ÀÌ
½Éº¼ÀÌ ¾îµð¼ ³¡³¯Áö ¸ð¸£±â ¶§¹®¿¡, as
´Â Èʳ¯ÀÇ ¸µÄ¿¸¦
À§Çؼ °ø°£À» ÇÒ´çÇØ µÎ´Â ¼ö¹Û¿¡ ¾ø´Ù. as
´Â ÀÌ ½Éº¼ÀÌ
¾ó¸¶³ª ¸Ö¸® ÀÖ´ÂÁö ¸ð¸£±â ¶§¹®¿¡, °¡´ÉÇÑÇÑ ¸¹Àº °ø°£À» È®º¸ÇÑ´Ù.) ÀÌ
¿É¼ÇÀ» »ç¿ëÇϸé, ÀÌ·¯ÇÑ ÂüÁ¶´Â ÇÑ°³ÀÇ word Å©±â(16 ºñÆ®)°¡ µÈ´Ù. ÀÌ
±â´ÉÀº ¸ñÀû ÆÄÀÏÀ» °¡´ÉÇÑÇÑ ÀÛ°Ô ÇÏ°í ½ÍÀ¸¸é¼ °ü·ÃµÈ ½Éº¼ÀÌ ¾ðÁ¦³ª
17ºñÆ® À̳»ÀÇ °Å¸®¿¡ ÀÖ´Ù´Â °ÍÀ» ¾È´Ù¸é À¯¿ëÇÏ°Ô ¾²ÀÏ ¼ö ÀÖ´Ù.
For some configurations, especially those where the compiler normally does not prepend an underscore to the names of user variables, the assembler requires a `%' before any use of a register name. This is intended to let the assembler distinguish between C variables and functions named `a0' through `a7', and so on. The `%' is always accepted, but is not required for certain configurations, notably `sun3'. The `--register-prefix-optional' option may be used to permit omitting the `%' even for configurations for which it is normally required. If this is done, it will generally be impossible to refer to C variables and functions with the same names as register names.
Normally the character `|' is treated as a comment character, which means that it can not be used in expressions. The `--bitwise-or' option turns `|' into a normal character. In this mode, you must either use C style comments, or start comments with a `#' character at the beginning of a line.
as
can assemble code for several different members of the
Motorola 680x0 family. The default depends upon how as
was configured when it was built; normally, the default is to assemble
code for the 68020 microprocessor. The following options may be used to
change the default. These options control which instructions and
addressing modes are permitted. The members of the 680x0 family are
very similar. For detailed information about the differences, see the
Motorola manuals.
This syntax for the Motorola 680x0 was developed at MIT.
The 680x0 version of as
uses instructions names and
syntax compatible with the Sun assembler. Intervening periods are
ignored; for example, `movl' is equivalent to `mov.l'.
In the following table apc stands for any of the address registers (`%a0' through `%a7'), the program counter (`%pc'), the zero-address relative to the program counter (`%zpc'), a suppressed address register (`%za0' through `%za7'), or it may be omitted entirely. The use of size means one of `w' or `l', and it may be omitted, along with the leading colon, unless a scale is also specified. The use of scale means one of `1', `2', `4', or `8', and it may always be omitted along with the leading colon.
The following addressing modes are understood:
%a6
is also known as `%fp', the Frame Pointer.
The standard Motorola syntax for this chip differs from the syntax
already discussed (see section Syntax). as
can
accept Motorola syntax for operands, even if MIT syntax is used for
other operands in the same instruction. The two kinds of syntax are
fully compatible.
In the following table apc stands for any of the address registers (`%a0' through `%a7'), the program counter (`%pc'), the zero-address relative to the program counter (`%zpc'), or a suppressed address register (`%za0' through `%za7'). The use of size means one of `w' or `l', and it may always be omitted along with the leading dot. The use of scale means one of `1', `2', `4', or `8', and it may always be omitted along with the leading asterisk.
The following additional addressing modes are understood:
%a6
is also known as `%fp', the Frame Pointer.
Packed decimal (P) format floating literals are not supported. Feel free to add the code!
The floating point formats generated by directives are these.
.float
Single
precision floating point constants.
.double
Double
precision floating point constants.
.extend
.ldouble
Extended
precision (long double
) floating point constants.
In order to be compatible with the Sun assembler the 680x0 assembler understands the following directives.
.data1
.data 1
directive.
.data2
.data 2
directive.
.even
.align
directive; it
aligns the output to an even byte boundary.
.skip
.space
directive.
Certain pseudo opcodes are permitted for branch instructions. They expand to the shortest branch instruction that reach the target. Generally these mnemonics are made by substituting `j' for `b' at the start of a Motorola mnemonic.
The following table summarizes the pseudo-operations. A *
flags
cases that are more fully described after the table:
Displacement +------------------------------------------------- | 68020 68000/10 Pseudo-Op |BYTE WORD LONG LONG non-PC relative +------------------------------------------------- jbsr |bsrs bsr bsrl jsr jsr jra |bras bra bral jmp jmp * jXX |bXXs bXX bXXl bNXs;jmpl bNXs;jmp * dbXX |dbXX dbXX dbXX; bra; jmpl * fjXX |fbXXw fbXXw fbXXl fbNXw;jmp XX: condition NX: negative of condition XX
*
---see full description below
jbsr
jra
jXX
jhi jls jcc jcs jne jeq jvc jvs jpl jmi jge jlt jgt jleFor the cases of non-PC relative displacements and long displacements on the 68000 or 68010,
as
issues a longer code fragment in terms of
NX, the opposite condition to XX. For example, for the
non-PC relative case:
jXX foogives
bNXs oof jmp foo oof:
dbXX
dbhi dbls dbcc dbcs dbne dbeq dbvc dbvs dbpl dbmi dbge dblt dbgt dble dbf dbra dbtOther than for word and byte displacements, when the source reads `dbXX foo',
as
emits
dbXX oo1 bra oo2 oo1:jmpl foo oo2:
fjXX
fjne fjeq fjge fjlt fjgt fjle fjf fjt fjgl fjgle fjnge fjngl fjngle fjngt fjnle fjnlt fjoge fjogl fjogt fjole fjolt fjor fjseq fjsf fjsne fjst fjueq fjuge fjugt fjule fjult fjunFor branch targets that are not PC relative,
as
emits
fbNX oof jmp foo oof:when it encounters `fjXX foo'.
The immediate character is `#' for Sun compatibility. The line-comment character is `|' (unless the `--bitwise-or' option is used). If a `#' appears at the beginning of a line, it is treated as a comment unless it looks like `# line file', in which case it is treated normally.
GNU as
for MIPS architectures supports the MIPS
R2000, R3000, R4000 and R6000 processors. For information
about the MIPS instruction set, see MIPS RISC Architecture, by Kane
and Heindrich (Prentice-Hall). For an overview of MIPS assembly
conventions, see "Appendix D: Assembly Language Programming" in the same
work.
The MIPS configurations of GNU as
support these
special options:
-G num
gp
register. It is only accepted for targets
that use ECOFF format. The default value is 8.
-EB
-EL
as
can select big-endian or
little-endian output at run time (unlike the other GNU development
tools, which must be configured for one or the other). Use `-EB'
to select big-endian output, and `-EL' for little-endian.
-mips1
-mips2
-mips3
-m4650
-no-m4650
-m4010
-no-m4010
-mcpu=CPU
gcc
.
-nocpp
as
, there is no need for `-nocpp', because the
GNU assembler itself never runs the C preprocessor.
--trap
--no-break
as
automatically macro expands certain division and
multiplication instructions to check for overflow and division by zero. This
option causes as
to generate code to take a trap exception
rather than a break exception when an error is detected. The trap instructions
are only supported at Instruction Set Architecture level 2 and higher.
--break
--no-trap
Assembling for a MIPS ECOFF target supports some additional sections
besides the usual .text
, .data
and .bss
. The
additional sections are .rdata
, used for read-only data,
.sdata
, used for small data, and .sbss
, used for small
common objects.
When assembling for ECOFF, the assembler uses the $gp
($28
)
register to form the address of a "small object". Any object in the
.sdata
or .sbss
sections is considered "small" in this sense.
For external objects, or for objects in the .bss
section, you can use
the gcc
`-G' option to control the size of objects addressed via
$gp
; the default value is 8, meaning that a reference to any object
eight bytes or smaller uses $gp
. Passing `-G 0' to
as
prevents it from using the $gp
register on the basis
of object size (but the assembler uses $gp
for objects in .sdata
or sbss
in any case). The size of an object in the .bss
section
is set by the .comm
or .lcomm
directive that defines it. The
size of an external object may be set with the .extern
directive. For
example, `.extern sym,4' declares that the object at sym
is 4 bytes
in length, whie leaving sym
otherwise undefined.
Using small ECOFF objects requires linker support, and assumes that the
$gp
register is correctly initialized (normally done automatically by
the startup code). MIPS ECOFF assembly code must not modify the
$gp
register.
MIPS ECOFF as
supports several directives used for
generating debugging information which are not support by traditional MIPS
assemblers. These are .def
, .endef
, .dim
, .file
,
.scl
, .size
, .tag
, .type
, .val
,
.stabd
, .stabn
, and .stabs
. The debugging information
generated by the three .stab
directives can only be read by GDB,
not by traditional MIPS debuggers (this enhancement is required to fully
support C++ debugging). These directives are primarily used by compilers, not
assembly language programmers!
GNU as
supports an additional directive to change the
MIPS Instruction Set Architecture level on the fly: .set
mipsn
. n should be a number from 0 to 3. A value from 1 to 3
makes the assembler accept instructions for the corresponding ISA level,
from that point on in the assembly. .set mipsn
affects not only
which instructions are permitted, but also how certain macros are expanded.
.set mips0
restores the ISA level to its original level: either the
level you selected with command line options, or the default for your
configuration. You can use this feature to permit specific R4000
instructions while assembling in 32 bit mode. Use this directive with care!
Traditional MIPS assemblers do not support this directive.
as
has no additional command-line options for the Hitachi
SH family.
`!' is the line comment character.
You can use `;' instead of a newline to separate statements.
Since `$' has no special meaning, you may use it in symbol names.
You can use the predefined symbols `r0', `r1', `r2', `r3', `r4', `r5', `r6', `r7', `r8', `r9', `r10', `r11', `r12', `r13', `r14', and `r15' to refer to the SH registers.
The SH also has these control registers:
pr
pc
mach
macl
sr
gbr
vbr
as
understands the following addressing modes for the SH.
Rn
in the following refers to any of the numbered
registers, but not the control registers.
Rn
@Rn
@-Rn
@Rn+
@(disp, Rn)
@(R0, Rn)
@(disp, GBR)
GBR
offset
@(R0, GBR)
addr
@(disp, PC)
as
implementation allows you to use the simpler form
addr anywhere a PC relative address is called for; the alternate
form is supported for compatibility with other assemblers.
#imm
The SH family has no hardware floating point, but the .float
directive generates IEEE floating-point numbers for compatibility
with other development tools.
as
has no machine-dependent directives for the SH.
For detailed information on the SH machine instruction set, see SH-Microcomputer User's Manual (Hitachi Micro Systems, Inc.).
as
implements all the standard SH opcodes. No additional
pseudo-instructions are needed on this family. Note, however, that
because as
supports a simpler form of PC-relative
addressing, you may simply write (for example)
mov.l bar,r0
where other assemblers might require an explicit displacement to
bar
from the program counter:
mov.l @(disp, PC)
The SPARC chip family includes several successive levels, using the same core instruction set, but including a few additional instructions at each level. There are exceptions to this however. For details on what instructions each variant supports, please see the chip's architecture reference manual.
By default, as
assumes the core instruction set (SPARC
v6), but "bumps" the architecture level as needed: it switches to
successively higher architectures as it encounters instructions that
only exist in the higher levels.
If not configured for SPARC v9 (sparc64-*-*
) GAS will not bump
passed sparclite by default, an option must be passed to enable the
v9 instructions.
GAS treats sparclite as being compatible with v8, unless an architecture is explicitly requested. SPARC v9 is always incompatible with sparclite.
-Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite | -Av9 | -Av9a
as
reports a fatal error if it encounters an instruction
or feature requiring a higher level.
-xarch=v8plus | -xarch=v8plusa
-bump
The Sparc uses IEEE floating-point numbers.
The Sparc version of as
supports the following additional
machine directives:
.align
.common
"bss"
. This behaves somewhat like .comm
, but the
syntax is different.
.half
.short
.
.proc
.reserve
"bss"
. This behaves somewhat like .lcomm
, but the
syntax is different.
.seg
"text"
, "data"
, or
"data1"
. It behaves like .text
, .data
, or
.data 1
.
.skip
.space
directive.
.word
.word
directive produces 32 bit values,
instead of the 16 bit values it produces on many other machines.
.xword
.xword
directive produces
64 bit values.
The Z8000 as supports both members of the Z8000 family: the unsegmented Z8002, with 16 bit addresses, and the segmented Z8001 with 24 bit addresses.
When the assembler is in unsegmented mode (specified with the
unsegm
directive), an address takes up one word (16 bit)
sized register. When the assembler is in segmented mode (specified with
the segm
directive), a 24-bit address takes up a long (32 bit)
register. See section Assembler Directives for the Z8000,
for a list of other Z8000 specific assembler directives.
as
has no additional command-line options for the Zilog
Z8000 family.
`!' is the line comment character.
You can use `;' instead of a newline to separate statements.
The Z8000 has sixteen 16 bit registers, numbered 0 to 15. You can refer to different sized groups of registers by register number, with the prefix `r' for 16 bit registers, `rr' for 32 bit registers and `rq' for 64 bit registers. You can also refer to the contents of the first eight (of the sixteen 16 bit registers) by bytes. They are named `rnh' and `rnl'.
byte registers r0l r0h r1h r1l r2h r2l r3h r3l r4h r4l r5h r5l r6h r6l r7h r7l word registers r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 long word registers rr0 rr2 rr4 rr6 rr8 rr10 rr12 rr14 quad word registers rq0 rq4 rq8 rq12
as understands the following addressing modes for the Z8000:
rn
@rn
addr
address(rn)
rn(#imm)
rn(rm)
#xx
The Z8000 port of as includes these additional assembler directives, for compatibility with other Z8000 assemblers. As shown, these do not begin with `.' (unlike the ordinary as directives).
segm
unsegm
name
.file
global
.global
wval
.word
lval
.long
bval
.byte
sval
sval
expects one string literal, delimited by
single quotes. It assembles each byte of the string into consecutive
addresses. You can use the escape sequence `%xx' (where
xx represents a two-digit hexadecimal number) to represent the
character whose ASCII value is xx. Use this feature to
describe single quote and other characters that may not appear in string
literals as themselves. For example, the C statement `char *a =
"he said \"it's 50% off\"";' is represented in Z8000 assembly language
(shown with the assembler output in hex at the left) as
@begingroup
@let@nonarrowing=@comment
68652073 sval 'he said %22it%27s 50%25 off%22%00' 61696420 22697427 73203530 25206F66 662200@endgroup
rsect
.section
block
.space
even
.align
; aligns output to even byte boundary.
For detailed information on the Z8000 machine instruction set, see Z8000 Technical Manual.
The Vax version of as
accepts any of the following options,
gives a warning message that the option was ignored and proceeds.
These options are for compatibility with scripts designed for other
people's assemblers.
-D
(Debug)
-S
(Symbol Table)
-T
(Token Trace)
-d
(Displacement size for JUMPs)
-V
(Virtualize Interpass Temporary File)
as
always does this, so this
option is redundant.
-J
(JUMPify Longer Branches)
-t
(Temporary File Directory)
as
does not use a temporary disk file, this
option makes no difference. `-t' needs exactly one
filename.
The Vax version of the assembler accepts two options when
compiled for VMS. They are `-h', and `-+'. The
`-h' option prevents as
from modifying the
symbol-table entries for symbols that contain lowercase
characters (I think). The `-+' option causes as
to
print warning messages if the FILENAME part of the object file,
or any symbol name is larger than 31 characters. The `-+'
option also inserts some code following the `_main'
symbol so that the object file is compatible with Vax-11
"C".
Conversion of flonums to floating point is correct, and compatible with previous assemblers. Rounding is towards zero if the remainder is exactly half the least significant bit.
D
, F
, G
and H
floating point formats
are understood.
Immediate floating literals (e.g. `S`$6.9') are rendered correctly. Again, rounding is towards zero in the boundary case.
The .float
directive produces f
format numbers.
The .double
directive produces d
format numbers.
The Vax version of the assembler supports four directives for generating Vax floating point constants. They are described in the table below.
.dfloat
d
format 64-bit floating point constants.
.ffloat
f
format 32-bit floating point constants.
.gfloat
g
format 64-bit floating point constants.
.hfloat
h
format 128-bit floating point constants.
All DEC mnemonics are supported. Beware that case...
instructions have exactly 3 operands. The dispatch table that
follows the case...
instruction should be made with
.word
statements. This is compatible with all unix
assemblers we know of.
Certain pseudo opcodes are permitted. They are for branch instructions. They expand to the shortest branch instruction that reaches the target. Generally these mnemonics are made by substituting `j' for `b' at the start of a DEC mnemonic. This feature is included both for compatibility and to help compilers. If you do not need this feature, avoid these opcodes. Here are the mnemonics, and the code they can expand into.
jbsb
jbr
jr
jCOND
neq
, nequ
, eql
, eqlu
, gtr
,
geq
, lss
, gtru
, lequ
, vc
, vs
,
gequ
, cc
, lssu
, cs
.
COND may also be one of the bit tests
bs
, bc
, bss
, bcs
, bsc
, bcc
,
bssi
, bcci
, lbs
, lbc
.
NOTCOND is the opposite condition to COND.
jacbX
b d f g h l w
.
OPCODE ..., foo ; brb bar ; foo: jmp ... ; bar:
jaobYYY
lss leq
.
jsobZZZ
geq gtr
.
OPCODE ..., foo ; brb bar ; foo: brw destination ; bar:
OPCODE ..., foo ; brb bar ; foo: jmp destination ; bar:
aobleq
aoblss
sobgeq
sobgtr
OPCODE ..., foo ; brb bar ; foo: brw destination ; bar:
OPCODE ..., foo ; brb bar ; foo: jmp destination ; bar:
The immediate character is `$' for Unix compatibility, not `#' as DEC writes it.
The indirect character is `*' for Unix compatibility, not `@' as DEC writes it.
The displacement sizing character is ``' (an accent grave) for
Unix compatibility, not `^' as DEC writes it. The letter
preceding ``' may have either case. `G' is not
understood, but all other letters (b i l s w
) are understood.
Register names understood are r0 r1 r2 ... r15 ap fp sp
pc
. Upper and lower case letters are equivalent.
For instance
tstb *w`$4(r5)
Any expression is permitted in an operand. Operands are comma separated.
Vax bit fields can not be assembled with as
. Someone
can add the required code if they really need it.
Go to the first, previous, next, last section, table of contents.