Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
  Previous   Contents   Next 
   
 
Chapter 5

Instruction-Set Mapping

The tables in this chapter describe the relationship between hardware instructions of the SPARC architecture, as defined in The SPARC Architecture Manual and the assembly language instruction set recognized by the SunOS 5.x SPARC assembler.

The SPARC-V9 instruction set is described in Appendix E, SPARC-V9 Instruction Set.

5.1 Table Notation

Table 5-1 shows the table notation used in this chapter to describe the instruction set of the assembler. The following notations are commonly suffixed to assembler mnemonics (uppercase letters refer to SPARC architecture instruction names.

Table 5-1

Notations

Describes

Comment

address

regrs1 + regrs2

regrs1 + const13

regrs1 - const13

const13 + regrs1

const13

Address formed from register contents, immediate constant, or both.

asi

 

Alternate address space identifier; an unsigned 8-bit value. It can be the result of the evaluation of a symbol expression.

const13

 

A signed constant which fits in 13 bits. It can be the result of the evaluation of a symbol expression.

const22

 

A constant which fits in 22 bits. It can be the result of the evaluation of a symbol expression.

creg

%c0 ... %c31

Coprocessor registers.

freg

%f0 ... %f31

Floating-point registers.

imm7

 

A signed or unsigned constant that can be represented in 7 bits (it is in the range -64 ... 127). It can be the result of the evaluation of a symbol expression.

reg

%r0 ... %r31

General purpose registers.

 

%g0 ... %g7

Same as %r0 ... %r7 (Globals)

 

%o0 ... %o7

Same as %r8 ... %r15 (Outs)

 

%l0 ... %l7

Same as %r16 ... %r23 (Locals)

 

%i0 ... %i7

Same as %r24 ... %r31 (Ins)

regrd

 

Destination register.

regrs1, regrs2

 

Source register 1, source register 2.

reg_or_imm

regrs2, const13

Value from either a single register, or an immediate constant.

regaddr

regrs1 regrs1 + regrs2

Address formed with register contents only.

Software_trap_number

regrs1 + regrs2

regrs1 + imm7

regrs1 - imm7

uimm7

imm7 + regrs1

A value formed from register contents, immediate constant, or both. The resulting value must be in the range 0.....127, inclusive.

uimm7

 

An unsigned constant that can be represented in 7 bits (it is in the range 0 ... 127). It can be the result of the evaluation of a symbol expression.

5.2 Integer Instructions

The notations described in Table 5-2 are commonly suffixed to assembler mnemonics (uppercase letters for architecture instruction names).

Table 5-2

Notation

Description

a

Instructions that deal with alternate space

b

Byte instructions

c

Reference to coprocessor registers

d

Doubleword instructions

f

Reference to floating-point registers

h

Halfword instructions

q

Quadword instructions

sr

Status register

Table 5-3 outlines the correspondence between SPARC hardware integer instructions and SPARC assembly language instructions.

The syntax of individual instructions is designed so that a destination operand (if any), which may be either a register or a reference to a memory location, is always the last operand in a statement.


Note - In Table 5-3,

  • Braces ({ }) indicate optional arguments.

    Braces are not literally coded.

  • Brackets ([ ]) indicate indirection: the contents of the addressed memory location are being read from or written to.

    Brackets are coded literally in the assembly language. Note that the usage of brackets described in Chapter 2, Assembler Syntax differs from the usage of these brackets.

  • All Bicc and Bfcc instructions described may indicate that the annul bit is to be set by appending ",a" to the opcode mnemonic; for example,

"bgeu,a label"

Table 5-3

Opcode

Mnemonic

Argument List

Operation

Comments

ADD

add

regrs1, reg_or_imm, regrd

Add

 

ADDcc

addcc

regrs1, reg_or_imm, regrd

Add and modify icc

 

ADDX

addx

regrs1, reg_or_imm, regrd

Add with carry

 

ADDXcc

addxcc

regrs1, reg_or_imm, regrd

 

 

AND

and

regrs1, reg_or_imm, regrd

And

 

ANDcc

andcc

regrs1, reg_or_imm, regrd

 

 

ANDcc

andn

regrs1, reg_or_imm, regrd

 

 

ANDNcc

andcc

regrs1, reg_or_imm, regrd

 

 

BN

bn{,a}

label

Branch on integer condition codes

branch never

BNE

bne{,a}

label

 

synonym: bnz

BE

BG

BLE

BGE

BI

BGU

BLEU

be{,a}

bg{,a}

ble{,a}

bge{,a}

bl{,a}

bgu{,a}

bleu{,a}

label

label

label

label

label

label

label

 

synonym: bz

BCC

bcc{,a}

label

 

synonym: bgeu

BCS

BPOS

BNEG

BVC

BVS

bcs{,a}

bpos{,a}

bneg{,a}

bvc{,a}

bvs{,a}

label

label

label

label

label

 

synonym: blu

BA

ba{,a}

label

 

synonym: b

CALL

call

label

Call subprogram

 

CBccc

cbn{,a}

cb3{,a}

cb2{,a}

cb23{,a}

cb1{,a}

cb13{,eo}

cb12{,a}

cb123{,a}

cb0{,a}

cb03{,a}

cb02{,a}

cb023{,a}

cb01{,a}

cb013{,a}

cb012{,a}

cba{,a}

label

label

label

label

label

label

label

label

label

label

label

label

label

label

label

label

Branch on coprocessor condition codes

branch never

FBN

FBU

FBG

FBUG

FBL

FBUL

FBLG

fbn{,a}

fbu{,a}

fbg{,a}

fbug{,a}

fbl{,a}

fbul{,a}

fblg{,a}

label

label

label

label

label

label

label

Branch on floating-point condition codes

branch never

FBNE

fbne{,a}

label

 

synonym: fbnz

FBE

fbe{,a}

label

 

synonym: fbz

FBUE

FBGE

FBUGE

FBLE

FBULE

FBO

FBA

fbue{,a}

fbge{,a}

fbuge{,a}

fble{,a}

fbule{,a}

fbo{,a}

fba{,a}

label

label

label

label

label

label

label

 

 

FLUSH

flush

address

Instruction cache flush

 

JMPL

jmpl

address, regrd

Jump and link

 

LDSB

ldsb

[address], regrd

Load signed byte

 

LDSH

ldsh

[address], regrd

Load signed halfword

 

LDSTUB

ldstub

[address], regrd

Load-store unsigned byte

 

LDUB

ldub

[address], regrd

Load unsigned byte

 

LDUH

lduh

[address], regrd

Load unsigned halfword

 

LD

ld

[address], regrd

Load word

 

LDD

ldd

[address], regrd

Load double word

regrd must be even

LDF

ld

[address], fregrd

 

 

LDFSR

ld

[address], %fsr

Load floating-point register

 

LDDF

ldd

[address], fregrd

Load double floating-point

fregrd must be even

LDC

ld

[address], cregrd

Load coprocessor

 

LDCSR

ld

[address], %csr

Load double coprocessor

 

LDDC

ldd

[address], cregrd

 

 

LDSBA

LDSHA

LDUBA

LDUHA

LDA

ldsba

ldsha

lduba

lduha

lda

[regaddr]asi, regrd

[regaddr]asi, regrd

[regaddr]asi, regrd

[regaddr]asi, regrd

[regaddr]asi, regrd

Load signed byte from alternate space

LDDA

ldda

[regaddr]asi, regrd

 

regrd must be even

LDSTUBA

ldstuba

[regaddr]asi, regrd

 

 

MULScc

mulscc

regrs1, reg_or_imm, regrd

Multiply step (and modify icc)

 

NOP

nop

 

No operation

 

OR

ORcc

ORN

ORNcc

or

orcc

orn

orncc

regrs1, reg_or_imm, regrd

regrs1, reg_or_imm, regrd

regrs1, reg_or_imm, regrd

regrs1, reg_or_imm, regrd

Inclusive or

 

RDASR

rd

%asrnrs1, regrd

 

 

RDY

rd

%y, regrd

 

See synthetic instructions.

RDPSR

rd

%psr, regrd

 

See synthetic instructions.

RDWIM

rd

%wim, regrd

 

See synthetic instructions.

RDTBR

rd

%tbr, regrd

 

See synthetic instructions.

RESTORE

restore

regrs1, reg_or_imm, reg rd

 

See synthetic instructions.

RETT

rett

address

Return from trap

 

SAVE

save

regrs1, reg_or_imm, regrd

 

See synthetic instructions.

SDIV

sdiv

regrs1, reg_or_imm, regrd

Signed divide

 

SDIVcc

sdivcc

regrs1, reg_or_imm, regrd

Signed divide and modify icc

 

SMUL

smul

regrs1, reg_or_imm, regrd

Signed multiply

 

SMULcc

smulcc

regrs1, reg_or_imm, regrd

Signed multiply and modify icc

 

SETHI

sethi

const22, regrd

Set high 22 bits of register

sethi

%hi(value), regrd

 

See synthetic instructions.

SLL

sll

regrs1, reg_or_imm, regrd

Shift left logical

 

SRL

srl

regrs1, reg_or_imm, regrd

Shift right logical

 

SRA

sra

regrs1, reg_or_imm, regrd

Shift right arithmetic

 

STB

stb

regrd, [address]

Store byte

Synonyms: stub, stsb

STH

sth

regrd, [address]

Store half-word

Synonyms: stuh, stsh

ST

st

regrd, [address]

 

 

STD

std

regrd, [address]

 

regrd Must be even

STF

st

fregrd, [address]

 

 

STDF

std

fregrd, [address]

 

 

STFSR

st

%fsr, [address]

Store floating-point status register

fregrd Must be even

STDFQ

std

%fq, [address]

Store double floating-point queue

 

STC

st

cregrd, [address]

Store coprocessor

cregrd Must be even

STDC

std

cregrd, [address]

 

cregrd Must be even

STCSR

st

%csr, [address]

 

 

STDCQ

std

%cq, [address]

Store double coprocessor

 

STBA

stba

regrd [regaddr]asi

Store byte into alternate space

Synonyms: stuba, stsba

STHA

stha

regrd [regaddr]asi

 

Synonyms: stuha, stsha

STA

sta

regrd, [regaddr]asi

 

 

STDA

stda

regrd, [regaddr]asi

 

regrd Must be even

SUB

sub

regrs1, reg_or_imm, regrd

Subtract

 

SUBcc

subcc

regrs1, reg_or_imm, regrd

Subtract and modify icc

 

SUBX

subx

regrs1, reg_or_imm, regrd

Subtract with carry

 

SUBXcc

subxcc

regrs1, reg_or_imm, regrd

 

 

SWAP

SWAPA

swap

swapa

[address], regrd

[regaddr]asi, regrd

Swap memory word

with register

Ticc

tn

software_trap_number

Trap on integer condition code

Trap never

tne

software_trap_number

Note: Trap numbers 16-31 are reserved for the user. Currently-defined trap numbers are those defined in /usr/include/sys/trap.h

 

Synonym: tnz

 

te

tg

tle

tge

tl

tgu

software_trap_number

software_trap_number

software_trap_number

software_trap_number

software_trap_number

software_trap_number

 

Synonym: tz

 

tleu

software_trap_number

 

Synonym: tcc

 

tlu

tgeu

tpos

tneg

software_trap_number

software_trap_number

software_trap_number

software_trap_number

 

Synonym: tcc

 

tvc

tvs

ta

software_trap_number

software_trap_number

software_trap_number

 

Synonym: t

TADDcc

TSUBcc

taddcc

tsubcc

regrs1, reg_or_imm, regrd

regrs1, reg_or_imm, regrd

Tagged add and modify icc

 

TADDccTV

TSUBccTV

taddcctv

tsubcctv

regrs1, reg_or_imm, regrd

regrs1, reg_or_imm, regrd

Tagged add and modify icc and trap on overflow

 

UDIV

udiv

regrs1, reg_or_imm, regrd

Unsigned divide

 

UDIVcc

udivcc

regrs1, reg_or_imm, regrd

Unsigned divide and modify icc

 

UMUL

umul

regrs1, reg_or_imm, regrd

Unsigned multiply

 

UMULcc

umulcc

regrs1, reg_or_imm, regrd

Unsigned multiply and modify icc

 

UNIMP

unimp

const22

Illegal instruction

 

WRASR

wr

reg_or_imm, %asrnrs1

 

 

WRY

wr

regrs1, reg_or_imm, %y

 

See synthetic instructions

WRPSR

wr

regrs1, reg_or_imm, %psr

 

See synthetic instructions

WRWIM

wr

regrs1, reg_or_imm, %wim

 

See synthetic instructions

WRTBR

wr

regrs1, reg_or_imm, %tbr

 

See synthetic instructions

XNOR

XNORcc

xnor

xnorcc

regrs1, reg_or_imm, regrd

regrs1, reg_or_imm, regrd

Exclusive nor

 

XOR

XORcc

xor

xorcc

regrs1, reg_or_imm, regrd

regrs1, reg_or_imm, regrd

Exclusive or

 

 
 
 
  Previous   Contents   Next