Go to the first, previous, next, last section, table of contents.


±â°è¿¡ ÀÇÁ¸ÇÏ´Â °Íµé

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.

AMD 29K Dependent Features

Options

as has no additional command-line options for the AMD 29K family.

Syntax

Macros

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.

Special Characters

`;' is the line comment character.

The character `?' is permitted in identifiers (but may not begin an identifier).

Register Names

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

Floating Point

The AMD 29K family uses IEEE floating-point numbers.

AMD 29K Machine Directives

.block size , fill
This directive emits size bytes, each of value fill. Both size and fill are absolute expressions. If the comma and fill are omitted, fill is assumed to be zero. In other versions of the GNU assembler, this directive is called `.space'.
.cputype
This directive is ignored; it is accepted for compatibility with other AMD 29K assemblers.
.file
This directive is ignored; it is accepted for compatibility with other AMD 29K assemblers.

Warning: in other versions of the GNU assembler, .file is used for the directive called .app-file in the AMD 29K support.

.line
This directive is ignored; it is accepted for compatibility with other AMD 29K assemblers.
.sect
This directive is ignored; it is accepted for compatibility with other AMD 29K assemblers.
.use section name
Establishes the section and subsection for the following code; section name may be one of .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'.

Opcodes

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.

H8/300 Dependent Features

Options

as has no additional command-line options for the Hitachi H8/300 family.

Syntax

Special Characters

`;' 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.

Register Names

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.

Addressing Modes

as understands the following addressing modes for the H8/300:

