2016/Asm1

From CS61
Jump to: navigation, search

9/20 Assembly Language 1: Calling Conventions and Arithmetic

  • Today's Exercise
  • Lecture notes
  • Lecture code is in cs61-exercises/asm1.
  • Reading:
    • 3.1: Historical Perspective
    • 3.2: Program Encodings -- if you don't read anything else, read the aside on page 177. If you do not read this, and you use assorted web resources to understand how specific instructions work, you will be confused.
    • 3.3: Data Formats
    • 3.5: Arithmetic and Logical Operations
    • 3.7: Procedures
    • For fun, a historical note on big vs. little-endian: On Holy Wars and a Plea for Peace

NOTE -- if you are using the second edition of the textbook, it presents the 32-bit x86 architecture; we are using the 64-bit architecture. The concepts are the same, but the details are different. You might find CMU's x86 64 handout helpful. You will also find additional resources on the Resources page. Finally, there are videos from last year, but again, they are about the 32-bit architecture -- principles are the same; details differ:

    • Arithmetic This material is unchanged by the move from 32-bits to 64-bits
    • Introduction to Assembly The material on Slide 3 and Slide 6 is most subject to change from 32 to 64.
    • Arithmetic and Logical Operatos This is mostly applicable, except that it doesn't include the fact that we now have instructions that operate on 64-bit types, the "q" class instructions.
    • Calling Conventions I hesitate to put this one up as the calling conventions on x86-64 are quite different. Nonetheless, the idea of a stack frame, which is central to understanding assembly code, is explained here. So, watch this, but keep in mind that, in general, on the 32-bit architecture, function call parameters are passed on the stack, while on the 64-bit architecture, they are passed in registers. Can you think of a reason why this changed?