Assembly Language from a Modern Point of View (open
"Why is this course different from all other assembly language courses?"
- Sadly, most courses in this subject are taught as if assembly
language is "just another programming language," failing to make the
material relevant to students and to computer systems.
- This textbook takes a quite different approach, treating the
subject as COMPUTER SYSTEMS, a vehicle with which
students can "look under the hood," to gain an understanding of what
the machine--both the hardware and the lower-level software--is
really doing with that C/C++ code the students write.
- Examples of "what is different":
- We use a real machine (Intel x86 famile) with a real OS
(Linux), rather than a simulator, and look at real code in the
Linux OS. This means that the concepts become much more concrete.
(If your lab lacks Linux platforms, you can use the
Linux virtual machine image with VMplayer.)
- We look at assembly code produced by the compiler by C/C++.
- We discuss how int, float,
char, struct, pointers and
classes are stored in terms of memory allocation.
- We show how assembly language code can be used to take
advantage of hardware features for enhanced performance.
- We stress the point that data types, language features and so
on are just imaginary, and that the hardware is unaware of them.
- Our study of hardware interrupts leads naturally to an
introduction to operating systems, including the boot process,
timesharing and virtual memory.
- We look at what goes on behind the scenes with calls to the C
library, and with system calls.
List of units:
storage: Bit, bytes, hex notation; memory words, addresses;
endian-ness; internal storage of int,
float, char, classes; how pointers
work internally; "What really happens when you print the integer 24 to
the screen?"; no such thing as type, language constructs in the
hardware; how files are stored on disk; memory allocation of C/C++ global, local
variables; "What really happens with a seg fault?"
Computer organization: Concept of a bus, including data, address and
control lines; CPU registers; CPU fetch/execute cycle; parallel
operations; clock rate; caches: blocks, lines, direct vs. associative
mapping; write policies; disk caches.
Intel assenbly language and linking: The Intel architecture; the
assembler as a "clerk"; introduction to frequently-used Intel machine
instructions and addressing modes; what happens in the linking process;
what happens in the compiling process; libraries; headers in executable files;
inline assembly code in C++; debugging of assembly language code.
More on arithmetic and logic operations: Signed and unsigned
multiplication and dividsion; carry and overflow; advanced jump
instructions; logic instructions; floating-point instructions.
Intel machine language: Relation of assembly language to machine
language; a few instruction formats; format and operation of jump
instructions; a look at an executable file.
Subroutines: Stacks; CALL, RET instructions; storage of arguments;
interfacing C/C++ to assembly language subroutines; calling C and the C
library from assembly language; local variables; use of the EBP
register and the GCC calling convention; notion of a stack frame; ENTER,
LEAVE, LEA instructions; the C function main() IS a
function, like any other; subroutine calls are "expensive"; debugging
assembly language subroutines; macros.
I/O ports and device structure; I/O space vs. memory-mapped approaches;
wait-loop I/O; PC keyboards; hardware interrupts: motivation, service
routines, memory permissions, identification and prioritizing of
interrupting devices; DMA; disk structure; USB devices.
to operating systems:
An OS is just a program; need for an OS; OS role in program loading and
execution; static vs. dynamic linking; strace command;
OS bootup actions; timesharing: processes "taking turns," need for
hardware timer, sample Linux OS source code, process states; background
jobs; threads; virtual memory: motivations for VM, page mapping, page
faults, access violations, enhanced performance via TLB, interactions
with caches; more on system calls; OS file management.
to RISC---the MIPS architecture: Motivation for the RISC approach;
beneficial effects for compiler writers; MIPS case study;
branch prediction; delayed branch.
- The Java
Why is the JVM "virtual"?; how to inspect JVM byte code; local
variables; function arguments; implementation of instance vs. class
methods; implementation of constructors; JVM jumps.