Title: CS2422 Assembly Language and System Programming
1CS2422 Assembly Languageand System Programming
- Department of Computer Science
- National Tsing Hua University
- September 16, 2008
2Announcement
- Two sessions for this course
- CS2422-01 (?????) Rm 234
- CS2422-02 (?????) Rm 236
3Course Administration CS2422-01
- Instruction Medium English
- ???? ???
- Email spoon_at_cs.nthu.edu.tw
- ??? ???739 ?? 31308
- ??
- ??? Email g962508_at_oz.nthu.edu.tw
- ??? Email g9762562_at_oz.nthu.edu.tw
- ??? Email g9762519_at_oz.nthu.edu.tw
- ????
- ??? (Tue) 1520-1710 ???(Thu) 1520-1610
- ???? ???234
- ???? www.cs.nthu.edu.tw/spoon/courses/CS242
201.htm
4Textbooks
- Kip Irvine, Assembly Language for Intel-Based
Computers, 5th ed. - Leland Beck, System Software
- Using the first 4 chapters
- Other good reference 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????????? How to irrigate the fields/farms?
????(water channels)
??(reservoir)
9???? (Water Channels)
10???????????How to divide into areas for watering?
?? Watergate
11???????????????Schedule of Watergates at Control
Center
12??????????????? Schedule of Irrigation Areas for
Officer
13???????????Commands from Officer for Irrigation
- Start irrigation from 9/17
- Irrigate ????? on 9/17
- Irrigate ???????? on 9/18
- Take turns to irrigates areas from 9/19 to 9/24
irrigate ????? for one day,
irrigate ????? for another day . - Irrigate?? on 9/25
- (????????)
- ??????????????
- How irrigation relates to computers?
14Computer Analogy
Machine code
10110110 11101010 01010111 11011011 00100111
15Computer Analogy
?????? Schedule of Irrigation Areas
Assembly program
????? Schedule for Watergates
?????? Schedule of Irrigation Areas
?
16Computer Analogy
?????? Commands from Officer
High-level Language Program
?????? Commands from Officer
?
17Assembly Language
- Machine language
- Machine instructions direct instructions to the
processor - 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) c
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