G A IFT FROM NITA For those of you who asked: http://www.contrib.andrew.cmu.edu/~anitazha/15213_tips.html A ’ S A NITA S UPER WESOME R S ECITATION LIDES 15/18-213: Introduction to Computer Systems Assembly and GDB, 4 Feb 2013 Anita Zhang, Section M M W ANAGEMENT AND HATNOT (cid:1) FAQ: http://www.cs.cmu.edu/~213/faq.html (cid:1) Read this before anything else It may be updated (cid:1) (cid:1) Answers to “Permission denied” errors, etc (cid:1) Style: http://www.cs.cmu.edu/~213/codeStyle.html (cid:1) RReeaadd iitt,, ffoollllooww iitt (cid:1) Style is worth 5-10 points every lab. Don’t lose it. (cid:1) .vimrc and .emacs configurations help your style (cid:1) TA Feedback: https://www.ugrad.cs.cmu.edu/ta/feedback (cid:1) Because we want to make your experience that much better W ’ A T ? HAT S ON THE GENDA ODAY (cid:1) Books (again) (cid:1) Motivation (cid:1) Registers (cid:1) Assembly Instructions (cid:1) BBoommbbllaabb OOvveerrvviieeww (cid:1) Bomblab Hints (cid:1) GDB (cid:1) Walkthrough W H Y R ? HAT AVE OU EAD (cid:1) Randal E. Bryant and David R. O'Hallaron, Computer Systems: A Programmer's Perspective, Second Edition, Prentice Hall, 2011 (cid:1) Brian W. Kernighan and Dennis M. Ritchie, TThhee CC PPrrooggrraammmmiinngg LLaanngguuaaggee,, SSeeccoonndd EEddiittiioonn,, Prentice Hall, 1988 (cid:1) Koenig, Andrew. C Traps and Pitfalls. Reading, MA: Addison-Wesley, 1988 (cid:1) Kernighan, Brian W., and Rob Pike. The Practice of Programming. Reading, MA: Addison-Wesley, 1999 W A W D T A ? HY RE E OING HIS GAIN B M (.. ) ETTER OTIVATION OR NOT R A T B EGISTERS AND LL HEM ITS %rax – 64 bits %eax – 32 bits (cid:1) Quad = 64 bits (cid:1) Doubleword = 32 bits %ax – 16 bits (cid:1) Word = 16 bits (cid:1) Byte = 8 bits %ah %al 8 bits 8 bits These are all parts of the same register W W ’ W W HAT E RE ORKING ITH (cid:1) General Purpose (x86) (cid:1) Caller Save: %eax, %ecx, %edx (cid:1) Callee Save: %ebx, %esi, %edi, %ebp, %esp (cid:1) x86_64 conventions on the next slide (cid:1)(cid:1) SSppeecciiaallss (cid:1) %eip – instruction pointer (cid:1) %ebp – frame pointer (cid:1) %esp – stack pointer (cid:1) Conditional Flags (cid:1) Sit in a special register of its own (cid:1) Carry (CF), Parity (PF), Zero (ZF), Sign (SF), Overflow (OF) are the ones you need to worry about 86_64, LOTS R ! X OF EGISTERS 64 bits wide 32 bits wide 16 bitswide 8 bits wide 8 bits wide Use %rax %eax %ax %ah %al Return Value %rbx %ebx %bx %bh %bl CalleeSave %rcx %ecx %cx %ch %cl 4thArgument %rdx %edx %dx %dh %dl 3rdArgument %rsi %esi %si %sil 2ndArgument %rdi %edi %di %dil 1stArgument %rbp %ebp %bp %bpl CalleeSave %rsp %esp %sp %spl Stack Pointer %r8 %r8d %r8w %r8b 5thArgument %r9 %r9d %r9w %r9b 6thArgument %r10 %r10d %r10w %r10b CallerSave %r11 %r11d %r11w %r11b Caller Save %r12 %r12d %r12w %r12b CalleeSave %r13 %r13d %r13w %r12b CalleeSave %r14 %r14d %rw %14b CalleeSave %r15 %r15d %r15w %15b CalleeSave
Description: