ICT - Notes - intro to computer programing, Lecture notes of Information and Communications Technology (ICT)

Outline of Topics Hardware/Software interface Layers of the Machine Kinds of Software Computer Languages Syntax, Semantics, Grammars What happens to your program? The compilation, Linking, Execution Program errors Compilation vs. Interpretation etc.

Typology: Lecture notes

2021/2022

Available from 12/04/2022

razaroghani
razaroghani 🇵🇰

4.5

(4)

151 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Computer
Programming
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download ICT - Notes - intro to computer programing and more Lecture notes Information and Communications Technology (ICT) in PDF only on Docsity!

Introduction to Computer

Programming

Outline of Topics

  • (^) Hardware/Software interface
    • (^) Layers of the Machine
    • (^) Kinds of Software
  • (^) Computer Languages
  • (^) Syntax, Semantics, Grammars
  • (^) What happens to your program?
    • (^) Compilation, Linking, Execution
    • (^) Program errors
  • (^) Compilation vs. Interpretation etc.

A Layered View of the Computer

Machine with all its hardware System Software

Compilers, Interpreters,Preprocessors,

etc.

Operating System, Device Drivers

Application Programs

Word-Processors, Spreadsheets,

Database Software, IDEs,

etc…

Operating System (OS)

 Provides several essential services:

  • (^) Loading & running application programs
  • (^) Allocating memory & processor time
  • (^) Providing input & output facilities
  • (^) Managing files of information

Computer Languages

  • (^) Machine Language
    • (^) Uses binary code
    • (^) Machine-dependent
    • (^) Not portable
  • (^) Assembly Language
    • (^) Uses mnemonics
    • (^) Machine-dependent
    • (^) Not usually portable
  • (^) High-Level Language (HLL)
    • (^) Uses English-like language
    • (^) Machine independent
    • (^) Portable (but must be compiled for different platforms)
    • (^) Examples: Pascal, C, C++, Java, Fortran,...

Machine Language

  • (^) The representation of a computer program which is actually read and understood by the computer. - (^) A program in machine code consists of a sequence of machine instructions.
  • (^) Instructions:
    • (^) Machine instructions are in binary code
    • (^) Instructions specify operations and memory cells involved in the operation Example: Operation^ Address 0010 0000 0000 0100 0100 0000 0000 0101 0011 0000 0000 0110

High-level language

  • (^) A programming language which use statements consisting of English-like keywords such as "FOR", "PRINT" or “IF“, ... etc.
  • (^) Each statement corresponds to several machine language instructions (one-to-many correspondence).
  • (^) Much easier to program than in assembly language.
  • (^) Data are referenced using descriptive names
  • (^) Operations can be described using familiar symbols
  • Example: Cost := Price + Tax

Syntax & Semantics

  • (^) Syntax:
    • (^) The structure of strings in some language. A language's syntax is described by a grammar.
    • (^) Examples:
      • (^) Binary number <binary_number> = | <binary_number> = 0 | 1
      • (^) Identifier = { | } = a | b |... | z <digit = 0 | 1 |... | 9
  • (^) Semantics:
    • (^) The meaning of the language

Compilers & Programs

• Compiler

  • (^) A program that converts another program from

some source language (or high-level

programming language / HLL) to machine

language (object code).

  • (^) Some compilers output assembly language

which is then converted to machine language by

a separate assembler.

Compilation into Assembly L

Compiler Assembler Source Program Assembly Language Assembly Language Machine Language

Compilers & Programs

• Object program

  • (^) Output from the compiler
  • (^) Equivalent machine language translation of the

source program

  • (^) Files usually have extension ‘.obj’

• Executable program

  • (^) Output from linker/loader
  • (^) Machine language program linked with necessary

libraries & other files

  • (^) Files usually have extension ‘.exe’

What is a Linker?

  • (^) A program that pulls other programs together so

that they can run.

  • (^) Most programs are very large and consist of

several modules.

  • (^) Even small programs use existing code provided

by the programming environment called libraries.

  • (^) The linker pulls everything together, makes sure

that references to other parts of the program

(code) are resolved.

Program Execution

• Steps taken by the CPU to run a program

(instructions are in machine language):

1. Fetch an instruction

2. Decode (interpret) the instruction

3. Retrieve data, if needed

4. Execute (perform) actual processing

5. Store the results, if needed

Program Errors

  • (^) Syntax Errors:
    • (^) Errors in grammar of the language
  • (^) Runtime error:
    • (^) When there are no syntax errors, but the program can’t complete execution - (^) Divide by zero - (^) Invalid input data
  • (^) Logical errors:
    • (^) The program completes execution, but delivers incorrect results
    • (^) Incorrect usage of parentheses