Unformatted text preview:

Alpha Processors Alpha Programming CS 740 Sept 15 2000 Reduced Instruction Set Computer RISC Simple instructions with regular formats Key Idea make the common case fast infrequent operations can be synthesized using multiple instructions Topics Assumes compiler will do optimizations Basics Control Flow Procedures Instruction Formats Flavors of integers Floating point Data structures Byte ordering e g scalar optimization register allocation scheduling etc ISA designed for compilers not assembly language programmers A 2nd Generation RISC Instruction Set Architecture Designed for superscalar processors i e 1 inst per cycle avoids some of the pitfalls of earlier RISC ISAs e g delay slots Designed as a 64 bit ISA from the start Very High Performance Machines Alpha has been the clear performance leader for many years now 2 CS 740 F 00 Translation Process text Abstract Machines C program p1 c p2 c Machine Model Compiler gcc S C Asm program p1 s p2 s text mem proc Assembler gcc or as binary Data Control 1 2 3 4 5 char int float double struct array pointer 1 2 3 4 5 byte 3 branch jump word 4 jump link doubleword contiguous word allocation address of initial byte 1 2 3 4 5 loops conditionals goto Proc call Proc return Object program p1 o p2 o ASM Linker gcc or ld binary Executable program p libraries a mem Disassembler dis h regs alu Debugger gdb processor disassembled program text 3 CS 740 F 00 4 Page 1 CS 740 F 00 Alpha Register Convention General Purpose Registers v0 t0 t1 t2 t3 t4 t5 Usage Conventions t6 Established as part of t7 architecture s0 Used by all compilers programs s1 and libraries s2 Assures object code s3 compatibility s4 e g can mix Fortran and C s5 s6 fp 32 total Store integers and pointers Fast access 2 reads 1 write in single cycle 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Registers cont Return value from integer functions Important Ones for Now 0 Return Value 1 8 Temporaries 16 First argument 17 Second argument 26 Return address 31 Constant 0 Temporaries not preserved across procedure calls Callee saved Frame pointer or callee saved CS 740 F 00 void test1 long int x long int y gval x x x y y y Obtain with command gcc O S code c Produces file code s Integer arguments Temporaries Return address Current proc addr or Temp Reserved for assembler Global pointer Stack pointer Always zero CS 740 F 00 Prog Representation Cont Object Compiled to Assembly long int gval 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 6 Program Representations C Code a0 a1 a2 a3 a4 a5 t8 t9 t10 t11 ra pv t12 AT gp sp zero 0x120001130 test1 0x27bb2000 0x23bd6f30 0xa47d8098 0x42100402 0x40500402 0x42310401 0x40310401 0x40410522 0xb4430000 0x6bfa8001 align 3 globl test1 ent test1 test1 ldgp 29 0 27 frame 30 0 26 0 prologue 1 lda 3 gval addq 16 16 2 addq 2 16 2 addq 17 17 1 addq 1 17 1 subq 2 1 2 stq 2 0 3 ret 31 26 1 end test1 Disassembled 0x120001130 0x120001134 0x120001138 0x12000113c 0x120001140 0x120001144 0x120001148 0x12000114c 0x120001150 0x120001154 test1 test1 4 test1 8 test1 12 test1 16 test1 20 test1 24 test1 28 test1 32 test1 36 ldah lda ldq addq addq addq addq subq stq ret gp 536870912 t12 gp 28464 gp t2 32616 gp a0 a0 t1 t1 a0 t1 a1 a1 t0 t0 a1 t0 t1 t0 t1 t1 0 t2 zero ra 1 Run gdb on object code x 10 0x120001130 Print 10 words in hexadecimal starting at address 0x120001130 dissassemble test1 7 Print disassembled version of procedure CS 740 F 00 8 Page 2 CS 740 F 00 Returning a Value from a Procedure Alternate Disassembly C Code Alpha program dis dis file o Prints disassembled version of object code file The h option prints hardware register names r0 r31 Code not yet linked Addresses of procedures and global data not yet resolved test1 0x0 0x4 0x8 0xc 0x10 0x14 0x18 0x1c 0x20 0x24 27bb0001 23bd8760 a47d8010 42100402 40500402 42310401 40310401 40410522 b4430000 6bfa8001 ldah lda ldq addq addq addq addq subq stq ret align 3 globl test2 ent test2 test2 frame 30 0 26 0 prologue 0 addq 16 16 1 addq 1 16 1 addq 17 17 0 addq 0 17 0 subq 1 0 0 ret 31 26 1 end test2 gp 1 t12 gp 30880 gp t2 32752 gp a0 a0 t1 t1 a0 t1 a1 a1 t0 t0 a1 t0 t1 t0 t1 t1 0 t2 zero ra 1 9 Place result in 0 CS 740 F 00 10 Pointer Examples C Code Compiled to Assembly long int test2 long int x long int y return x x x y y y CS 740 F 00 Array Indexing Annotated Assembly C Code long int iaddp long int xp long int yp int x xp int y yp return x y iaddp long int arefl long int a long int i return a i arefl incr int arefi int a long int i return a i arefi void incr long int sum long int v long int old sum long int new old val sum new 11 ldq 1 0 16 ldq 0 0 17 addq 1 0 0 ret 31 26 1 ldq 1 0 16 addq 1 17 1 stq 1 0 16 ret 31 26 1 1 xp 0 yp return with a value x y 1 sum 1 v sum 1 return CS 740 F 00 Annotated Assembly 12 Page 3 s8addq 17 16 17 17 8 i a 0 ldq 0 0 17 return val a i ret 31 26 1 return s4addq 17 16 17 17 4 i a 0 ldl 0 0 17 return val a i ret 31 26 1 return CS 740 F 00 Array Indexing Cont C Code Structures Pointers Annotated Assembly long int garray 10 long int gref long int i return garray i Disassembled comm struct long long long garray 80 gref ldgp 29 0 27 setup the gp lda 1 garray 1 garray 0 s8addq 16 1 16 16 8 i 1 ldq 0 0 16 ret val garray i ret 31 26 1 return 0x80 0x84 0x88 0x8c 0x90 0x94 gref gref 4 gref 8 gref 12 gref 16 gref 20 27bb0001 23bd86e0 a43d8018 42010650 a4100000 6bfa8001 ldah lda ldq s8addq ldq ret 13 rec int int int i a 3 p C Code long int find a struct rec r long int idx return r a idx 15 0 a 8 gp 65536 t12 gp 31008 gp t0 32744 gp a0 t0 a0 v0 0 a0 zero ra 1 a 8 p 32 Annotated Assembly set i stq 17 0 16 ret 31 26 1 14 r i val CS 740 F 00 Structures Pointers Cont struct long long long p 32 Annotated Assembly rec int int int i a 3 p C Code void set p struct rec r long int ptr r p ptr find …


