Download presentation
Presentation is loading. Please wait.
1
Introduction to Computers and Programming
Hardware Software Computer languages Compiling, interpreting and assembling
2
Computer Basics A computer system consists of both hardware and software. Hardware - the physical components Software - the instructions, or rather, computer programs, that tell the hardware what to do
3
Common Hardware Components
Memory Processor (CPU) Input Devices (such as mouse and keyboard) Output Devices (such as video display or printer) Processor: Central Processing Unit (CPU) interprets and executes program instructions Memory: volatile and non-volatile holds data and instructions Input devices: keyboard, mouse, touch-screen game controllers sensors Output device(s) video display, printer robotic devices
4
Classification of Memory
At a high-level there are two types of memory: Volatile – contents are lost when power is turned off: Main memory (stores programs and data during execution) Cache memory Fastest and most expensive form of memory, per byte Non-Volatile – contents are maintained when power is turned off: Hard drive (internal or external, stores programs and data permanently) CD, DVD Flash drive, floppy disk Tape (still used extensively) Slowest and cheapest form of memory, per byte
5
Memory Organization Bit = one binary digit, either 0 or 1
Byte = 8 bits Word = machine dependant, typically 4 bytes Larger groupings: (number of bytes) name approximation exact Kilobyte (KB) 2^ ^3 Megabyte (MB) 2^ ^6 Gigabyte (GB) 2^ ^9 Terabytes (TB) 2^ ^12 Petabyte (PB) 2^ ^15 Exabyte (EB) 2^ ^18 Zetabyte (ZB) 2^ ^21 Yottabyte (YB) 2^ ^24
6
Binary Encodings Everything in memory is “encoded” in binary, i.e., as a sequence of bits. “A” => 45 => “DOG” => Generally, the encoding of an object is unique among all similar objects, e.g., the encoding of “A” is different from the encoding of “B.” How many binary sequences are there on n bits? How many bits are needed to uniquely encode k items?
7
Main Memory Organization
A list of locations, each containing one byte of data. Each location has an associated “number,” which is commonly referred to as its’ address. Is said to be byte addressable. Also called Random Access Memory (RAM). The number of bytes per data item may vary from one item to another, and from one computer system to another. Integer => 4 bytes (1 word) Character => 1 or 2 bytes
8
Running (Executing) a Program
A (computer) program is a set of instructions for a computer to follow, or rather, execute. The term application is sometimes used to informally refer to a computer program (we will use the term more formally later). Program Computer Data (input for the program) Output
9
Many Types of Programs System Software - Part of the computers “infrastructure,” and necessary for the system to operate: Operating Systems - DOS, Microsoft Windows, MacOS, Linux, UNIX, etc. Database Systems – Oracle, IBM DB2, SQL Server, Access Networking Software Web Servers Application Servers User Applications - Not required for the system to operate: Games Office Applications – Word, Powerpoint, Excel Web Browsers Text Editors – textedit, vi, emacs, notepad
10
Various Types of User Interfaces
Graphical User Interface (GUI) Windows, menus, buttons, sliders, etc. MacOS, Windows Sometimes also called “event-driven” interfaces First developed by Xerox Corporation Command-Line: User types in commands one line at a time DOS (Start -> run -> cmd) Unix xterm Application Program Interface (API) Allows one program to communication, interact or “interface” with another, or with some external, physical device. ODBC, JDBC, Swing, AWT
11
Programming Language Hierarchy
Programs are written, or coded, in a programming language. There are many different types of programming languages. Machine Language Assembly Language High-Level Language
12
High-Level Languages High-Level Language (HLL):
Java, C, C++, C#, COBOL, FORTRAN, BASIC, Lisp, Ada, etc. closest to natural language words, numbers, and math symbols multi-line statements/commands relatively easy for people to read (it’s for people) not directly understood by hardware “portable” (hardware independent) A program in a HLL is frequently referred to as: a source program source code source file source
13
High-Level Language Example (Java)
public class SimpleProgram { public static void main(String[] args) System.out.println(“Hello out there.”); System.out.println(“I will add two numbers for you.”); int x; double d; x = 3752; d = ; System.out.println(“The sum of ” + x + “ and ” + d + “ is:”); System.out.println(x + d); }
14
Machine Languages Machine Language (lowest level):
just 0s and 1s single-line commands very difficult for humans to read directly understood by hardware not portable (hardware dependent) A program in machine language is frequently referred to as: an object program object code executable program executable code executable
15
Machine Language Example
000000 000001 000010 000110 100000 100011 000011 001000 000100 :
16
Assembly Languages Assembly Language:
a more readable version of machine language (also for people) words, abbreviations, letters and numbers replace 0s and 1s single-line statements/commands easily translated to machine executable code like machine code, not portable (hardware dependent) So, if we already have HLLs for people, why do we need assembly language? compilation results in a loss of meaning…sort of control over the resulting machine code
17
Assembly Language Example
PUSH DX MOV AH 08 INT 21 CMP AL 30 JB 0203 CMP AL 46 JA 0203 CMP AL 39 JA 021B MOV AH 02 MOV DL AL SUB AL 30 POP DX RET CMP AL 41 SUB AL 37
18
Getting from Source to Machine Code
Translating a program in a high-level language to machine code is called compiling. A program that compiles programs is called a compiler. A program that translates an assembly language program into machine code is called an assembler. Compilers and assemblers need to know the specific target hardware. There is, however, one additional type of translation called interpreting…
19
Compilers vs. Assemblers vs. Interpreters
Compilers and Assemblers: translation is a separate user step from execution entire source program is translated before execution sometimes said to be “off-line,” i.e. not at run time Interpreters: (another way to translate source to object code) translation is not a separate user step from execution translation and execution occur “line at a time” sometimes said to be “on-line,” i.e. at run time The difference between compiling (or assembling) and interpreting a computer program, is analogous to the difference between translating a book, and interpreting a speaker.
20
Java Program Translation
Executing a java program involves both compilation and interpretation. Java Program Translation & Execution: Step #1: A java program is compiled; this produces a program in byte code. Similar to assembly code, but hardware independent. Step #2: An interpreter, called the Java Virtual Machine (JVM) translates the byte code program to hardware-specific machine code, and executes it. Execution is done in an interpretive manner Question: Why not compile directly to machine code, rather than byte code? Answer: To make a long story short, portability over the internet.
21
Java Program Translation Including Linker
Oh, and, one other part of the translation process is linking… Java Program Previously Compiled Helper Programs Java Compiler Byte-Code Program Byte-Code Interpreter Machine-Language Instructions Class Loader (i.e., Linker) Computer Execution of Machine-Language Instructions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.