0% found this document useful (0 votes)
4 views

Computer Programming Languages19-09-2007

The document provides an overview of computer programming languages, categorizing them into machine language, assembly language, and high-level languages, each with distinct characteristics and examples. It discusses the evolution of programming languages, the differences between conventional C and Embedded C, and the roles of compilers and cross-compilers in software development. Additionally, it highlights the specific features and constraints of programming in Embedded C compared to traditional programming environments.

Uploaded by

musewardinesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Computer Programming Languages19-09-2007

The document provides an overview of computer programming languages, categorizing them into machine language, assembly language, and high-level languages, each with distinct characteristics and examples. It discusses the evolution of programming languages, the differences between conventional C and Embedded C, and the roles of compilers and cross-compilers in software development. Additionally, it highlights the specific features and constraints of programming in Embedded C compared to traditional programming environments.

Uploaded by

musewardinesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Contents

 Today's Topic: Computer Programming Languages

 We will learn
1. Computer Programming Languages.
2. Non-computational languages
3. Machine language
 Example

4. Assembly language
 Example
5. High level language
 Examples.
Computer
Programming
Languages
Computer Programming
Languages:
 A programming language is an artificial language that
can be used to control the behavior of a machine,
particularly a computer

 Programming languages, like human languages, are


defined through the use of syntactic and semantic rules,
to determine structure and meaning respectively.
Computer Programming
Languages (Contd…):

 Programming languages are used to facilitate


communication about the task of organizing and
manipulating information, and to express algorithms
precisely.

 For 50 years, computer programmers have been writing


code. New technologies continue to emerge, develop,
and mature at a rapid pace. Now there are more than
2,500 documented programming languages!
Non-computational
languages:
 Non-computational languages, such as markup
languages like HTML or formal grammars like BNF, are
usually not considered programming languages.

 Often a programming language is embedded in the non-


computational language.
Machine language:
• It is the lowest-level programming language.

• Machinelanguages are the only languages


understood by computers.
Machine language:

 While easily understood by computers, machine


languages are almost impossible for humans to use
because they consist entirely of numbers.

For example, an x86/IA-32 processor can execute the


following binary instruction as expressed in machine
language:

Binary: 10110000 01100001 (Hexadecimal: 0xb061)


Assembly Level Language:
 An assembly language is a low-level language for
programming computers.

 The word "low" does not imply that the language is


inferior to high-level programming languages but rather
refers to the small or nonexistent amount of abstraction
between the language and machine language, because
of this, low-level languages are sometimes described as
being "close to the hardware."

 It implements a symbolic representation of the numeric


machine codes and other constants needed to program
a particular CPU architecture.
Assembly Level
Language (contd…):
 A utility program called an assembler, is used to translate assembly
language statements into the target computer's machine code.
 The assembler performs a more or less isomorphic translation (a one-to-one
mapping) from mnemonic statements into machine instructions and data.
Example: Assembly language representation is easier to remember
(more mnemonic)

mov al, 061h

This instruction means:


Move the hexadecimal value 61 (97 decimal) into the processor register
named "al".

The mnemonic "mov" is an operation code or opcode, A comma-separated


list of arguments or parameters follows the opcode;
Example (Adds 2 numbers):

name "add"
mov al, 5 ; bin=00000101b
mov bl, 10 ; hex=0ah or bin=00001010b
add bl, al ; 5 + 10 = 15 (decimal) or
hex=0fh or

bin=00001111b
High-level language:
 High-level languages are relatively easy to learn
because the instructions bear a close resemblance to
everyday language, and because the programmer does
not require a detailed knowledge of the internal workings
of the computer.

 Each instruction in a high-level language is equivalent to


several machine-code instructions, therefore it is more
compact than equivalent low-level programs.

 High-level languages are used to solve problems and


are often described as problem-oriented languages
High-level language
(Contd…):
Examples of HLL:
 BASIC was designed to be easily learnt by first-time
programmers;
 COBOL is used to write programs solving business problems;
 FORTRAN is used for programs solving scientific and
mathematical problems.
 With the increasing popularity of windows-based systems, the
