User Tools

Site Tools


instruction_set

Alpha Instruction Set

Primer

Hello World!

# hello.S
# gcc hello.S -o hello
# ./hello
.data
PRINT:	.ascii		"Hello, World!\n"
 
.text
	.align	4
	.set	noreorder
	.arch	ev4
	.globl	main
	.ent	main
 
main:	ldgp	$gp,0($27)		# load global pointer
	stq	$26,0($sp)		# save return address to stack
 
	lda	$16,PRINT		# load format string
					# $16 is first argument to functions
	jsr	$26,printf		# call printf
	ldgp	$gp,0($26)		# reload global pointer
					# (necessary after function calls)
 
	mov	$31,$0			# return val = 0
	ldq	$26,0($sp)		# load return address from stack
	ret	$31,($26),1		# return, (1 signifies return from a procedure)
	.end	main

Registers

Integer

There are 32 integer registers. The $31 register holds the constant value 0. Writes to it are ignored.

By convention 12 registers are for temporary values, 6 are saved across function calls, and 6 are for passing arguments to functions.

Register Alternate Name Preserved? Purpose
$0 $v0 No Return Value
$1$8 $t0$t7 No Temporary Registers
$9$14 $s0$s5 Yes Saved Registers
$15 $s6 or $fp Yes Saved Register or Frame Pointer
$16$21 $a0$a5 No Function Arguments
$22$25 $t8$t11 No Temporary Registers
$26 $ra Yes Function Return Address
$27 $pv or $t12 No Procedure Value or Temporary Register
$28 $at No Reserved for Assembler
$29 $gp No Global Pointer
$30 $sp Yes Stack Pointer
$31 $zero Zero Sink

Floating-Point

There are 32 floating-point registers. The $f31 register holds the constant value 0.0. Writes to it are ignored.

By convention, 15 registers are for temporary values, 8 are saved across function calls, and 6 are for passing arguments to functions.

Register Preserved? Purpose
$f0 No Return Value
$f1 No Return Value of Imaginary Part
$f2$f9 Yes Saved Registers
$f10$f15 No Temporary Registers
$f16$f21 No Function Arguments
$f22$f30 No Temporary Registers
$f31 Zero Sink

ISA Extensions

Presence Detection

To determine the presence of instruction set extensions at runtime, use the amask instruction.

Byte/Word eXtensions (BWX)

The Byte/Word eXtensions (BWX) were introduced in the EV56 and are available in all subsequent implementations.

Mnemonic Description
ldbu Load byte unaligned
ldwu Load word unaligned
sextb Sign-extend byte
sextw Sign-extend word
stb Store byte
stw Store word

Motion Video Instructions (MVI)

Motion Video Instructions (MVI) were introduced in the PCA56 and are available in all subsequent implementations.

Mnemonic Instruction
maxsb8 Vector Signed Byte Maximum
maxsw4 Vector Signed Word Maximum
maxub8 Vector Unsigned Byte Maximum
maxuw4 Vector Unsigned Word Maximum
minsb8 Vector Signed Byte Minimum
minsw4 Vector Signed Word Minimum
minub8 Vector Unsigned Byte Minimum
minuw4 Vector Unsigned Word Minimum
perr Pixel Error
pklb Pack Longwords to Bytes
pkwb Pack Words to Bytes
unpkbl Unpack Bytes to Longwords
unpkbw Unpack Bytes to Words

Floating-point Instruction eXtensions (FIX)

The Floating-point Instruction eXtensions (FIX) were introduced in the EV6 and are available in all subsequent implementations.

Mnemonic Description Floating-Point Format
itofs Copy Low 32 bits from Integer Register to Floating-Point Register using S_floating Format IEEE
itoft Copy 64 bits from Integer Register to Floating-Point Register IEEE
itoff Copy Low 32 bits from Integer Register to Floating-Point Register using F_floating Format VAX
ftois Copy Floating-Point Register using S_floating Format to Integer Register IEEE
ftoit Copy 64 bits from Floating-Point Register to Integer Register IEEE
sqrts Calculate square root of S_floating Formatted Value IEEE
sqrtt Calculate square root of T_floating Formatted Value IEEE
sqrtf Calculate square root of F_floating Formatted Value VAX
sqrtg Calculate square root of G_floating Formatted Value VAX

Count Instruction eXtensions (CIX)

The Count Instruction eXtensions (CIX) were introduced in the EV67 and are available in all subsequent implementations.

Mnemonic Description
ctlz Count Leading Zeros
ctpop Count Population (Count number of 1's)
cttz Count Trailing Zeros
instruction_set.txt · Last modified: by mattst88