Assembly Language Conventions on DEC Alpha Systems
Added 31 Jul 2008
SUMMARY
When you do kernel debugging of Windows NT on a DEC Alpha-based system,
there are a number of commonly used assembly language conventions that are
useful to know. Some of them are very simple; others are more complicated.
Debugging can go much faster after you are aware of these conventions.
Back to the top
MORE INFORMATION
Alpha assembly language has a very small number of instructions. The set used in Windows NT operating system code is made even smaller by the fact that floating point commands are generally not used. Because of that, knowing the following types of assembly instructions should give you a good start at debugging Windows NT on a DEC Alpha computer.
Back to the top
Registers
DEC Alpha computers, like many RISC-based systems, have a large number of registers. There are 32 integer registers (R0-R31) and 32 floating point registers (F0-F31), all of which are 64-bit. In most operating system assembly code, only the integer registers will be used. Additionally, the assembly language does not refer to the registers using R0 through R31, instead, it uses a naming convention that indicates the general purpose of the registers:Register Name Purpose
-------- ---- -------
R0 V0 Frequently used to store function addresses
R1-R8 T0-T7 Temporary registers, used to store interim
values in calculations
R9-R14 S0-S5 Primary registers, used to store local variables
and other important 'permanent' values
R15 FP/S6 Frame pointer, also referred to as S6
R16-R21 A0-A5 Argument registers, used to pass arguments in
function calls.
R22-R25 T8-T11 More temporary registers
R26 RA Return Address register
R27 PV/T12 Pointer value/Temporary storage
R28 AT Assembler temporary register
R29 GP Global Pointer
R30 SP Stack Pointer
R31 ZERO Special constant register which always holds
zero
The T and A registers are all temporary-use registers, and the S registers are more permanent (in the sense that the S registers will always be saved off onto the stack at the beginning of each function and restored at the end of each function), so they can be counted on to hold the same values before and after a function call has been made (where the A and T registers may have been changed by the function call). The FP and SP registers will also be saved in the same manner.
Back to the top
Store and Load Instructions
The two types of instructions you will commonly see are load and store, some examples of which are:ldl t5,0x8(s3)
ldq t1,0x460(t1)
stl t6,0x4(s2)
stq s0,0x50(sp)
The general format of both of these commands is:
ldX rY,(rZ)
stX rY,(rZ)
where X is the size of the value (longword or quadword), rY is the first Register, and rZ is the second. The notation
There are also special forms of these instructions, but the only one you will see frequently is the load address instruction (LDA), that has the same operands as the other load commands. A load address will compute the address in the second operand (
Back to the top
Moving Data Between Registers
In Alpha assembly, you will often see the following types of commands as well, all of which have a very similar effect:1. bis fp,zero,a2
2. bis zero,zero,a3
3. bis zero,#0x3,a1
4. bis zero,zero,zero
In all of the above commands, zero is a special literal that refers to a fixed register on the processor that is always set to zero. 'bis' is the mnemonic for a bitwise or and is a very fast instruction, taking one processor cycle to run. The four commands above have the following results:
| 1. | bis rX,zero,rY is a fast way of moving the value in register X into register Y. |
| 2. | bis zero,zero,rX is a fast way of zeroing out register X. |
| 3. | bis zero,#0xX,rY moves the literal value X into register Y. |
| 4. | The last form of the bis command, bis zero,zero,zero, effectively does nothing. It is used when the next command is waiting on the results of a command that is still being carried out. Because it wastes exactly 1 processor cycle and no more, it is a convenient way for assembler to say "wait one cycle and then start doing things again". |