rn
Register direct
@rn
Register indirect
@(d, rn)
@(d:16, rn)
@(d:24, rn)
Register indirect: 16-bit or 24-bit displacement d from register n. (24-bit displacements are only meaningful on the H8/300H.)
@rn+
Register indirect with post-increment
@-rn
Register indirect with pre-decrement
@aa
@aa:8
@aa:16
@aa:24
Absolute address aa. (The address size `:24' only makes sense on the H8/300H.)
#xx
#xx:8
#xx:16
#xx:32
Immediate data xx. You may specify the `:8', `:16', or `:32' for clarity, if you wish; but as neither requires this nor uses it--the data size required is taken from context.
@@aa
@@aa:8
Memory indirect. You may specify the `:8' for clarity, if you wish; but as neither requires this nor uses it.

Floating Point

The H8/300 family has no hardware floating point, but the .float directive generates IEEE floating-point numbers for compatibility with other development tools.

H8/300 Machine Directives

as has only one machine-dependent directive for the H8/300:

.h8300h
Recognize and emit additional instructions for the H8/300H variant, and also make .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.

Opcodes

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.

H8/500 Dependent Features

Options

as has no additional command-line options for the Hitachi H8/500 family.

Syntax

Special Characters

`!' 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.

Register 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
code pointer
dp
data pointer
bp
base pointer
tp
stack top pointer
ep
extra pointer
sr
status register
ccr
condition code register

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.

Addressing Modes

as understands the following addressing modes for the H8/500:

Rn
Register direct
@Rn
Register indirect
@(d:8, Rn)
Register indirect with 8 bit signed displacement
@(d:16, Rn)
Register indirect with 16 bit signed displacement
@-Rn
Register indirect with pre-decrement
@Rn+
Register indirect with post-increment
@aa:8
8 bit absolute address
@aa:16
16 bit absolute address
#xx:8
8 bit immediate
#xx:16
16 bit immediate

Floating Point

The H8/500 family has no hardware floating point, but the .float directive generates IEEE floating-point numbers for compatibility with other development tools.

H8/500 Machine Directives

as has no machine-dependent directives for the H8/500. However, on this platform the `.int' and `.word' directives generate 16-bit numbers.

Opcodes

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.

HPPA Dependent Features

Notes

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.

Options

as has no machine-dependent command-line options for the HPPA.

Syntax

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.

Floating Point

The HPPA family uses IEEE floating-point numbers.

HPPA Assembler Directives

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
Reserve n bytes of storage, and initialize them to zero.
.call
Mark the beginning of a procedure call. Only the special case with no arguments is allowed.
.callinfo [ param=value, ... ] [ flag, ... ]
Specify a number of parameters and flags that define the environment for a procedure. param may be any of `frame' (frame size), `entry_gr' (end of general register range), `entry_fr' (end of float register range), `entry_sr' (end of space register range). The values for flag are `calls' or `caller' (proc has subroutines), `no_calls' (proc does not call subroutines), `save_rp' (preserve return pointer), `save_sp' (proc preserves stack pointer), `no_unwind' (do not unwind this proc), `hpux_int' (proc is interrupt routine).
.code
Assemble into the standard section called `$TEXT$', subsection `$CODE$'.
.copyright "string"
In the SOM object format, insert string into the object code, marked as a copyright string.
.copyright "string"
In the ELF object format, insert string into the object code, marked as a version string.
.enter
Not yet supported; the assembler rejects programs containing this directive.
.entry
Mark the beginning of a procedure.
.exit
Mark the end of a procedure.
.export name [ ,typ ] [ ,param=r ]
Make a procedure name available to callers. typ, if present, must be one of `absolute', `code' (ELF only, not SOM), `data', `entry', `data', `entry', `millicode', `plabel', `pri_prog', or `sec_prog'. param, if present, provides either relocation information for the procedure arguments and result, or a privilege level. param may be `argwn' (where n ranges from 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
Define a two-byte integer constant n; synonym for the portable as directive .short.
.import name [ ,typ ]
Converse of .export; make a procedure available to call. The arguments use the same conventions as the first two arguments for .export.
.label name
Define name as a label for the current assembly location.
.leave
Not yet supported; the assembler rejects programs containing this directive.
.origin lc
Advance location counter to lc. Synonym for the portable directive .org.
.param name [ ,typ ] [ ,param=r ]
Similar to .export, but used for static procedures.
.proc
Use preceding the first statement of a procedure.
.procend
Use following the last statement of a procedure.
label .reg expr
Synonym for .equ; define label with the absolute expression expr as its value.
.space secname [ ,params ]
Switch to section secname, creating a new section by that name if necessary. You may only use params when creating a new section, not when switching to an existing one. secname may identify a section by number rather than by name. If specified, the list params declares attributes of the section, identified by keywords. The keywords recognized are `spnum=exp' (identify this section by the number exp, an absolute expression), `sort=exp' (order sections according to this sort key when linking; exp is an absolute expression), `unloadable' (section contains no loadable data), `notdefined' (this section defined elsewhere), and `private' (data in this section not available to other programs).
.spnum secnam
Allocate four bytes of storage, and initialize them with the section number of the section named secnam. (You can define the section number with the HPPA .space directive.)
.string "str"
Copy the characters in the string str to the object file. See section .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"
Like .string, but appends a zero byte after copying str to object file.
.subspa name [ ,params ]
.nsubspa name [ ,params ]
Similar to .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"
Write str as version identifier in object code.

Opcodes

For detailed information on the HPPA machine instruction set, see PA-RISC Architecture and Instruction Set Reference Manual (HP 09740-90039).

80386¿¡¼­ÀÇ ÀÇÁ¸ÀûÀΠƯ¡

¿É¼Ç

as¿¡´Â ÇöÀç 80386¿¡ °ü·ÃµÈ ±â°è ÀÇÁ¸ÀûÀÎ ¿É¼ÇÀº ¾ø´Ù.

AT&T ¹®¹ý ´ë Intel ¹®¹ý

gcc¿Í asÀÇ Ãâ·Â°ú ÇÔ²² ȣȯ¼ºÀ» À¯ÁöÇÒ ¸ñÀûÀ¸·Î AT&T ½Ã½ºÅÛ V/386 ¾î¼Àºí·¯ ¹®¹ýÀ» Á¦°øÇÑ´Ù. ÀÌ°ÍÀº ÀÎÅÚ ¹®¹ý°ú ´Ù¼Ò°£ Â÷ÀÌ°¡ ÀÖ´Ù. °ÅÀÇ ´ëºÎºÐÀÇ 80386À» ¼³¸íÇÏ´Â ¹®¼­µéÀº ÀÎÅÚ ¹®¹ý¸¸À» »ç¿ëÇϱ⠶§¹®¿¡ ¿©±â ¼­´Â ÀÌ·¯ÇÑ Â÷ÀÌÁ¡µé¿¡ ´ëÇؼ­ ¼³¸íÇÑ´Ù. µÎ ¹®¹ý¿¡¼­ÀÇ ÁÖ¸ñÇÒ ¸¸ÇÑ Â÷ÀÌÁ¡µéÀº ´ÙÀ½°ú °°´Ù.

ÀÛµ¿ÀÚ(opcode) ¸íĪ

ÀÛµ¿ÀÚ¿¡´Â ÇÇ¿¬»êÀÚÀÇ Å©±â¸¦ ¸í½ÃÇÏ´Â ÇϳªÀÇ ±ÛÀÚ°¡ ²¿¸®¿¡ ºÙ´Â´Ù. `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 ½ºÅ¸ÀÏÀÇ ¸Þ¸ð¸® ÂüÁ¶¸¦ ÇÏ´Â ¸î¸î ¿¹¸¦ ½Æ´Â´Ù.

AT&T: `-4(%ebp)', Intel: `[ebp - 4]'
base´Â `%ebp'ÀÌ°í disp´Â `-4' ÀÌ´Ù. sectionÀº ºüÁ® ÀÖÀ¸¸ç, µðÆúÆ® ¼½¼ÇÀÌ »ç¿ëµÈ´Ù(º£À̽º ·¹Áö½ºÅÍ·Î `%ebp'¿Í ÇÔ²² ¾îµå·¹½ÌÀ» ÇÒ `%ss'). index, scale µÑ ´Ù ºüÁ® ÀÖ´Ù.
AT&T: `foo(,%eax,4)', Intel: `[foo + eax*4]'
index´Â `%eax'(scale 4·Î ´ÜÀ§È­µÇ´Â)ÀÌ°í disp´Â `foo'ÀÌ´Ù. ´Ù¸¥ ÇʵåµéÀº ºüÁ® ÀÖÀ¸¸ç ¼½¼Ç ·¹Áö½ºÅÍ´Â µðÆúÆ®·Î `%ds'°¡ »ç¿ëµÈ´Ù.
AT&T: `foo(,1)'; Intel `[foo]'
ÀÌ°ÍÀº ¸Þ¸ð¸® ÇÇ¿¬»êÀڷμ­ `foo'¿¡ ÀÇÇØ Æ÷ÀÎÅÍ µÇ´Â °ªÀÌ´Ù. base¿Í index°¡ ºüÁ® ÀÖÀ¸³ª, ´ÜÁö ÇϳªÀÇ `,'°¡ ÀÖÀ» »ÓÀÌ´Ù. ÀÌ°ÍÀº ¹®¹ý»óÀÇ ¿¹¿ÜÀÌ´Ù.
AT&T: `%gs:foo'; Intel `gs:foo'
ÀÌ°ÍÀº ¼½¼Ç ·¹Áö½ºÅÍ-section `%gs'¿Í ÇÔ²² `foo'°¡ °¡¸£Å°´Â °ªÀ» ÀǹÌÇÑ´Ù.

Àý´ëÀûÀÎ(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'¸¦ ¾² °íÀÚ ÇÑ´Ù¸é ±×°ÍÀº Á¤È®È÷ ÄÚµå¼Ó¿¡ Æ÷ÇÔÇÏ¿©¾ß ÇÑ´Ù.

Writing 16-bit Code

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'ÀÌ µÉ ¼ö ÀÖÀ» °ÍÀÌ´Ù.

Intel 80960 Dependent Features

i960 Command-line Options

-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
Select the 80960 architecture. Instructions or features not supported by the selected architecture cause fatal errors. `-ACA' is equivalent to `-ACA_A'; `-AKC' is equivalent to `-AMC'. Synonyms are provided for compatibility with other tools. If you do not specify any of these options, 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
Add code to collect information about conditional branches taken, for later optimization using branch prediction bits. (The conditional branch instructions have branch prediction bits in the CA, CB, and CC architectures.) If BR represents a conditional branch instruction, the following represents the code generated by the assembler when `-b' is specified:
        call    increment routine
        .word   0       # pre-counter
Label:  BR
        call    increment routine
        .word   0       # post-counter
The 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
Normally, Compare-and-Branch instructions with targets that require displacements greater than 13 bits (or that have external targets) are replaced with the corresponding compare (or `chkbit') and branch instructions. You can use the `-no-relax' option to specify that 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'.

Floating Point

as generates IEEE floating-point numbers for the directives `.float', `.double', `.extended', and `.single'.

i960 Machine Directives

.bss symbol, length, align
Reserve length bytes in the bss section for a local symbol, aligned to the power of two specified by align. length and align must be positive absolute expressions. This directive differs from `.lcomm' only in that it permits you to specify an alignment. See section .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
You can use the `.leafproc' directive in conjunction with the optimized 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
The `.sysproc' directive defines a name for a system procedure. After you define it using `.sysproc', you can use name to refer to the system procedure identified by index when calling procedures with the optimized call instruction `callj'. Both arguments are required; index must be between 0 and 31 (inclusive).

i960 Opcodes

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.

Compare-and-Branch

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:

M680x0 Dependent Features

M680x0 Options

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.

`-m68000'
`-m68008'
`-m68302'
Assemble for the 68000. `-m68008' and `-m68302' are synonyms for `-m68000', since the chips are the same from the point of view of the assembler.
`-m68010'
Assemble for the 68010.
`-m68020'
Assemble for the 68020. This is normally the default.
`-m68030'
Assemble for the 68030.
`-m68040'
Assemble for the 68040.
`-m68060'
Assemble for the 68060.
`-mcpu32'
`-m68331'
`-m68332'
`-m68333'
`-m68340'
`-m68360'
Assemble for the CPU32 family of chips.
`-m68881'
`-m68882'
Assemble 68881 floating point instructions. This is the default for the 68020, 68030, and the CPU32. The 68040 and 68060 always support floating point instructions.
`-mno-68881'
Do not assemble 68881 floating point instructions. This is the default for 68000 and the 68010. The 68040 and 68060 always support floating point instructions, even if this option is used.
`-m68851'
Assemble 68851 MMU instructions. This is the default for the 68020, 68030, and 68060. The 68040 accepts a somewhat different set of MMU instructions; `-m68851' and `-m68040' should not be used together.
`-mno-68851'
Do not assemble 68851 MMU instructions. This is the default for the 68000, 68010, and the CPU32. The 68040 accepts a somewhat different set of MMU instructions.

Syntax

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:

Immediate
`#number'
Data Register
`%d0' through `%d7'
Address Register
`%a0' through `%a7'
`%a7' is also known as `%sp', i.e. the Stack Pointer. %a6 is also known as `%fp', the Frame Pointer.
Address Register Indirect
`%a0@' through `%a7@'
Address Register Postincrement
`%a0@+' through `%a7@+'
Address Register Predecrement
`%a0@-' through `%a7@-'
Indirect Plus Offset
`apc@(number)'
Index
`apc@(number,register:size:scale)' The number may be omitted.
Postindex
`apc@(number)@(onumber,register:size:scale)' The onumber or the register, but not both, may be omitted.
Preindex
`apc@(number,register:size:scale)@(onumber)' The number may be omitted. Omitting the register produces the Postindex addressing mode.
Absolute
`symbol', or `digits', optionally followed by `:b', `:w', or `:l'.

Motorola Syntax

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:

Address Register Indirect
`(%a0)' through `(%a7)'
`%a7' is also known as `%sp', i.e. the Stack Pointer. %a6 is also known as `%fp', the Frame Pointer.
Address Register Postincrement
`(%a0)+' through `(%a7)+'
Address Register Predecrement
`-(%a0)' through `-(%a7)'
Indirect Plus Offset
`number(%a0)' through `number(%a7)', or `number(%pc)'. The number may also appear within the parentheses, as in `(number,%a0)'. When used with the pc, the number may be omitted (with an address register, omitting the number produces Address Register Indirect mode).
Index
`number(apc,register.size*scale)' The number may be omitted, or it may appear within the parentheses. The apc may be omitted. The register and the apc may appear in either order. If both apc and register are address registers, and the size and scale are omitted, then the first register is taken as the base register, and the second as the index register.
Postindex
`([number,apc],register.size*scale,onumber)' The onumber, or the register, or both, may be omitted. Either the number or the apc may be omitted, but not both.
Preindex
`([number,apc,register.size*scale],onumber)' The number, or the apc, or the register, or any two of them, may be omitted. The onumber may be omitted. The register and the apc may appear in either order. If both apc and register are address registers, and the size and scale are omitted, then the first register is taken as the base register, and the second as the index register.

Floating Point

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.

680x0 Machine Directives

In order to be compatible with the Sun assembler the 680x0 assembler understands the following directives.

.data1
This directive is identical to a .data 1 directive.
.data2
This directive is identical to a .data 2 directive.
.even
This directive is a special case of the .align directive; it aligns the output to an even byte boundary.
.skip
This directive is identical to a .space directive.

Opcodes

Branch Improvement

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
These are the simplest jump pseudo-operations; they always map to one particular machine instruction, depending on the displacement to the branch target.
jXX
Here, `jXX' stands for an entire family of pseudo-operations, where XX is a conditional branch or condition-code test. The full list of pseudo-ops in this family is:
 jhi   jls   jcc   jcs   jne   jeq   jvc
 jvs   jpl   jmi   jge   jlt   jgt   jle
For 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 foo
gives
     bNXs oof
     jmp foo
 oof:
dbXX
The full family of pseudo-operations covered here is
 dbhi   dbls   dbcc   dbcs   dbne   dbeq   dbvc
 dbvs   dbpl   dbmi   dbge   dblt   dbgt   dble
 dbf    dbra   dbt
Other than for word and byte displacements, when the source reads `dbXX foo', as emits
     dbXX oo1
     bra oo2
 oo1:jmpl foo
 oo2:
fjXX
This family includes
 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  fjun
For branch targets that are not PC relative, as emits
     fbNX oof
     jmp foo
 oof:
when it encounters `fjXX foo'.

Special Characters

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.

MIPS Dependent Features

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.

Assembler options

The MIPS configurations of GNU as support these special options:

-G num
This option sets the largest size of an object that can be referenced implicitly with the gp register. It is only accepted for targets that use ECOFF format. The default value is 8.
-EB
-EL
Any MIPS configuration of 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
Generate code for a particular MIPS Instruction Set Architecture level. `-mips1' corresponds to the R2000 and R3000 processors, `-mips2' to the R6000 processor, and `-mips3' to the R4000 processor. You can also switch instruction sets during the assembly; see section Directives to override the ISA level.
-m4650
-no-m4650
Generate code for the MIPS R4650 chip. This tells the assembler to accept the `mad' and `madu' instruction, and to not schedule `nop' instructions around accesses to the `HI' and `LO' registers. `-no-m4650' turns off this option.
-m4010
-no-m4010
Generate code for the LSI R4010 chip. This tells the assembler to accept the R4010 specific instructions (`addciu', `ffc', etc.), and to not schedule `nop' instructions around accesses to the `HI' and `LO' registers. `-no-m4010' turns off this option.
-mcpu=CPU
Generate code for a particular MIPS cpu. This has little effect on the assembler, but it is passed by gcc.
-nocpp
This option is ignored. It is accepted for command-line compatibility with other assemblers, which use it to turn off C style preprocessing. With GNU 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
Generate code to take a break exception rather than a trap exception when an error is detected. This is the default.

MIPS ECOFF object code

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.

Directives for debugging information

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!

Directives to override the ISA level

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.

Hitachi SH Dependent Features

Options

as has no additional command-line options for the Hitachi SH family.

Syntax

Special Characters

`!' 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.

Register 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
procedure register (holds return address)
pc
program counter
mach
macl
high and low multiply accumulator registers
sr
status register
gbr
global base register
vbr
vector base register (for interrupt vectors)

Addressing Modes

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
Register direct
@Rn
Register indirect
@-Rn
Register indirect with pre-decrement
@Rn+
Register indirect with post-increment
@(disp, Rn)
Register indirect with displacement
@(R0, Rn)
Register indexed
@(disp, GBR)
GBR offset
@(R0, GBR)
GBR indexed
addr
@(disp, PC)
PC relative address (for branch or for addressing memory). The 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
Immediate data

Floating Point

The SH family has no hardware floating point, but the .float directive generates IEEE floating-point numbers for compatibility with other development tools.

SH Machine Directives

as has no machine-dependent directives for the SH.

Opcodes

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)

SPARC Dependent Features

Options

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
Use one of the `-A' options to select one of the SPARC architectures explicitly. If you select an architecture explicitly, as reports a fatal error if it encounters an instruction or feature requiring a higher level.
-xarch=v8plus | -xarch=v8plusa
For compatibility with the Solaris v9 assembler. These options are equivalent to -Av9 and -Av9a, respectively.
-bump
Warn whenever it is necessary to switch to another level. If an architecture level is explicitly requested, GAS will not issue warnings until that level is reached, and will then bump the level as required (except between incompatible levels).

Floating Point

The Sparc uses IEEE floating-point numbers.

Sparc Machine Directives

The Sparc version of as supports the following additional machine directives:

.align
This must be followed by the desired alignment in bytes.
.common
This must be followed by a symbol name, a positive number, and "bss". This behaves somewhat like .comm, but the syntax is different.
.half
This is functionally identical to .short.
.proc
This directive is ignored. Any text following it on the same line is also ignored.
.reserve
This must be followed by a symbol name, a positive number, and "bss". This behaves somewhat like .lcomm, but the syntax is different.
.seg
This must be followed by "text", "data", or "data1". It behaves like .text, .data, or .data 1.
.skip
This is functionally identical to the .space directive.
.word
On the Sparc, the .word directive produces 32 bit values, instead of the 16 bit values it produces on many other machines.
.xword
On the Sparc V9 processor, the .xword directive produces 64 bit values.

Z8000 Dependent Features

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.

Options

as has no additional command-line options for the Zilog Z8000 family.

Syntax

Special Characters

`!' is the line comment character.

You can use `;' instead of a newline to separate statements.

Register Names

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

Addressing Modes

as understands the following addressing modes for the Z8000:

rn
Register direct
@rn
Indirect register
addr
Direct: the 16 bit or 24 bit address (depending on whether the assembler is in segmented or unsegmented mode) of the operand is in the instruction.
address(rn)
Indexed: the 16 or 24 bit address is added to the 16 bit register to produce the final address in memory of the operand.
rn(#imm)
Base Address: the 16 or 24 bit register is added to the 16 bit sign extended immediate displacement to produce the final address in memory of the operand.
rn(rm)
Base Index: the 16 or 24 bit register rn is added to the sign extended 16 bit index register rm to produce the final address in memory of the operand.
#xx
Immediate data xx.

Assembler Directives for the Z8000

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
Generates code for the segmented Z8001.
unsegm
Generates code for the unsegmented Z8002.
name
Synonym for .file
global
Synonym for .global
wval
Synonym for .word
lval
Synonym for .long
bval
Synonym for .byte
sval
Assemble a string. 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
synonym for .section
block
synonym for .space
even
special case of .align; aligns output to even byte boundary.

Opcodes

For detailed information on the Z8000 machine instruction set, see Z8000 Technical Manual.

VAX Dependent Features

VAX Command-Line Options

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)
These are obsolete options used to debug old assemblers.
-d (Displacement size for JUMPs)
This option expects a number following the `-d'. Like options that expect filenames, the number may immediately follow the `-d' (old standard) or constitute the whole of the command line argument that follows `-d' (GNU standard).
-V (Virtualize Interpass Temporary File)
Some other assemblers use a temporary file. This option commanded them to keep the information in active memory rather than in a disk file. as always does this, so this option is redundant.
-J (JUMPify Longer Branches)
Many 32-bit computers permit a variety of branch instructions to do the same job. Some of these instructions are short (and fast) but have a limited range; others are long (and slow) but can branch anywhere in virtual memory. Often there are 3 flavors of branch: short, medium and long. Some other assemblers would emit short and medium branches, unless told by this option to emit short and long branches.
-t (Temporary File Directory)
Some other assemblers may use a temporary file, and this option takes a filename being the directory to site the temporary file. Since 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".

VAX Floating Point

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.

Vax Machine Directives

The Vax version of the assembler supports four directives for generating Vax floating point constants. They are described in the table below.

.dfloat
This expects zero or more flonums, separated by commas, and assembles Vax d format 64-bit floating point constants.
.ffloat
This expects zero or more flonums, separated by commas, and assembles Vax f format 32-bit floating point constants.
.gfloat
This expects zero or more flonums, separated by commas, and assembles Vax g format 64-bit floating point constants.
.hfloat
This expects zero or more flonums, separated by commas, and assembles Vax h format 128-bit floating point constants.

VAX Opcodes

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.

VAX Branch Improvement

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
`Jsb' is already an instruction mnemonic, so we chose `jbsb'.
(byte displacement)
bsbb ...
(word displacement)
bsbw ...
(long displacement)
jsb ...
jbr
jr
Unconditional branch.
(byte displacement)
brb ...
(word displacement)
brw ...
(long displacement)
jmp ...
jCOND
COND may be any one of the conditional branches 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.
(byte displacement)
bCOND ...
(word displacement)
bNOTCOND foo ; brw ... ; foo:
(long displacement)
bNOTCOND foo ; jmp ... ; foo:
jacbX
X may be one of b d f g h l w.
(word displacement)
OPCODE ...
(long displacement)
OPCODE ..., foo ;
brb bar ;
foo: jmp ... ;
bar:
jaobYYY
YYY may be one of lss leq.
jsobZZZ
ZZZ may be one of geq gtr.
(byte displacement)
OPCODE ...
(word displacement)
OPCODE ..., foo ;
brb bar ;
foo: brw destination ;
bar:
(long displacement)
OPCODE ..., foo ;
brb bar ;
foo: jmp destination ;
bar:
aobleq
aoblss
sobgeq
sobgtr
(byte displacement)
OPCODE ...
(word displacement)
OPCODE ..., foo ;
brb bar ;
foo: brw destination ;
bar:
(long displacement)
OPCODE ..., foo ;
brb bar ;
foo: jmp destination ;
bar:

VAX Operands

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.

Not Supported on VAX

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.