Title: CS2422 Assembly Language and System Programming
1CS2422 Assembly Language and System Programming
- Department of Computer Science
- National Tsing Hua University
2Announcement
- Two sessions for this course
- CS2422-01 (?????)
- CS2422-02 (?????)
3Course Administration CS2422-02
- ???? ???
- ??? ???443 ?? 42804email king_at_cs.nthu.edu.tw
- ?? ???????
- ??? ???734 ?? 53553
- ????
- ???1520-1710 ???1520-1610
- ???? ???236
- ???? http//www.cs.nthu.edu.tw/king/courses
/cs2422.html
4Textbooks
- Kip Irvine, Assembly Language for Intel-Based
Computers, 5th ed. - Leland Beck, System Software
- Using the first 4 chapters
- Other good books
- Patterson and Hennesey, Computer Organization
and Design (not Intel-based, textbook of CS4100) - The Art of Assembly (freely available online)
5Honor Code
- University code will be followed strictly to
handle the cheating in assignments and exams. - You are allowed (and in fact encouraged) to
discuss the assignments, but the work must be
your own.
6Grading (Subject to Change)
- 1. Program assignments 60
- 2. Mid-term exam. 20
- 3. Final exam 20
- Early bonus 2 each day early, up to two days
- Late penalty -20 each day (or partial day) late
- The instructor reserves the right to normalize
(including shift and scale) the scores for the
purpose of achieving fair grade distribution
within the class or across classes
7Whats Next?
- Basic concepts
- What is assembly language, assembly program,
and assembler? - How are they related to computers?
- Why this course?
8?????????
????
??
9????
10???????????
11???????????????
?? 1 2 3 4 5 6 7 8
9/17 ? ? ? ? ?
9/18 ? ? ? ? ?
9/19, 9/21, 9/23 ? ? ? ? ?
9/20, 9/22, 9/24 ? ? ? ? ? ?
9/25 ? ? ? ?
12???????????????
??? ?? ?? ?? ??
9/17 ? ?
9/18 ? ? ?
9/19, 9/21, 9/23 ? ?
9/20, 9/22, 9/24 ? ?
9/25 ?
13???????????
- ???????9/17????
- 9/17???????
- 9/18??????????
- 9/19?9/24??,?????????,??????????
- 9/25????
- (????????)
- ??????????????
14Computer Analogy
Machine code
10110110 11101010 01010111 11011011 00100111
15Computer Analogy
Assembly program
?
16Computer Analogy
High-level Language Program
?
17Assembly Language
- Machine language
- Machine instructions direct instructions to the
processor, e.g. to be encoded to control the
datapath - A numeric language understood by the processor
- Assembly language
- Statements (instructions) in short mnemonics and
symbolic reference, e.g. ADD, MOV, CALL, var1, i,
j, that have a 1-to-1 relationship with machine
instructions - Understood by human
18From C to Assembly
C
x (ab) b
Assembly
MOV AX, a ADD AX, b MUL c MOV x, AX
C compiler
19From Assembly to Binary
Assembly
MOV AX, a ADD AX, b MUL c MOV x, AX
Assembler
00000000101000010000000000011000
00000000100011100001100000100001
10001100011000100000000000000000
10001100111100100000000000000100
10101100111100100000000000000000
10101100011000100000000000000100
00000011111000000000000000001000
Machine code
20Different Levels of Abstractions
temp vk vk vk1 vk1 temp
High Level Language Program
Compiler
- MOV AX, a
- ADD AX, b
- MOV x, AX
Assembly Language Program
more elaborated later in Sec. 1-2 Virtual
Machine Concept
Assembler
0000 1001 1100 0110 1010 1111 0101 1000 1010 1111
0101 1000 0000 1001 1100 0110 1100 0110 1010
1111 0101 1000 0000 1001 0101 1000 0000 1001
1100 0110 1010 1111
Machine Language Program
Machine Interpretation
Control Signal
ALUOP03 lt InstReg911 MASK
21Comparing Assembly to High-Level Languages
22System Programming
- Programming of system software
- Programs that support operation of a computer
itself, rather than any particular application - Examples text editor, compiler, loader or
linker, debugger, macro processor, operating
system, database management systems, .
23System Programming
- Assembler
- A computer program to translate an assembly
program into the processors object code - Translates assembly instruction mnemonics into
opcodes, and resolves symbolic names for memory
locations and other entities - Linker
- A program that takes one or more objects
generated by compilers/assemblers and assembles
them into a single executable file - Loader
- A program to load executables into memory,
preparing them for execution and executing them - Usually a part of operating system
24Whats Next?
- Basic concepts
- What is assembly language, assembly program,
and assembler? - How are they related to computers?
- Why this course?
25Why This Course?
- A great way to learn how a computer works
- To talk in the languages of the processors
- To see how a computer talks to other devices
- To write very efficient code (size speed)
- To build solid background for other courses
- Computer Architecture, Compilers, Operating
Systemsetc.
26Even More Important Now
- A few examples
- The SOC (System-On-Chip) and embedded system
trend - The era of ubiquitous computing
- For graphics folks the DirectX and OpenGL
shading languages - The hardware/software boundary is blurring