Instruction set summary


The SPARC instruction set consists of 69 instructions. Each instruction takes exactly 32 bits. The complete set is often described as having six basic categories, as follows :

  1. Memory access instructions

  2. Arithmetic / logical / shift instructions

  3. Control transfer instructions

  4. State register instructions

  5. Floating-point unit instructions

  6. Coprocessor instructions

We will cover each of these categories in detail.

Operation codes & instruction formats

When discussing a processor's native language, we sometimes talk about the individual operation codes (opcodes) of each instruction. This discussion often involves learning the specific bit-by-bit organization of the instructions, or instruction formats.

The SPARC processor uses three basic instruction formats for the complete instruction set. As a software analyst examining system crash dumps, it is rare indeed that you will ever need to look at the raw instructions of a program in hexadecimal, because kadb and adb will be converting the values into assembly language for you. This process is referred to as " disassembling ." Should you want to explore this extremely detailed aspect of the instruction set, please refer to The SPARC Architecture Manual, Version 8 .

The SPARC assembly language instructions, with which we will be working, and the SPARC opcodes are usually the same. We will point out the few cases where they differ .

Assembly language syntax

When looking at SPARC assembly language via adb , we will see adb 's disassembled interpretation of the opcodes it finds. In very simple terms, the general syntax of assembly instructions we will see are as follows:

  label:  instruction source destination   instruction label  

As we discuss each category of instruction, we will show the syntax of the instructions and some examples of assembly language code.

Instruction syntax

Throughout the rest of this chapter, while discussing the individual instructions in the SPARC instruction set and their syntax, we will use the following conventions. These are the same conventions you will find in The SPARC Architecture Manual, Version 8 .

Registers

When we refer to reg in the instruction syntax, we are referring to any Integer Unit, general-purpose register name . It may be any one of the following:

%r0 through %r31

General-purpose registers

%g0 through %g7

Globals

(aka %r0 through %r7 )

%o0 through %o7

Out registers

(aka %r8 through %r15 )

%l0 through %l7

Local registers

(aka %r16 through %r24 )

%i0 through %i7

In registers

(aka %r25 through %r31 )

%fp

Frame pointer

(aka %i6 and %r30 )

%sp

Stack pointer

(aka %o6 and %r14 )

When we refer to sreg and dreg in the instruction syntax, one general-purpose register is the source register and the other is a destination register.

Note

In SPARC assembly language, the percent sign, % , must be used in front of all register names .


The symbols freg and creg will be used in instruction syntax to represent any floating-point processor and coprocessor register names.

%f0 through %f31

The floating-point registers

%c0 through %c31

Possible coprocessor registers

When we refer to sfreg and dfreg in the instruction syntax, one floating-point register is the source register and the other is a destination register.

Special symbol names

The following special symbols are used in SPARC assembly language. You'll recognize most of these from the chapter about the SPARC processor. We will discuss the last two, %hi and %lo , later on in this chapter.

%psr

Processor state register

%fsr

Floating-point state register

%csr

Coprocessor state register

%wim

Window invalid mask register

%tbr

Trap base register

%y

Multiply / divide register

%fq

Floating-point queue

%cq

Coprocessor queue

%hi

Unary operator that extracts the high 22 bits of its operand

%lo

Unary operator that extracts the low 10 bits of its operand

Operand values

SPARC instructions use operands that may include the following symbols.

simm13

A signed immediate constant that can be represented in 13 bits.

const22

A constant that can be represented in 22 bits.

as

An alternate address space identifier (0 to 255)

value

An unspecified, integer value

Register values

When discussing instructions that access memory, we will use [ address ] in the instruction syntax to represent any of the following methods of deriving a memory address.

reg

Address = Contents of register (address is stored in register)

simm13

Address = Signed 13-bit immediate value or offset

reg +/- simm13

Address = Contents of register plus or minus an offset value

reg1 + reg2

Address = Value of one register + value of a second register

Some instructions only use register values (the above methods, which don't involve use of a simm13 offset value). When discussing those instructions, we will use [ regaddr ] in the instruction syntax instead of [ address ].

For instructions that can only use either one register or a signed 13-bit immediate value to represent an address or other value, we will use reg_or_imm in the instruction syntax.

When talking about the trap instructions, we will use sw_trap_num in the instruction syntax to represent software trap numbers , which may be any value from 0 to 127.

Labels

When discussing instructions that branch or jump, we will use label to represent a location within the routine. Labels in SPARC assembler may consist of alphanumeric characters (a “z, A “Z, 0 “9), underscores (_), dollar signs ($), and periods (.). The first letter of a label cannot be a decimal digit (0-9). When examining disassembled code (from adb) , labels used by branch instructions will usually be shown as a variable (routine name) plus an offset value.

Note that the 4.x bundled C compiler automatically prefaced C variable and function names with an underscore (_). This convention allows you to identify assembly code labels, which are normally not defined with a leading underscore unless they are to be callable from C-language functions. This convention was discarded with the ANSI C compilers.



PANIC. UNIX System Crash Dump Analysis Handbook
PANIC! UNIX System Crash Dump Analysis Handbook (Bk/CD-ROM)
ISBN: 0131493868
EAN: 2147483647
Year: 1994
Pages: 289
Authors: Chris Drake

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net