View Full Document

CMU CS 15740 - Alpha Programming

Documents in this Course
leecture

leecture

17 pages

Lecture

Lecture

9 pages

Lecture

Lecture

36 pages

Lecture

Lecture

9 pages

Lecture

Lecture

13 pages

lecture

lecture

25 pages

lect17

lect17

7 pages

Lecture

Lecture

65 pages

Lecture

Lecture

28 pages

lect07

lect07

24 pages

lect07

lect07

12 pages

lect03

lect03

3 pages

lecture

lecture

11 pages

lecture

lecture

20 pages

lecture

lecture

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

10 pages

Lecture

Lecture

22 pages

Lecture

Lecture

28 pages

Lecture

Lecture

18 pages

lecture

lecture

63 pages

lecture

lecture

13 pages

Lecture

Lecture

36 pages

Lecture

Lecture

18 pages

Lecture

Lecture

17 pages

Lecture

Lecture

12 pages

lecture

lecture

34 pages

lecture

lecture

47 pages

lecture

lecture

7 pages

Lecture

Lecture

18 pages

Lecture

Lecture

7 pages

Lecture

Lecture

21 pages

Lecture

Lecture

10 pages

Lecture

Lecture

39 pages

Lecture

Lecture

11 pages

lect04

lect04

40 pages

Load more
Loading Unlocking...
Login

Join to view Alpha Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Alpha Programming and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?