CS计算机代考程序代写 assembly chain cache prolog 3.1 Slide Deck #1: Data Representation

3.1 Slide Deck #1: Data Representation
• Terminology: bit, byte, least significant bit/byte (LSB), most significant bit/byte (MSB).
• You should be comfortable interacting with and converting between values in bases 2 (binary), 8 (octal), 10 (decimal),
and 16 (hexadecimal). Understand how unsigned values are represented.
• Base 2 addition.
• Representing signed values in signed-magnitude form.
• Representing signed values in two’s complement form.
• Determining overflow when adding unsigned integers vs. signed integers (two’s complement form).
• How many different values can be represented with n bits?
• Where the minimum and maximum of C integer types come from.
• Multidimensional arrays.
– Row-major order vs. column-major order. – “Contiguous version” vs. pointer array.
• Bit operations. Understand each of these conceptually and how to use them in C/ C++. – Bitwise AND.
*This content is protected and may not be shared, uploaded, or distributed. 1

– Bitwise OR.
– Bitwise XOR.
– Bitwise NOT.
– Left shift.
– Right shift. Logical vs. arithmetic.
• Representing real numbers.
– Fixed-point format. Components: sign, integer component, fractional component. – Floating-point format.
∗ Components: sign, mantissa, exponent. Understand the trade-offs in giving more bits to the mantissa and less bits to the exponent, and vice- versa.


∗ Normalization.
∗ You do not need to understand why it is preferable to store the sign,

exponent, and mantissa in that order.


• •
∗ You do not need to understand why a bias is applied when the exponent is stored.
∗ There might be at least one question about the single-precision, double- precision, extended-precision, quad-
precision, and half-precision formats. If you sufficiently understand the floating-point format and the benefits
of more bits for the mantissa and exponent, then this question(s) shouldn’t be an issue.
∗ You will not be asked about “guard bits”.
∗ You will not be asked about the IEEE special values.

∗ Floating-point error.
• No types or access control at the hardware level.
3.2 Slide Deck #2: Computer Organization
• The four steps of compilation.
• Components of a computer. Von Neumann architecture (VNA). CPU/processor, main memory (RAM), I/O facility.
• You will not be asked about the terminology on slide #15, e.g. core, multi-core processor, etc. I might use the term
“core”, but you can think of it as being synonymous to “processor”, for now.
• Components of CPU core:
– Arithmetic logic unit (ALU). Understand what the ALU does. – Control unit (CU).
– Flags. (See in slide deck #3 for more on flags.)
– Registers.
∗ Be comfortable with using the 16 different 64-bit general-purpose registers and accessing their lower 32 bits, 16 bits, or 8 bits.
∗ IP, IR, and RFLAGS.
∗ MAR and MDR. (mentioned below)
• Instruction cycle. Understand how the instruction pointer and the instruction register change as a program is run.



• Memory hierarchy. Understand the properties of the different forms of memory, most importantly speed and volatility.
• Main memory organization: word, byte-addressable vs. word-addressable, endianess.
• Program loading. Process memory layout. ROM.
• Communication with main memory. Role of the three sub-buses: data bus, address bus, and control bus. Role of the
MAR and MDR in memory reads and writes. Understand the effect of the address bus size.
• You will not be asked about processor size.
• Cache.
• – Understand how a cache is supposed to work and how it helps us. Cache hit vs. cache miss.
• – Understand temporal locality of reference and spatial locality of reference. Be able to identify occurrences of these.
• – You will not be asked about cache organization, e.g. blocks, lines, fully-associative vs. set-associative vs. direct-
mapped, etc. That will be for ECS 154A.
• Secondary storage. – Very slow.
– Nonvolatile.
– Where files are stored.

3.3 Slide Deck #3: Intro to the x86-64 Assembly Language
You should understand all of the examples that we talk about during lecture and all of the parts of programming assignment #3.
2
• Hopefully needless to say, you will not be asked about the Intel syntax. You will only be asked about the AT&T syntax.
• Format and syntax of an x86-64 program. .data section vs. .text section. _start. Directives/pseudoinstructions. Labels.
• Where possible, I will try to minimize the need to understand instruction suffixes, e.g. the l at the end of a movl
instruction or the q at the end of a addq instruction.
• Variable/data/array-related directives: .quad vs. .long vs. .word vs. .byte. .rept and .endr. .space. .string.
• Denoting a hexadecimal constant with 0x.
• Understand the role that the memory hierarchy plays in assembly code.
– Should make smart use of registers in order to minimize accesses to main memory where possible. – Can’t access memory with both operands of an instruction.
• Below is a list of instructions that I expect you to be able to use and that we talked about. (If I missed any very important ones, please let me know.)
– mov.
– cmp.
– Jump instructions:
∗ Typical comparisons: jl, jle, jg, jge. ∗ Equality checking: je, jne. ∗ Unconditional jump: jmp.
∗ Zero: jz, and jnz.

– Integer arithmetic: add, sub, imul (both the two-operand form and the one- operand form), idiv, inc, and dec. – Bitwise operations: and, or, xor, shl/sal, shr, and sar.
– nop.
– You will not be asked to perform a system call (i.e. to use syscall).
• Addressing modes: immediate mode, register mode, direct mode, indirect mode, indexed mode.
• Loops in assembly code.
• Dealing with arrays of integers and arrays of characters (i.e. strings).
• The different flags: zero flag, sign flag, overflow flag, and carry flag. Understand how the flags allow the jump instructions
to operate.
• Math in immediate mode.
3.4 Slide Deck #4: More on the x86-64 Assembly Language
You should understand all of the problems in programming assignment #4.
• Understand the concept of the activation stack and its interaction with return addresses and local variables; understand how the contents of the stack changes as functions begin and end. Towards the beginning of this slide deck, there is a simplified view, but as the slide deck goes on, the details get more complicated. You are expected to know the complicated details as listed below, up to and including how a chain of functions behaves (as shown on slide #73).
• You should understand all of the examples in this slide deck.
• Basic manipulation of the stack with push and pop.

• The steps in calling a function; what needs to be pushed to the stack (when calling a function) and why. The call
instruction.
• The steps in returning from a function. The ret instruction.
• Returning a value.
• Cleaning up the stack after calling a function. Why we do this.
• “Based addressing” mode (technically not different from indexed addressing mode).
• Scale-factor addressing mode.
• Register preservation and why we do this.
• You will not be asked about a specific well-known calling convention (e.g. System V AMD64), anything about ABIs, or
anything about volatile vs. nonvolatile registers. Where applicable, I will always tell you the exact calling convention a
function is using, just like I do in programming assignment #4.
• Stack frame. RBP (frame/base pointer). Function prologue and epilogue.
• Be able to determine offsets (from stack pointer or base pointer) to access function arguments on the stack.
• Stack-based local variables.

• enter and leave.
• You should be able to write basic functions that:
– Take arguments on the stack or in registers. – Use stack-based local variables.
3
– Take pointer arguments (i.e. addresses of variables) and use those arguments to modify the referenced variables.
• You should be able to write caller code (i.e. code that calls a specific function following a given convention). • lea instruction.