next generation of programming languages was designed to
facilitate the development of GUI interfaces;
for example, Visual Basic wraps the BASIC language in a
graphical programming environment.
 Support for object-oriented programming has also become
more common, for example in C++ and Java.
Example (C program to add 2
numbers):
#include<stdio.h> //header files
Void main()
{
int a, b, c; // declaration of 3 variables
printf(“Enter two numbers:\n”);
Scanf(“%d”, &a); // read 1st number
Scanf(“%d”, &b); // read 2nd number
c=a+b; // compute the sum
printf(“Sum of 2 numbers is %d”, c); //print sum
}
High level language to machine language
conversion
PROGRAMMING IN
EMBEDDED C
 Whenever the conventional ‘C’ Language and its extensions are used for
 programming embedded systems, it is referred as ‘Embedded C’
programming.
 Programming in ‘Embedded C’ is quite different from conventional Desktop
application development using ‘C’ language for a particular OS platform.
 Desktop computers contain working memory in the range of Giga bytes and
storage memory in the range of Giga/Tera bytes. For a desktop application
developer, the resources available are surplus in quantity and the developer
is not restricted interms of the memory usage.
 This is not the case for embedded application developers. Almost all
embedded systems are limited in both storage and working memory
resources.
‘C’ v/s. ‘Embedded C’
 ‘C’ is a well structured, well defined and standardized general
purpose programming language with extensive bit manipulation
support. ‘C’ offers a combination of the features of high level
language and assembly and helps in hardware access
programming (system level programming) as well as business
package developments(Application developments like pay roll
systems, banking applications, etc).
 The conventional ‘C’ language follows ANSI standard and it
incorporates various library files for different operating systems.
 A platform(operating system) specific application, known as,
compiler is used for the conversion of programs written in‘C’ to the
target processor (on which the OS is running) specific binary files.
 Hence it is a platform specific development.
‘C’ v/s. ‘Embedded C’
 Embedded ‘C’ can be considered as a subset of conventional ‘C’
language. Embedded ‘C’ supports all ‘C’ instructions and
incorporates a few target processor specific functions/instructions.
 It should be noted that the standard ANSI ‘C’ library implementation
is always tailored to the target processor/controller library files in
Embedded ‘C’.
 The implementation of target processor/controller specific
functions/instructions depends upon the processor/controller as well
as the supported cross-compiler for the particular Embedded‘C’
language.
 A software program called ‘Cross-compiler’ is used for the
conversion of programs written in Embedded ‘C’ to target
processor/controller specific instructions (machine language).
Compiler vs. Cross-Compiler
 Compiler is a software tool that converts a source code written in a
high level language on top of a particular operating system running
on a specific target processor architecture (e.g. Intel x86/Pentium).
 Here the operating system, the compiler program and the
application making use of the source code run on the same target
processor.
 The source code is converted to the target processor specific
machine instructions.
 The development is platform specific (OS as well as target
processor on which the OS is running).
 Compilers are generally termed as ‘Native Compilers’. A native
compiler generates machine code for the same machine
(processor) on which it is running.
Compiler vs. Cross-Compiler
 Cross-compilers are the software tools used in cross-platform
development applications.
 In cross-platform development, the compiler running on a particular
target processor/OS converts the source code to machine code for
a target processor whose architecture and instruction set is different
from the processor on which the compiler is running or for an
operating system which is different from the current development
environment OS.
 Embedded system development is a typical example for cross-
platform development where embedded firmware is developed on a
machine with Intel/AMD or any other target processors and the
same is converted into machine code for any other target processor
architecture (e.g. 8051, PIC, ARM etc).
Using ‘C’ in ‘Embedded C’
 Keywords and Identifiers
 Data Types
 Storage Class
 Arithmetic Operations
 Logical Operations
 Relational Operations
 Branching Instructions
 Looping Instructions
 Arrays and Pointers
 Characters and Strings
 Input & Output operations
 String Concatenation
 String Comparison
 Functions
 Lib-Fun

 User Defined Fun.

 Function Pointers

 Arrays of Function Pointers

 Structures and Unions

 Pre-processors and Macros


 Constant Declarations in Embedded ‘C’
 Bit Manipultion Operations
 Dynamic Memory Allocation

You might also like