High level language and
low level language programming
-
High level
programming:
- In
CS170/CS171,
you were writing computer programs in
a
high level
programming language
-- e.g.: Java
-
High level
language programming
uses
statement
constructs
E.g.:
|
-
Low level
programming:
-
Low level
programming
does
not have
any
language constructs
-
Low level
programming does
not have:
assignment statements,
if,
while, etc
|
|
High level language and
low level language programming
-
High level
programming:
- The
computer
cannot
(directly) execute
a
computer program written
in a
high level
programming language
- A
high level language
program
must be
compiled (= translated) into
machine code
first
- A compiler
(e.g.: javac)
will
translate
statements
in a
high level
programming language into
a
series of
machine instructions that
achieve the
result
of the statements.
|
-
Low level
programming:
- There is a
one-to-one correspondence
between:
Low level instruction <---> Binary machine instruction code
|
|
|
The
historical development of
computer programming languages
The
first generation
programming languages:
(reference:
click here )
The
historical development of
computer programming languages
The
2nd generation
programming languages:
(Wikipedia:
click here )
- ~1950: introduction of
assembler
programming language
-
Assembler language uses
English mnemomics
to represent
binary
machine instructions:
- A
simple
translation program
(called the assembler)
translates
each mnemomic
into
one (1) machine instruction
|
The
historical development of
computer programming languages
The
3rd generation or
"High level"
programming languages:
(Wikipedia:
click here )
- In 1957,
the first
high level
programming language
(Fortran) was
available
- A very complex
translation program called a
compiler is used
to translate the
statements into
binary computer (machine) instructions
in a 2 step process:
|
Example to show you the
entire program compilation process - DEMO
The programmer write a
program in a
High level language program
(C language):
int x, y, z;
int main( )
{
z = x + y;
}
|
DEMO:
/home/cs255001/demo/translation-process/prog.c
Example to show you the
entire program compilation process - DEMO
The programmer write a
program in a
High level language program
(C language):
int x, y, z;
int main( )
{
z = x + y;
}
|
The
compiler will
translate the
(C) program into
an
equivalent program
in
assembler code:
main:
str fp, [sp, #-4] // These assembler codes
add fp, sp, #0 // perform: z = x + y
ldr r3, .L3
ldr r2, [r3]
... (many more, omitted for brevity)
|
One (1) statement will
translate into
many
assembler instructions !!
DEMO:
/home/cs255001/bin/cc255 -S prog.c
Example to show you the
entire program compilation process - DEMO
The program in
assembler code is
further processed by
the
assembler:
main:
str fp, [sp, #-4]
add fp, sp, #0
ldr r3, .L3
ldr r2, [r3]
...
|
Example to show you the
entire program compilation process - DEMO
The program in
assembler code is
further processed by
the
assembler:
main:
str fp, [sp, #-4]
add fp, sp, #0
ldr r3, .L3
ldr r2, [r3]
...
|
The
assembler will then
translate the
assembler codes into
(binary)
machine instruction codes:
00000000 <main>:
0: e52db004 <-- binary number written in hexadcimal
4: e28db000 // These are (binary) machine codes !!!
8: e59f3028
...
|
DEMO:
/home/cs255001/bin/cc255 -c prog.s (dump255 prog.o)
Why
is
assembler programming
a
core course
in Computer Science
You can
expose the
details the following
Computer Science
concepts
using
assembler programming:
- What happens inside the computer
when you
define a
variable in your
program ?
- How does
a computer program
use
array variables ?
- How does
a computer program
use
linked list variables ?
- What happens inside the computer
when an
assignment statement is
executed ?
- What happens inside the computer
when an
if-statement is
executed ?
- What happens inside the computer
when a method
passes parameters and
returns a value
- What happens inside the computer
when a
parameter is
passed by value and
passed by reference ?
- What happens inside the computer
when a
recursive function/method is
executed ?
- Etc, etc
|
All these
concepts and more will be
explained in
CS255 - and
illustrated with
assembler codes
❮
❯