Lecture 1. H.intro
Lecture 1. H.intro
Object-Oriented Programming
COMP2011: Introduction
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;
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 mainly stick to C++ 2003 but will talk about some useful
new features from C++11 later in the course.
(The compiler you will use in CSE lab is C++11-compliant.)
Which compiler?
GNU gcc/g++. It is free.