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 :
We will cover each of these categories in detail. Operation codes & instruction formatsWhen 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 syntaxWhen 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 syntaxThroughout 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 . RegistersWhen 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:
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.
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 namesThe 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.
Operand valuesSPARC instructions use operands that may include the following symbols.
Register valuesWhen 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.
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. LabelsWhen 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. |