1.2 - Computer Organisation & Programming Languages2024S1
1.2 - Computer Organisation & Programming Languages2024S1
statement do something
Hardware and Software
Programs and data
Hardware
Software Categories
Operating System
• controls all machine activities
• user interface to the computer
• manages resources such as the
CPU and memory
Hardware – CPU and Main Memory
Information is moved
between main memory
and secondary memory
as needed
Central Processing Unit
Hard disk/SSD
Main
Memory Removable
storage
Secondary memory
devices provide
long-term storage
Typical Hardware Configuration
Screen
CPU
Keyboard
I/O (Input Output)
devices for
communication
with CPU Hard disk/SSD
Main
Memory Removable
storage
The Central Processing Unit
• A CPU is also called a microprocessor
• It continuously follows the fetch-decode-execute
cycle:
Retrieve an instruction from
Fetch main memory
Execute Decode
Carry out the instruction; Determine what the
access and modify data if instruction is
instructed to
Memory
9278
9279 00101010 personAge
9280 personAge is called a variable
9281
9282
9283
9284
9285
9286
9278
9279 00101010 byte personAge
9280 personAge is a variable of type ‘byte’
9281 It can represent integer values from
9282 –128 to 127
9283
9284
9285
9286
High-level languages:
Python
SQL
Java
C
assembly language
machine code
Why Java (or equivalent)?
movq $4, %rax
movq $1, %rbx
movq $string, %rcx
movq length, %rdx
int $0x80
movq %rax, %rbx
return syscall exit status
movq $1, %rax
int $0x80
*Of course, it really is that, but that’s just how the program’s execution is
realised in a physical machine
What is a language?
Correct Syntax
a cat
• valid words and sat on under
symbols mat dog the
• valid ways of arranging
them the cat sat on the mat
Correct semantics
• what the arrangement
of symbols means
the mat sat on the cat
What is a programming language?
Syntax personCase
class void { }
• valid words and symbols public +-*/
• valid identifiers (new personAge main
‘words’)
• valid ways of arranging byte personAge = 25;
them
Semantics
• what the arrangement of 00011001
symbols means
personAge
A basic Java program
}
}
A basic Java program
Identifiers: author-given names for types (class names) and variables
• Jabber is a name we chose (so is args)
• String, System, out, println, main chosen by Java library authors
• main is a special name: program execution always starts here
Java
bytecode
Java
virtual >java MyProgram
MyProgram.class
machine
Executable
/executing machine
code
(Simplified) Program Development
Familiarise
Do Task 1PP
yourself with
Hello World
the MyLO site