ࡱ> DABCza߿ߝXo( UUUUzag\Oy Ek( DDR(8  t `www.intel.com*http://www.intel.com// 0DTimes New RomanTTܖ 0ܖDTahomaew RomanTTܖ 0ܖ" DWingdingsRomanTTܖ 0ܖ0D[SOgdingsRomanTTܖ 0ܖ@DArialngsRomanTTܖ 0ܖ"PDSymbolgsRomanTTܖ 0ܖ`DMurray BoldmanTTܖ 0ܖhB A.@  @@``  @n?" dd@  @@`` 8 0 (@4$$;   LDH'""/"/"/(*)667    !$%&-'()*+,-./01234 5 69:;<#=(O$$r$߿ߝXoifr$g\Oy Ekii AA1))?@8^_g42d2d 0ppp@  <4BdBd l 0T=ʚ;ʚ;<4!d!d l 0 <4dddd l 0 0___PPT10 X___PPT9:nu=!BWk@~PNG  IHDRF} PLTE3:tRNS@f cmPPJCmp0712Om9IDATc``b $<&40(Zжj˂AtM iIENDB`/ 0DM0Z[ 4 56>7@9L:;<= > ?@.A<Bc@?Z+ F\course\cpeg323-05F\Topic2d-323.pptO =k1>Topic2d High-Level languages and System Software (Toolchain):?$c$7$. , 8Introduction to Computer Systems Engineering (CPEG 323)2-2 9M Reading List (4Slides: Topic2d Operating System and Compiler Books<5 "  c'  'N Tool Chain  O  P Tool Chain  XTwo good examples SimpleScalar www.simplescalar.com GNUPro www.intel.com (Search GNUPro)f   `   0;HQ Tool Chain  Basic Set: " Compilers: C, C++, Fortran, and etc. " Binary utilities: assembler, linker, objdump, ar, nm " Debugger " Simulator (functional / cycle-accurate) " Others: performance monitor (VTune of Intel)  b% b 5b b(  $b$.((>YZ R Tool Chain   STool Chain - PreprocessorsFunctionality Header files Definitions Conditional compilation Pragma(Preprocessor Directives ) Delete the comments&ff?"TTool Chain - CompilerfTransform a program from high level language to assembly language (or machine language) Optimizations fgZParameter Passing(Caller save. The calling procedure (caller) is responsible for saving and restoring any registers that must be preserved across the call. The called procedure (callee) can then modify any register without constraint. Callee save. The callee is responsible for saving and restoring any registers that it might use. The caller uses registers without worrying about restoring them after a call.^ "  " n  >3 [Saving Registers(P(If you call a function, whatever you have in $s0 to $s7 is guaranteed to be there when the function gets back to you But registers $t0 - $t9 are fair game to be reused by the function What are the alternatives? - Save nothing? - Save everything? Why caller/callee save ? u "  " (C "  " ( " # "  " # \Why caller save / callee save?If all caller save ? Even callee doesn t kill any of the saved registers  waste of cycles and memory resource If all callee save ? Callee has to save all the register (which will be used by callee), even caller doesn t use themNZaZa PV5 ] Caller save   ^ Callee Save   _Caller Save / Callee SaveWhen to use caller save register ? TEMPORARY VARIABLE Also called Scratch Register When to use callee save register ? GLOBAL VARIABLE Z#1##1# `"UTool Chain - Assembler2Transform assembly code into binary (machine code)VTool Chain - LinkerxLinking  resolve symbols Relocation  assign memory addressWTool Chain - loader.Cannot see by user Done by Shell and OS kernelX(Tool Chain  Library Libc/Libm    Y Tool Chain  _Objdump See the memory layout and sections Symbol table Disassembly code Relocation information&XXY34Compiling/Assembling a ProgramP(Code converted from high-level to machine language (binary) Each source file converted to a separate  object file in Unix, object files have extension .o This is not executable (yet)! Intended to be combined with other modules, not stand-alone May not have everything we need (e.g., a main () function) Functions not assigned specific locations in memory Each function given a  relocation table - This table tells exactly which addresses need to be resolved< "  " 7 "  - -4 "  " ) " @ " =75Relocation TableP(Suppose function f() in module a.c calls g() in b.c a.c should declare g with extern (directly or in .h file) Relocation table in a.o says something like:  the jal at the 52nd instruction in f calls g, but I don t know where g is. Relocation table in b.o says something like:  I have a function g, which starts at location 628 in my file. g unresolved even if local (why?) 4 "  " : "  " z "  " m "  " # " f G-"6Linking a program(`Linker combines one or more object files into a proper executable Linker determines which functions needed, discards the rest All needed functions put one after the other in text segment Linker resolves all labels; for instance Function f() in a.o calls g() in b.o Linker knows where it put g(), so it fixes the jal in f() Linker includes extra code: Initialization code before call to main()  Cleanup code after main() returnsB " n " < " n " = " n " ) " n_ -n - " nN -n)_N  ;sDLoading( A program that links without an error can be run. Before being run, the program resides in a file on secondary storage, such as a disk. On Unix system, the operating system kernel brings a program into memory and starts running. 7 Libraries (Libraries contain functions intended to be shared & reused, e.g., C library: printf(), malloc(), strcmp(), sin(), cos() STL (Standard Template Library) in C++ Big software projects may make their own libraries Static libraries (* .a in Unix) made part of the executable by linker Dynamic libraries (* .so in Unix, * .dll in Windows) combined at runtime Executable still has relocation table of unresolved function calls Loader does the final resolution when you execute the program B " x -x -F " x " I " x -x -xBH,      bM GHIJaDebugger ` Instruction level debugger Source level debugger Major techniques Ptrace (POSIX API. on Linux/Unix system) Embedded or raw machine Software trap Single step modeFBBB`B``.B  Z 9Debugger& ( Source-level debugger lets you step through your source code Requires extra information attached to executable Location and type of every function and variable First instruction address corresponding to each line of source Usually requires extra switches to compiler and linker, e.g., -g Two popular graphical debuggers are ddd and xxgdb (on ECE/CIS machines)? "  " 2 " p - -A "  " H " 32p  ,IERun a Executable File (OS View) (J The operating system performs the following steps: 1. Reads the executable file s header to determine the size of the text and data segments. 2.  Establish a new address space (e.g. via the creation of a new page table) for the program. This address space is large enough to hold the text and data segments, along with a stack segment 3. Copies instructions and data from the executable file into the new address spacef4q3qF 4. Copies arguments passed to the program onto the stack. 5. Initializes the machine registers. In general, most registers are cleared but the stack pointer must be assigned the address of the first free stack location 6. Jumps to a start-up routine that copies the program s arguments from the stack to registers and calls the program s main routine. If the main routine returns, the start-up routine terminates the program with the exit system call.2$Typical Layout of an Executable File%P%$ :The Role of the OS Kernel&(HThe OS  kernel performs the following essential functions: Manages resources (memory, disks, I/O)  mostly via  drivers Switches between users (in a multi-user system such as copland) Provides convenient functions for applications to access resources Protects users from one another Provides essential  glue , e.g., support for loaders For this to work efficiently, the CPU must have some support for the kernel.< " x "  > " x "  @ " x " C " x "   " x " 5 " x " M " x!;#Processor Support for the OS kernel$P$(Most processors have at least 2 distinct levels or  modes :  Supervisor (or  privileged or  kernel ) mode  User level (including  root or  administrator ) Lower levels can t do some things, e.g., access the disk drive CPU boots in kernel mode; drops to user mode to run user code Early micros (such as 8086) lacked such modes< " xc -x -? " x " > " x " . " x<<TrapsP( So once we re in user mode, how do we get back to the privileged mode? Through  traps  exceptional or unusual conditions requiring intervention by the kernel: Hardware error (divide by 0 or access to illegal memory address) Hardware  interrupt (Ethernet card got data; mouse clicked) Clock signal telling multi-user OS to switch to another user  Software trap when user code requests something from kernel PC reaches value stored in special  breakpoint register0 " x2 " x= Trap Handlers(P (" When a trap occurs, the CPU: Sets bits in special  status reg., indicating the cause of the trap Switches to privileged mode Jumps to a  trap handler (installed at boot time) at fixed location Handler reads status bits and takes appropriate action Return address saved, like jal instruction * When kernel is done, a special instruction return to the user code, dropping into user mode automatically " x " xb -xl -xbly>Software Traps(P( To do just about anything on the system involving shared resources (such as write to a file), the user code must ask the kernel to do it! User code gets access to the kernel through  trap instructions  System calls provided for operations such as writing files A function call to a system call converted to a software trap Args passed in the usual way (e.g., $a0-$a3 in MIPS) In MIPS, use the  syscall instruction No operands in assemble-language instruction Specify which system call you want by putting a value in $v0 ~ " x " xj -x -xj,FCy? System Calls( P (POSIX standard defines system calls and their numbers For instance, call no. 4 is the write() function: #include <unistd.h> ssize_t write(int fildes, cost void *buf, size_t nbyte); Every open file is identified by a unique  file descriptor (int) This function writes nbyte bytes, starting at address buf, to the filexh " x " R " x " C " xG " xFt  B@Example: Call to printf()(P(DUser code a.c calls printf ( Answer is %d\n , i); printf() declared as an extern function in stdio.h Compiler generates a.o with printf unresolved in relocation table Data segment of a.o has string  Answer is %dl_ (NUL at end) 14 bytes, with local label (e.g., L314) in relocation table Reference resolved when linked with libc (C library): By linker if statically (e.g., -Bstatic in Sun CC) B y loader if dynamically " x< -x6 " xM -xGK <6M%0.&ACalling printf()(P(4Program sets args to printf (L314 and i) does jal printf printf (still in user mode) does the following: Creates new stack frame (as any non-leaf function should) Processes args; makes new string  Answer is 42l in heap Creates args to write() function: Constant 1 in $a0 (file descriptor 1 is stdout) Address of heap string in $a1 Constant 13 in $a2 - Puts constant 4 in $v0 and does a syscall instruction j " x -xa " x9 -x -x " xjI*a;   n3>XBProcessing the Trap(P(The CPU executes the syscall (trap) instruction: Switches to privileged mode Sets bits in status regs indicating trap caused by syscall Jumps to trap handler Trap handler checks status bits; sees trap came from syscall Checks call # in $v0; fetches 4th entry in function table and jumps System call transfers 13 bytes to low-level driver - Driver writes them to graphics display (if normal stdout)1 " xm -x " x= " x1m\ bELbToolchain Review(P( Caller save register. The registers that the calling procedure (caller) is responsible for saving and restoring across the call. The called procedure (callee) can then modify the registers without constraint. Callee save register. The registers that the callee is responsible for saving and restoring if it might use. The caller uses the registers without worrying about restoring them after a call.6>4'cProgram TranslatesP(Pa.c Int I; & Printf( Answer is %d , i) & l " x% " Zc c 6dProgram Translates(cont.)(P( eProgram Translates (Cont.)(P( P,  0` @EoOV` @Eff؂o` MMMwww` 33f3Ƨgzf` 3ffE` JH3f̙ff` 33̙fRP` =bf>?" dd@,?wnd@ n< w_@nA``< n?" dd@   @@``PP   @ ` ` p>> ''CCP\'(  P!T  P "b  P# " \  P "B P HDA "B P HDA "B P HDA "@@B P HDA "B  P HDA "B  P HDA "B  P HDA "@@B  P HDA "B  P HDA "B P HDA "B P HDA "@@B P HDA "  B P HDA "  B P HDA "  B P HDA "@ @ B P HDA "  B P HDA "  B P HDA "  B P HDA "@@B P HDA "B P HDA "B P HDA "z\  P "B P HDA "B P HDA "B P HDA "@@B P HDA "B  P HDA "B !P HDA "B "P HDA "@@B #P HDA "B $P HDA "B %P HDA "B &P HDA "@@B 'P HDA " B (P HDA " B )P HDA " B *P HDA "@ @ B +P HDA " B ,P HDA " B -P HDA " B .P HDA "@@B /P HDA "B 0P HDA "B 1P HDA "B 2P HDA "@@B 3P HDA "B 4P HDA "B 5P HDA "B 6P HDA "@@B 7P HDA "B 8P HDA " 9P # t?A?60%"@`tB :P 6D"tb `  ;P# "|i4 tB PB  BCENGGHʲI[TQ zR(VzR(V[T`TzR(V[T`T" ?P 6L "  T Click to edit Master title style! ! @P O Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level"0  RClick to edit Master text styles Second level Third level Fourth level Fifth level!     S AP 6U "``  D*   BP 6Z "``    ^*  c    CP 6l_ "`   F*  H P 0޽h ?>P @Eff؂o___PPT92p22 Blueprint*  0 M*E*0GGT)(  TB$T  T "6b  T# " T T??"@`\  T "B T HDA "B T HDA "B T HDA "@@B  T HDA "B  T HDA "B  T HDA "B  T HDA "@@B  T HDA "B T HDA "B T HDA "B T HDA "@@B T HDA "  B T HDA "  B T HDA "  B T HDA "@ @ B T HDA "  B T HDA "  B T HDA "  B T HDA "@@B T HDA "B T HDA "B T HDA "B T HDA "B T HDA "B T HDA "@@B T HDA "B  T HDA "B !T HDA "B "T HDA "@@B #T HDA "B $T HDA "B %T HDA "B &T HDA "@@B 'T HDA " B (T HDA " B )T HDA " B *T HDA "@ @ B +T HDA " B ,T HDA " B -T HDA " B .T HDA "@@B /T HDA "B 0T HDA "B 1T HDA "B 2T HDA "@@B 3T HDA "B 4T HDA "B 5T HDA "B 6T HDA "@@B 7T HDA "B 8T HDA "tB 9T 6D"$\ /c3  :T "/c3 B ;T 6D"/3 ,$D  0tB TB  ZBCENGGHʲI[TQ zR(VzR(V[T`TzR(V[T`T"]Ft\  ?T "tB @T 6D"r r tB ATB 6D"442 BT  ZBCENGGHʲI[TQ zR(VzR(V[T`TzR(V[T`T"   CT 6r "Pp   T Click to edit Master title style! ! DT \Ft Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level"%p0u   W#Click to edit Master subtitle style$ $ ET 6 "`` t D*   FT 6( "`    ^*  c    GT 6 "`   F*  H T 0޽h ?/ >TBT @Eff؂o; 0 K(     T]~K~K ?v$  ] p*  H$$HHmm  T]~K~K ? 8$ ] r*  H$$HHmm  Z]~K~K ?v  ] p*  H$$HHmm  ZT]~K~K ? 8 ] r*  H$$HHmmp  01 ?RG  ];  T]lrlr ? L" ] SClick to edit Master notes styles Second Level Third Level Fourth Level Fifth Level"     TH  0jB? ? a(80___PPT10.03(  H(     T]~K~K ?v$  ] ^* H$$HHmm  T]~K~K ? 8$ ] `* H$$HHmm  Z]~K~K ?v  ] ^* H$$HHmm  Z\]~K~K ? 8 ] `* H$$HHmmH  0jB? ? a(80___PPT10.й 0  d<(  d~ d s *CT  ~ d s *$DTpP?   H d 0޽h ? ̙33y___PPT10Y+D=' G= @B +  0 @6(  x  c $Оf?P  f ~  s *f@Pp  f H  0޽h ? 333gggy___PPT10Y+D=' G= @B +  0 P)(  x  c $H?P   q   Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level0 Gtoolchain A collection of system softwares used to develop for a particular hardware target If you designed a new processor, what is the basic system software tool set you need? H R[ R [$  H  0޽h ? @Eff؂o___PPT10i. -+D=' G= @B +  0 `$,E(    6 8hI ; C program  R2  s *'   <8,@ 8Compiler   68nm  KAssembly language programR2  s *   <8,zV  9 Assembler   6h8  QObject: Machine language module     68  \*Object: Library routine (machine language)++R2   s * $     <"8&  6Linker   68   V$Executable: Machine language program%%R2   s *    <X8*   6Loader  6P/8 | ] 8Memory^B  6Db5^B  6D ^B  6D2+^B  6D"^B  6Dp # ^B @ 6D 3 ^B  6D* ^B  6D : + ^B  6D" 8   048 1A Typical Toolchain and its Translation Hierarchy22 |B @ TDǂjJ))?<~|B @ TDǂjJ))? l|B @ TDǂjJ))?  |B @ TDǂjJ))?6 |B  TDǂjJ))?`2  # l$;81))?2H [ Toolchain    |B   TDǂjJ))?j 2 ! 0|@8 n  @Debugger   2 * 0E8W !  E Utility tools |B +@ TDǂjJ))? 0 , 3 BCDEFA1))?.dcGE@  ZH  0޽h ? @Eff؂o___PPT10i./(+D=' G= @B +  0 p0(  x  c $XJ8?P  8 x  c $K8@P0 8 H  0޽h ? @Eff؂o___PPT10i.PC+D=' G= @B +  0 0(  x  c $,R8?P  8 x  c $S8@P0 8 H  0޽h ? @Eff؂o___PPT10i.+D=' G= @B +-  0 D<(  x  c $pa8?P  8    fb81))? gcc  v  O0  o foo foo.c (old Step 0: cpp) foo.i Step 1: cc1 - compiler foo.s Step 2: as - assembler foo.o Step 3: ld - linker foo 2 020H  0޽h ? @Eff؂o___PPT10i.+D=' G= @B +  0 0(  x  c $p8?P  8 x  c $Hq8@P0 8 H  0޽h ? @Eff؂o___PPT10i.f+D=' G= @B +  0 0(  x  c $v8?P  8 x  c $w8@P0 8 H  0޽h ? @Eff؂o___PPT10i.m9+D=' G= @B +  0 B:(    3 r\8gֳgֳ ??PO  8   C x 8gֳgֳ ?@P0 8 H  0޽h ? 333gggy___PPT10Y+D=' G= @B +  0   b(   x   c $l8?P  8     0X8 @PS" n  8 H   0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +  0 00(  x  c $8?P  8 x  c $X8@P0 8 H  0޽h ? @Eff؂o___PPT10i.WM+D=' G= @B +  0 @ (     `1))?h     f1))? x  c $[?P  [    fx81))?0  eAdd $10, $11,$12 Save $10, $12, $13 Jal B Restore $10, $12, $13 Sub $11, $2, $12 Mul $12, $10, $13 bf 2",%+   f[1))?    X Add $2, $4, $5 Br $31& 2   fT[1))?X x @ Function A  2    fP[1))?P 0p @ Function B  2 =   3 r[1))?E PK 7How to save ? - save to stack sw $10, 20(sp)&8 ((H  0޽h ? @Eff؂o___PPT10i.+D=' G= @B +   0 &P (  x  c $%[?P  [    `1))?p    f1))? e   ft'[1))?0 x  ;Add $10, $11,$12 Jal B Sub $11, $2, $12 Mul $12, $10, $13 D< 2",   f+B#style.visibility<*#6%(D' =+4 8?dCB0-#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<*#6D' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<*#6Dn' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*6T%(D' =+4 8?dCB0-#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<*6TD' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<*6TDn' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*w%(D' =+4 8?dCB0-#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<*wD' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<*w+  0 0(  x  c $ T[?P  [ x  c $T[@P0 [ H  0޽h ? @Eff؂o___PPT10i.p>\+D=' G= @B +  0 0(  x  c $Z[?P  [ x  c $[[@P0 [ H  0޽h ? @Eff؂o___PPT10i.im+D=' G= @B +  0 0(  x  c $+B#style.visibility<*%(D' =-6B'blinds(horizontal)*<3<*D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =+4 8?dCB1+#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<* D' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<* +8+0+ 0 +  0   t (    62\  "Static Library  # l4\1))? 0 kCall printf      f4:\1))?8 xH i Call printf    3 r8\1))?}& = Program A      fB\1))?eV C = Program B   0    fE\.M1))?0  ,$D  0 fPrintf: (  0    fJ\.M1))?(@ p ,$D  0 fPrintf: (  B    `D1))?  B    `D1))? 0 B  @  fD1))?( ( 0 B   `D1))?p H8p B   `D1))?(@@p B @  fD1))? @(H  0޽h ? @Eff؂o  ___PPT10 .)Z+k(D ' R\= @B D ' = @BA?%,( < +O%,( < +D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =+4 8?dCB1+#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<* D' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<* D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =+4 8?dCB1+#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<* D' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<* +p+0+ 0 ++0+ 0 +X 0 og(    6TY\  : Comparison    P\\ Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level0 Dynamic Less memory space Less disk space Most of the case: Slower Static More memory size More disk size Most of the case: fasterVZ<ZZ9Z<9 H  0޽h ? @Eff؂o___PPT10i.ǯm+D=' G= @B +  0 (0(  (x ( c $f\?P  \ x ( c $g\@P0 \ H ( 0޽h ? @Eff؂o___PPT10i.7s<+D=' G= @B +[  0 z(  x  c $8m\?P  \ Z  m\ @PRectangle: Click to edit Master text styles Second level Third level Fourth level Fifth levele- \ H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +-  0 TL@(    3 r\gֳgֳ ?@P^ \   s \gֳgֳ ??PO  \ H  0޽h ? 333gggy___PPT10Y+D=' G= @B +  0 >6P(    3 r\\gֳgֳ ?@P6y \   T \gֳgֳ?> D(cont d) H  0޽h ? 333gggy___PPT10Y+D=' G= @B +   0 4,`h(  hx h c $\?P}M  \ F ~ h ~ PN X `  h  Z h s *X `  h <\ +[ ;stack  h <\    B Dynamic date   ZB h s *DX `   h <\   >Reserved   ZB  h s *DX `   h <\   :Text ZB  h s *DX `   h <t\   A Static data   `B h 0DYY`B h 0DY4 YC  h <\]  l$sp 7fff ffff  h <8\  F 9hex `B h 0DQnn h <(\~L  l$gp 1000 8000  h <\ W  9hex `B h 0D ,  h <\ M  @ 1000 8000    h <0\ a !  9hex  h < \(  Ipc 0040 0000  h <\ R  9hex `B h 0D ?  h 0@\zX, k(From Patterson and Hennessy, p. 152; COPYRIGHT 1988 MORGAN KAUFMANN PUBLISHERS, INC. ALL RRIGHTS RESERVED)l l H h 0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +[  0 z(  x  c $T\?P  \ Z  ,\ @PRectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level/wO \ H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +[  0 z(  x  c $8\?P  \ Z  \ @PRectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level# \ H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +y  0 0(  x  c $]?P  ] x  c $]@P{ ] H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +[  0 z (  x  c $]?P  ] Z  ] @PRectangle: Click to edit Master text styles Second level Third level Fourth level Fifth levelDd ] H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +[  0 z0(  x  c $\*]?P  ] Z  +] @PRectangle: Click to edit Master text styles Second level Third level Fourth level Fifth levelD\d ] H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +y  0 @0(  x  c $,;]?P  ] x  c $<]@PJ ] H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +y  0 P0(  x  c $8K]?P  ] x  c $K]@P= ] H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +y  0 `0(  x  c $X]?P  ] x  c $Y]@P= ] H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +y  0 p0(  x  c $xo]?P  ] x  c $s]@P= ] H  0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +  0 4(  4x 4 c $?P    4  ZtZgֳgֳ ?@PRectangle: Click to edit Master text styles Second level Third level Fourth level Fifth levelf  ! 4 3 r$1))? !Caller save /Callee save register " " H 4 0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +  0   8u (  8x 8 c $??P}M   x 8 c $F@P=   8 # l1))? &  8 # l1))?T B 8 # lDԔ))?V   8 # lx1))?   =compile 2 8 # lT1))? 7  Sa.s 2x  8 # lb1))? W  \.text & Parameter pass Jal printf & .data 0/0  2)c,   8 # l1))?=  B  8  `Do))? C    8 # l1))? q1 :  >assembly  2   8 # lTh1))?   Sa.o 2N 8 3 r:1))? m  0323: Parameter pass 444: Jal reloc add.1 1> 8 # l1))?  8 3 rLq1))?7 oRef: 444   8 # l1))?  ea.o- relocation table 2H 8 0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +  0 "<(  <x < c $$?P}M     < # l1))?m    < # l1))?W w  Wa.o 2U < 3 ry1))?O #  5323: Parameter pass 444: Jal reloc add. ret6 P6> < # l1))?N  < # l1))?l  555: Create stack Process args $a0 <- file ID $a1 <- adds. Of heap $a2 <- length of string $v0 <- 4 (write) Syscall ret40  2z0 2c,S < # l{1))?af[ ^printf.o  2  < # l1))?>{ < 3 rИ1))? oRef: 444   < # l1))?=c  < 3 r1))?"  oDef: 555   < # lP1))?m  ia.o- relocation table 2  < # l1))? pprintf.o- relocation table  2 < # l1))?  < 3 r4S1))?& U.  }%L323: Parameter pass L444: Jal L555& & < # l1))? e5 dL555: Create stack Process args $a0 <- 1 $a1 <- adds. Of heap $a2 <- 13 $v0 <- 4 Syscall ret40  2^0 2ec,7 < # l1))?m f < # l1))? v {  >linker 2 < # l1))? KExecutable file  2  < # l1))?  < 3 rh1))??- KStart-up routine - !< 3 r1))?L !__main: jal main jal exit" ",  B "< # lDԔ))?:H < 0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +  0 '@(  @x @ c ${?P}M    @ # l1))?L  @ 3 r̄1))?9  }%323: Parameter pass 444: J reloc 555& & @ # l`ϊ1))?  d555: Create stack Process args $a0 <- 1 $a1 <- adds. Of heap $a2 <- 13 $v0 <- 4 Syscall ret.40  2_0 2ec,7 @ # l1))?E GExecutable file 2 @ # l<1))?3 - G(software trap) 2B @ 3 rD1))?f] &B @@ # lD>))? @ # lb1))? { A user mode  2 B @@ # lD>))?9 U  @ # l1))?yX s Gprivileged mode 2 @ # l1))?   'Set status register Jal trap(4) handler( 2(  @ # l1))? C !@ # lj1))?s Bm  Ktrap(4) handler  2` "@ # ln1))?Z   >what trap -- syscall $v0 ? ------- 4 Jal 4th function driver6? 2, ,  #@ # l1))?M l  $@ # l0=1))? %  \$Transfer 13 bytes to graphic display% 2% %@ S ~ӊ1))? "  M4th function driver  &@ # l1))?  '@ # l1))?#4 @ 3 rG1))?@ (__main: jal main jal exit main:) ),   H @ 0޽h ? @Eff؂oy___PPT10Y+D=' G= @B +r0^ Zp2; LbZ\F`eP]_pbkhylFv ^8?AZDF|IV9%P.aAcwOh+'0> d p|    0Computer Architecture What Does It Mean?? ?Guang R. GaoPC:\Program Files\Microsoft Office\Templates\Presentation Designs\Blueprint.potHWU78Microsoft PowerPoint 4.0@\D@MY@F!@ AG<;  G-  y--$xx--'--$:::--'-B( DD--$ --'-B( DD--$ --'-B( DD--$ --'-B( DD--$ --'-B( DD--$ --'-B( DD--$  --'-B( DD--$ $$%%%%%%%%$$--'-B( DD--$ ****++++****--'-B( DD--$ ///00000///--'-B( DD--$ 445555555544--'-B( DD--$ ::::;;;;::::--'-B( DD--$ ???@@@@@???--'-B( DD--$ DDEEEEEEEEDD--'-B( DD--$ JJJJKKKKJJJJ--'-B( DD--$ OOOPPPPPOOO--'-B( DD--$ TTUUUUUUUUTT--'-B( DD--$ ZZZZ[[[[ZZZZ--'-B( DD--$ ___`````___--'-B( DD--$ ddeeeeeeeedd--'-B( DD--$ jjjjkkkkjjjj--'-B( DD--$ ooopppppooo--'-B( DD--$ ttuuuuuuuutt--'-B( DD--$ xxxxx--'-B( DD--$ x x x x x --'-B( DD--$ xxxx--'-B( DD--$ xxxxx--'-B( DD--$ xxxxx--'-B( DD--$ x xxx --'-B( DD--$ %%x%x%x%x$x$%%%%%--'-B( DD--$ ++x+x*x*x*x***+++--'-B( DD--$ 00x0x/x/x//0000--'-B( DD--$ 55x5x5x5x4x455555--'-B( DD--$ ;;x;x:x:x:x:::;;;--'-B( DD--$ @@x@x?x?x??@@@@--'-B( DD--$ EExExExExDxDEEEEE--'-B( DD--$ KKxKxJxJxJxJJJKKK--'-B( DD--$ PPxPxOxOxOOPPPP--'-B( DD--$ UUxUxUxUxTxTUUUUU--'-B( DD--$ [[x[xZxZxZxZZZ[[[--'-B( DD--$ ``x`x_x_x__````--'-B( DD--$ eexexexexdxdeeeee--'-B( DD--$ kkxkxjxjxjxjjjkkk--'-B( DD--$ ppxpxoxoxoopppp--'-B( DD--$ uuxuxuxuxtxtuuuuu--'-B( DD--$ {{x{xzxzxzxzzz{{{--'-B( DD--$ xxxx--'-B( DD--$ xxxxx--'-B( DD--$ xxxxx--'-B( DD--$ xxxx--'-B( DD--$ xxxxx--'-B( DD--$ xxxxx--'o--%)--'o--%A--'o--%Y55--'o--%t --'o-- %     --'o--%)__--'o--%6h--'o-- %__``aaa``_^]]]--'@"Tahoma-. @E2 u 10/14/2005. "System7-@"Tahoma-. @E 2 u>\.-@"Tahoma-. @E2 u?course.-@"Tahoma-. @E 2 uE\.-@"Tahoma-. @E2 uFcpeg323.-@"Tahoma-. @E 2 uM-.-@"Tahoma-. @E 2 uN05F.-@"Tahoma-. @E 2 uR\.-@"Tahoma-. @E2 uSTopic2d.-@"Tahoma-. @E 2 uZ-.-@"Tahoma-. @E2 u[323.ppt.-@"Tahoma-. @E 2 u1.-@"Arial-. ff2 ETopic2d.-@"Arial-. ff 2 #High.-@"Arial-. ff 2 5-.-@"Arial-. ff%2 8Level languages and .-@"Arial-. ff2 $4System Software.-@"Arial-. ff 2 ->(.-@"Arial-. ff2 -A Toolchain.-@"Arial-. ff 2 -f).-@"Arial-. @E-2 C,Introduction to Computer .-@"Arial-. @E$2 L3Systems Engineering .-@"Arial-. @E2 \C (CPEG 323).-՜.+,D՜.+,H    Letter Paper (8.5x11 in)!0 8Times New RomanTahoma Wingdings宋体ArialSymbol Murray Bold Blueprint?Topic2d High-Level languages and System Software (Toolchain) Reading List Tool ChainSlide 4 Tool Chain Tool Chain Tool ChainTool Chain - PreprocessorTool Chain - CompilerParameter PassingSaving RegistersWhy caller save / callee save? Caller save Callee SaveCaller Save / Callee SaveTool Chain - AssemblerTool Chain - LinkerTool Chain - loaderTool Chain – Library Tool Chain Slide 21Compiling/Assembling a ProgramRelocation TableLinking a programLoading Libraries Slide 27 Slide 28 Slide 29 Slide 30 Debugger Debugger Run a Executable File (OS View) Slide 34%Typical Layout of an Executable FileThe Role of the OS Kernel$Processor Support for the OS kernelTrapsTrap HandlersSoftware Traps System CallsExample: Call to printf()Calling printf()Processing the TrapToolchain ReviewProgram TranslatesProgram Translates(cont.)Program Translates (Cont.)  Fonts UsedDesign Template Slide Titles0 8@ _PID_HLINKSAdhttp://www.intel.com/_0HWUHWU  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./02345678:;<=>?@ERoot EntrydO)PicturesCurrent User9SummaryInformation(>PowerPoint Document(DocumentSummaryInformation81