Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.

Similar presentations

Presentation on theme: "1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming."— Presentation transcript:

1 1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming Environment  Readings: Chapter 1 Section 1

2 2 Hardware Model  The physical machines that make up a computer installation: Secondary Storage Input Devices Output Devices CPU Main Memory

3 3 Hardware: CPU  Acronym for …  The “ brain ” of computer  Consists of a processing unit (the ALU), a control unit (the CU) and a set of registers (a few high- speed memory units for temporary use)  Fetch and execute instructions from the main memory until the computer is turned off ALU CU Register File CPU

4 4 Hardware: Main Memory  The place for storing data of all kinds  Bit (Binary Digit, smallest unit)  stores either 0 or 1  Byte - consists of 8 bits  Main memory  a list of bytes, each associated with an address  stores both the program and data  e.g. 64K bytes of memory: 0 1 2 65535............

5 5 Software Model  Software  A collection of programs for a specific task  e.g. operating system (OS), editor, compiler, game, database server  Operating System  Chief servant, managing tasks and resources  allocates the computer ’ s resources to the different tasks that the computer must accomplish  What are the most popular OS ’ s?  e.g. DOS, Windows, UNIX, Solaris, Linux, etc.

6 6 Editor C Compiler Pascal Compiler Games Web Browser System and Application Software Hardware-Software Hierarchy Operating System Hardware

7 7 Hardware-Software Hierarchy

8 8 Software: Program & Data  Program - a sequence of instructions specifying how the data is to be processed.  Data - input to the program, either supplied during runtime or pre-stored in the computer  Both program and pre-stored data are stored in the main memory  Originally, in secondary storage, e.g., CD or hard disk, before loaded into the main memory

9 9 Programming Languages (PL) Can You Understand This? Is This Better?

10 10 PL: Machine Languages  A CPU only understands its own machine language => portability problem  In Motorola 68000, the following 4 bytes is an instruction to move the value in register D3 to memory address 104.  In Intel 80486, the same sequence of bytes represents different instructions  Coding is tedious and error prone 192 49 104 0

11 11 PL: Assembly Languages  Use English-like abbreviations  e.g. the previous MC68000 machine instruction is written as: MOVE D3, 104  slightly easier for human to understand  need an assembler to translate into machine instructions  Different CPUs have different instruction sets e.g. MOVE D3, 104 is not a valid instruction in Intel 80486 because it doesn ’ t even have a register called D3 => portability problem

12 12 PL: High-level Languages  Close(r) to human language  One single statement accomplishes substantial tasks  Need a compiler/linker to translate into machine language  More portable - the same program (more or less) works for different machines  e.g. Fortran, COBOL, Pascal, Ada, Modula, C, C++, Lisp, Prolog, Java, Perl...

13 13 PL: Compiler & Linker  Compiler  translates a program in high- level language into an object program (or object code). The original program is called the source program/code.  Linker  combines the object code of a program with other pre- compiled object codes to generate an executable code which is in machine language linker compiler source code object code other object code executable code

14 14 The C Language  Developed by Dennis Ritchie in 1970 ’ s  Originally for writing system programs such as OS (e.g. UNIX) and compilers  Efficient and widely used in engineering applications  Small and easy to get started  easy to make undetected errors

15 15 C: Standardization & Libraries  ANSI/ISO Standard for C: 1990  C Standard Libraries  Contains pre-written functions  Greatly facilitates programming and performance  Generally provided by compiler vendors  Proprietary libraries provided by individual vendors

16 16 Software Engineering Start Problem definition Algorithm design Desktop testing Problem-solving phase Translating to C Testing Working program Implementation phase

17 17 SE: Development Process  Specify the task  Find an algorithm for its solution  Code the algorithm in a programming language  Prepare the source code (program) in a file, called source file  Test the code  Compile the source file to produce object code, stored in an object file  Link up the object code with any library module and load the loader to produce the final executable file  Run the executable file and debug any error

18 18 SE: Development Process  No complete set of rule! Split a BIG problem into few smaller problems Solve the smaller problems one by one Combine the solutions of smaller problems  Strategy –Top-down design –Stepwise refinement

19 19 Programming Environment Editor Disk Preprocessor Disk Compiler Disk Linker Disk

20 20 Programming Environment............ Loader CPU Disk Main Memory

21 21 Programming Errors  Syntax errors:  violation of the syntax  detected during compilation  Run-time errors:  compilation successful but errors detected during run- time, e.g. division by zero  Logic error:  compilation and execution do not produce machine detectable errors but the answer is wrong  may be due to wrong algorithm or wrong coding

22 22 Tips for A Good Programmer  Not only know how to write a program, but also know how to write a good program  Writing a program may be simple, but writing a program with unique and good programming styles is not simple

Download ppt "1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming."

Similar presentations

Ads by Google