Control Transfer and Arithmetic Conditional/Unconditional branches Delayed Control Transfer –Increases the efficiency of pipelining Annulled branches Usual arithmetic and logical operations
5. Data Types and Addressing Eleven Data Types –unsigned byte (8 bits) to extended precision floating point (128 bit)
SPARC Data Types TypeSize (bits) Corresponding C Data Type Range Unsigned Byte8 unsigned char 0 … 256 Byte8 char –128 … 127 Unsigned Halfword16 unsigned short 0 … Halfword16 short – … Unsigned Word32 unsigned int/long 0 … Word32 int/long – … Doubleword64N/AVery large! Tagged Data30 + 2N/A0 … Single Precision Floating Point 32 float s = 1, e = 8, f = 23 Double Precision Floating Point 64 double s = 1, e = 11, f = 52 Extended Precision Floating Point 128N/As = 1, e = 15, j = 1, f = 63
Registers and Memory Registers –All 32 bits Big-Endian Convention Data Alignment
Addressing Modes Four addressing modes: –Two register –Register + (13-bit) immediate –30-bit PC-relative –22-bit PC-relative
Register Windows save and restore Window over/under flow
Register Windows
Variables Accessed using ld and st –ld [%fp - 4], %l0
Some Useful m4 Macros define(local_vars, `define(last_sym, 0)’) define(var, `$1 = last_sym - $2 & -$2 define(`last_sym’, $1)’) define(begin, `.globalmain main: save%sp, last_sym & -8, %sp’) define(end, `mov1, %g1 t0’)
Using the Macros include(macro_defs.m) local_vars var(x, 4) var(y, 4) begin ld[%fp + x], %l0! l0 <- x st%l0, [%fp + y]! y <- l0 end
Expansion x = & -4 y = x - 4 & -4.global main main: save %sp, y & -8, %sp ld [%fp + x], %l0 ! l0 <- x st %l0, [%fp + y] ! y <- l0 mov 1, %g1 t 0
Global Variables Use data definition pseudo-ops.data ! Start of data segment x:.word 12 ! int x = 12; y:.byte 'a' ! char y = 'a';.align 2 ! Get alignment correct z:.half 0xffff ! short z = 0xffff;.align 4 ! Get alignment correct lst:.skip 4 * 100 ! int lst[100];.text ! Start of program segment...