introduction to programming

18
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Hardware, Software, and Number Systems

Upload: mckenzie-norton

Post on 03-Jan-2016

24 views

Category:

Documents


0 download

DESCRIPTION

Introduction to Programming. Hardware, Software, and Number Systems. David Goldschmidt, Ph.D. Computer Science The College of Saint Rose. wireless router. hard drive. system unit. power supply. motherboard (with CPU). video card. processor cooling fan. sound card. memory cards. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to Programming

Introduction to Programming

David Goldschmidt, Ph.D.Computer Science

The College of Saint Rose

Hardware, Software, andNumber Systems

Page 2: Introduction to Programming

Hardwarewireless router

system unit

power supply

motherboard (with CPU)

video card

memory cards

processor cooling fan

sound card

hard drive

Page 3: Introduction to Programming

Cool Hardware Tablet PCs combine laptop and PDA

features

Page 4: Introduction to Programming

Cool Hardware Docking stations…

Page 5: Introduction to Programming

Operating Systems System Software

Computer programs that directlycontrol the operations of thecomputer and its devices

Operating System Coordinates and orchestrates all activities

of the hardware devices in a computer Provides a Graphical User Interface (GUI )

forusers to interact with the computer

Page 6: Introduction to Programming

Operating Systems Microsoft Windows

Windows 2000, Windows XP,Windows XP Tablet PC,Windows Vista, Windows 7

Macintosh Mac OS v9.1, Mac OS X

Others UNIX, Linux, etc.

Page 7: Introduction to Programming

Hardware (a Closer Look)

Page 8: Introduction to Programming

Central Processing Unit (CPU)

ArithmeticLogicUnit

ControlUnit

CPU

Instruction (input) Result (output)

e.g. addition, subtraction, logical AND, OR, NOT

executes machine

language programs

Memory

Page 9: Introduction to Programming

Memory

A section of memory is called a byte.

A section of two or four bytes is often called a word.

Main memory can be visualized as a column or row of cells.

0x0000x001

0x0030x002

0x0040x0050x0060x007

A byte is made up of 8 bits.10101010

Page 10: Introduction to Programming

Low-Level Languages

000101000011001010000100010010010101010101010010

Machine language program(executable file)

LDA #47STA $570DEXJSR $817CPX #0BNE #14

Assembly language program

Translationprogram

(Assembler)

Page 11: Introduction to Programming

Compiling a C/C++ Program#include <iostream>

int main(){ float x; cout << “ ...

C/C++ program

C/C++Compiler

000101000011001010000100010010010101010101010010

Machine language program(object “.obj” file)

000101000011001010000100010010010101010101010010

Precompiled Libraries(e.g. iostream)

C/C++Linker

000101000011001010000100010010010101010101010010

Machine language program(executable “.exe” file)

Page 12: Introduction to Programming

Fetch-Decode-Execute Cycle

Fetch

The CPU’s control unit fetches, from main memory,the next instruction in the sequence of program instructions.

Decode

The instruction is encoded in the form of a number. The control unit decodes the instruction and generates an electronic signal.

ExecuteThe signal is routed to the appropriate component of the computer (such as the ALU, a disk drive, or some other device). The signal causes the component to perform an operation.

The CPU performs the fetch-decode-execute cycle to “run” program instructions

Page 13: Introduction to Programming

Java Program Development

Text editor Source code(.java)

Saves Java statements

Java compiler

Is read by

Byte code(.class)

Produces

JavaVirtual

Machine

Is interpreted by

ProgramExecution

Results in

Page 14: Introduction to Programming

Compiling a Java Program

public class ex01{ double x; int y;

...

Java program

JavaCompiler

000101000011001010000100010010010101010101010010

Java byte code(“.class” file)

Page 15: Introduction to Programming

Executing a Java Program

000101000011001010000100010010010101010101010010

Java byte code(“.class” file)

000101000011001010000100010010010101010101010010

Precompiled libraries(i.e. byte code)

JavaVirtual

Machine

Page 16: Introduction to Programming

Numbering Systems

We count using our fingers.... Base 10:

Computers count using binary digits or bits.... Base 2:

000001002003004005006007008009010011012013

000000000000000100000010000000110000010000000101000001100000011100001000

Page 17: Introduction to Programming

Base Conversion

A byte is a grouping of 8 bits

Convert an unsigned binary number (11011001) to decimal (base 10):

What about negative integers?

128

10011011

1248163264128base 10

value

16+ 8+ 1+ = 21764+

unsigned byte ranges

from 0 to 255

Page 18: Introduction to Programming

Two’s Complement

Conversion from binary to decimal is identical, except the leftmost bit always has a negative weight-128 64 32 16 8 4 2 1

1 1 0 1 1 0 0 1

-128 64 16 8 1

base 10

value

+ + + = -39+

two’s complement byteranges from -128 to 127