Programming With C++ COMP2011: Introduction: Cecia Chan Albert Chung Cindy Li
Programming With C++ COMP2011: Introduction: Cecia Chan Albert Chung Cindy Li
Programming With C++ COMP2011: Introduction: Cecia Chan Albert Chung Cindy Li
COMP2011: Introduction
Cecia Chan
Albert Chung
Cindy Li
HUMAN
INSTRUCTIONS
PROGRAM
Memory
CPU
Control
ALU I/O devices
Unit
main:
!#PROLOGUE# 0
save %sp,-128,%sp
!#PROLOGUE# 1
mov 1,%o0
st %o0,[%fp-20]
mov 2,%o0
st %o0,[%fp-24]
ld [%fp-20],%o0
ld [%fp-24],%o1
add %o0,%o1,%o0
st %o0,[%fp-28]
mov 0,%i0
nop
int main( )
{
int x, y, z;
x = 1;
y = 2;
z = x+y;
return 0;
}
x = 1;
x and y have the value of
y = 2;
1 and 2 respectively. z = x+y;
It is based on the
number of Google
searches on the
languages’ tutorials.
For example,
machine A compiler a.cpp −→ a.out (or a.exe).
Why C++?
Read the FAQ from the designer of C++, Bjarne Stroustrup.
Which C++?
The language has been evolving:
C++ 1983 ⇒ C++ 1998 ⇒ C++ 2003 ⇒ C++ 2011 ⇒ · · ·
We will learn C++11 (but not all the new features).
Which compiler?
GNU gcc/g++. It is free.
(The compiler you will use in CSE lab is C++11-compliant.)