Monday, November 28, 2011

Function of Loader

A loader is a system program, which takes the object code of a program as input and prepares it for execution.

Loader Function : The loader performs the following functions :

1.)Allocation - The loader determines and allocates the required memory space for the program to execute properly.

2.)Linking -- The loader analyses and resolve the symbolic references made in the object modules.

3.)Relocation - The loader maps and relocates the address references to correspond to the newly allocated memory space during execution.

4.)Loading - The loader actually loads the machine code corresponding to the object modules into the allocated memory space and makes the program ready to execute.

Linking vs. loading

Linking vs. loading:- 1.)Program loading: Copy a program from secondary storage into main memory so it's ready to run.
Loading just involves copying the data from disk to memory, or it involves allocating storage, setting protection bits, or arranging for virtual memory to map virtual addresses to disk pages.
2.) Relocation:-Relocation is the process of assigning load addresses to the various parts of the program, adjusting the code and data in the program to reflect the assigned addresses.
If a program is created from multiple subprograms, all the subprograms have to be loaded at non-overlapping addresses.
Linker creates a program from multiple subprograms, and create one linked output program that starts at zero, with the various subprograms relocated to locations within the big program.
#)Linker is a program that takes one or more objects generated by a compiler and combines them into a single executable program.

#)Loader is the part of an operating system that is responsible for loading programs from executables (i.e., executable files) into memory, preparing them for execution and then executing them.

Linker

Linker :-Link editors are commonly known as linkers. a computer program that takes one or more objects generated by a compiler and combines them into a single executable program.or, a linker is a program that combines object modules to form an executable program.
Many programming languages allow to write different pieces of code, called modules, separately. This simplifies the programming task because we can break a large program into small, more manageable pieces. So,we need to put all the modules together. This is done by linker.A linker also replaces symbolic addresses with real addresses.

Header file

header file:- the c standard library contains files containing the function .these files are known as header file .Heaedr file provide function prototype ,definition for library function .Data tpe and constants used with the library function are also defined on them .
Some of these are :-
1.stdio.h:-this header file define type and macro needed for the standard i/o package .this defin i/o predefined stream e.g. stdin,stdout ,stderr.
2.string.h:- this header file declare several string manipulation and memory manipulation routine .the function are-
memccpy,stdcp,strtok.
3.math.h:- this header file declar prototype for the math function and math handlers .The routine in math.h file perform mathematical calculation and conversion.
4. stdlib.h:-this header file file declare several commonly used routine like conversion routine ,search routine .

Macro definition or Expansion

• Macro definition consists of
i) macro prototype ii) one of more model iii) macro preprocessor
• Macro definition is in between a macro header statement and a macro e statement.
• Syntax of macro prototype statement < macro name> [ < formal parameter spec> [; ... ]] where < macro name> = It is in the mnemonic field of an assembly statement < formal parameter spec > is in the following form < parameter name > [ < parameter kind > ]
• Syntax of the macro call is < macro name> [ < actual parameter spec> [; ... ]]

Macro Expansion:-
• Macro call leads to macro expansion.
• Macro call statement is replaced by a sequence of assembly statement in macro expansion.
• Two key notions are used in macro expansion
a)Expansion time control flow
b)Lexical substitution
• Algorithm for macro expansion

Difference in External or Internal commands of DOS

The internal commands reside in COMMAND.COM, which loads into memory when the computer system is started; these commands do not reside on disk. It has 1 of the major file command.com that loads when you boot system in dos.dir, date, etc are internal command i.e. part of command.com and is already loaded in memory and can be executed any time when you are using dos system.
The external commands are files that do reside on disk and have an extension of .COM, .EXE, or .BAT. format, fdisk are external command. They are in form of separate files (format.exe, fdisk.com etc) and if you don't have this files, you cannot execute this commands.
Both command types are executed from the MS-DOS prompt.

Difference between one pass and two pass assemblers

The difference between one pass and two pass assemblers are:-
A one pass assembler passes over the source file exactly once, in the same pass collecting the labels, resolving future references and doing the actual assembly. The difficult part is to resolve future label references and assemble code in one pass.
A two pass assembler does two passes over the source file ( the second pass can be over a file generated in the first pass ). In the first pass all it does is looks for label definitions and introduces them in the symbol table. In the second pass, after the symbol table is complete, it does the actual assembly by translating the operations and so on.

Device driver

Device driver:-A device driver is a program that controls a particular type of device that is attached to the computer. Device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device.
A driver typically communicates with the device through the computer bus or communications subsystem to which the hardware connects.There are device drivers for printers, displays, CD-ROM readers, diskette drives, and so on.
A device driver essentially converts the more general input/output instructions of the operating system to messages that the device type can understand.
For example, all printers come accompanied with drivers to install that tell the operating system exactly how to print information on the page.

Debugger

Debugger:-A debugger or debugging tool is a computer program that is used to test and debug other programs .
In writing the program certain errors ,called bugs ,can occur in the program.This cause to not function as the original output .Sometimes these errors are easy to fix, while some bugs are very difficult to trace.So we use a program called debugger.
Debuggers help software developers find and eliminate bugs while they are writing programs. A debugger tells the programmer what types of errors it finds and often marks the exact lines of code where the bugs are found.
Debuggers also allow programmers to run a program step by step so that they can determine exactly when and why a program error occur.
Function performed by debugger:
1.)What statement or expression was the program executing at the time of a fatal error?
2.)If a fatal error occurs while executing a function, what line of the program contains the call to
that function?
3.)What are the values of program variables (including parameters) at a particular point during
execution of the program?
4.)What is the result of evaluating a particular expression at some point in the program?
5.)What is the sequence of statements actually executed in a program?

CPU parts

The CPU has two main parts.
1. The Control Unit.
2. Arithmetic Logic Unit.
The parts of the CPU are usually connected by an electronic component referred to as a Bus, which acts as an electronic highway between them. The CPU has special purpose storage devices called registers, helps in storing data and instructions.
1. Control Unit: It is responsible for directing and coordinating most of the computer system activities. It does not execute instructions by itself. It tells other parts of the computer system what to do. It determines the movement of electronic signals between the main memory and arithmetic logic unit as well as the control signals between the CPU and input/output devices.
2. Arithmetic logic Unit: ALU performs all the arithmetic and logical functions i.e. addition, subtraction, multiplication, division and certain comparisons. These comparisons include greater than, less than, equals to etc. The ALU controls the speed of calculations.
3. Registers: It is a special temporary storage location within the CPU. Registers quickly, accept, store and transfer data and instructions that are being used immediately (main memory hold data that will be used shortly, secondary storage holds data that will be used later). To execute an instruction, the control unit of the CPU retrieves it from main memory and places it onto a register. The typical operations that take place in the processing of instruction are part of the instruction cycle or execution cycle. The instruction cycle refers to the retrieval of the instruction from main memory and its subsequence at decoding. The process of alerting the circuits in CPU to perform the specified operation. The time it takes to go through the instruction cycle is referred to as I-time.

4. Bus: The term Bus refers to an electrical pathway through which bits are transmitted between the various computer components. Depending on the design of the system, several types of buses may be present. The most important one is the data bus, which carries the data through out the central processing unit. The wider the data bus, the more data it can carry at one time and thus the greater the processing speed of the computer.

C compiler preprocessors

C compiler preprocessors:-Preprocessor commands are executed before the compiler compiles the source code.
#include preprocessor directive
• causes a copy of a specified file to be
included in place of the directive
• Two versions:
– #include “filename”
preprocessor searches in the same directory as
the file being compiled for the file to be
included
– #include <filename>
used for standard library header files, the
search normally performed through predesignated
directories
2
7
#define preprocessor directive
• creates symbolic constants and
macros.
ex- #define PI 3.14159
identifier replacement-text
replaces all subsequent occurrences of the
symbolic constant PI with the numeric
constant 3.14159.

#include :-insert a source file.
#define :-Define a preprocessor constant.
#if :-Branch based on an expression.
#ifdef :-Branch if preprocessor constant has been defined?
#ifndef :-Branch is a preprocessor constant has NOT been defined.
#line :-Specify the number of the next source line.
#undef :-Remove a preprocessor constant.
#pragma:-Perform an implementation dependent action???
#else :-Executed if #if #ifdef or #ifndef fails.
#error :-Write an error message.
#elif :-Executed when an #if fails.
#endif :-Close #if #ifdef or #ifndef

Components of computer

Components of computer are :-
1.)Input Unit:
Computers need to receive data and instruction in order to solve any problem. Therefore we need to input the data and instructions into the computers. The input unit consists of one or more input devices. Keyboard is the one of the most commonly used input device. Other commonly used input devices are the mouse, floppy disk drive, magnetic tape, etc. All the input devices perform the following functions.
a.)Accept the data and instructions from the outside world.
b.)Convert it to a form that the computer can understand.
c.)Supply the converted data to the computer system for further processing.

2.)Storage Unit:
The storage unit of the computer holds data and instructions that are entered through the input unit, before they are processed.
1. Primary Storage: Stores and provides very fast. This memory is generally used to hold the program being currently executed in the computer, the data being received from the input unit, the intermediate and final results of the program. The primary memory is temporary in nature. The data is lost, when the computer is switched off. In order to store the data permanently, the data has to be transferred to the secondary memory.
2. Secondary Storage:-The programs that we run on the computer are first transferred to the primary memory before it is actually run. Whenever the results are saved, again they get stored in the secondary memory. The secondary memory is slower and cheaper than the primary memory. Some of the commonly used secondary memory devices are Hard disk, CD, etc.
3.)Output Unit:
The output unit of a computer provides the information and results of a computation .
Printers, Visual Display Unit (VDU) ,monitor are the o/p unit.
4.)Arithmetic Logical Unit:-All calculations are performed in the Arithmetic Logic Unit (ALU) of the computer. It also does comparison and takes decision. The ALU can perform basic operations such as addition, subtraction, multiplication, division, etc and does logic operations viz, >, <, =, ‘etc. Whenever calculations are required, the control unit transfers the data from storage unit to ALU once the computations are done, the results are transferred to the storage unit by the control unit and then it is send to the output unit for displaying results.
4.)Control Unit:
It controls all other units in the computer. The control unit instructs the input unit, where to store the data after receiving it from the user. It controls the flow of data and instructions from the storage unit to ALU. It also controls the flow of results from the ALU to the storage unit. The control unit is generally referred as the central nervous system of the computer that control and synchronizes its working.
5.)CPU (Central Processing Unit):-The processor or CPU controls the computer.
This makes your computer run. it executes instructions and transports data round the computer system.
The control unit and ALU of the computer are together known as the Central Processing Unit (CPU). The CPU is like brain performs the following functions:
• It performs all calculations.
• It takes all decisions.
• It controls all units of the computer.

Task of compiler

Software that converts a set of high-level language statements into a lower-level representation.
or, A compiler is a computer program that transforms human readable source code of another computer program into the machine readable code that a CPU can execute.
A compiler usually generates assembly language first and then translates the assembly language into machine language. A utility known as a "linker" then combines all required machine language modules into an executable program that can run in the computer.

The act of transforming source code into machine code is called "compilation".

Task of compiler:-The most important task is to translate the code into machine code. The computer itself cannot understand C++ or Java or any other high level language. The task of compilers and interpreters is to translate the programming language into a language the computer understands and can execute.

Differences between .cmd and .bat

Differences between .cmd and .bat execution in the Windows NT family

The only known difference between .cmd and .bat file execution is that in a .cmd file the ERRORLEVEL variable changes even on a successful command that is affected by Command Extensions (when Command Extensions are enabled), whereas in .bat files the ERRORLEVEL variable changes only upon errors.

Bitwise operation

A bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits.
NOT:-The bitwise NOT, or complement, is a unary operation that performs logical negation on each bit, forming the ones' complement of the given binary value.
NOT 0111 (decimal 7)
= 1000 (decimal 8)
The ~ (tilde) operator performs a bitwise complement on its single integer operand.
OR:-A bitwise OR takes two bit patterns of equal length, and produces another one of the same length by matching up corresponding bits .
0101 (decimal 5)
OR 0011 (decimal 3)
= 0111 (decimal 7)
The | (vertical bar) operator performs a bitwise OR on two integers.
The bitwise OR may be used in situations where a set of bits are used as flags;

XOR:-A bitwise exclusive or takes two bit patterns of equal length and performs the logical XOR operation on each pair of corresponding bits. The result in each position is 1 if the two bits are different, and 0 if they are the same. For example:
0101 (decimal 5)
XOR 0011 (decimal 3)
= 0110 (decimal 6)
The ^ (caret) operator performs a bitwise exclusive-OR on two integers.
0 1 0 1 0 1 1 0
^ 0 0 1 1 0 0 1 0
---------------
0 1 1 0 0 1 0 0
Bit shift:-
The << operator shifts its first operand left by a number of bits given by its second operand, filling in new 0 bits at the right.
The >> operator shifts its first operand right. If the first operand is unsigned, >> fills in 0 bits from the left, but if the first operand is signed, >> might fill in 1 bits if the high-order bit was already 1.
For example, 0x56 << 2 is 0x158:
0 1 0 1 0 1 1 0 << 2-------------------
0 1 0 1 0 1 1 0 0 0
And 0x56 >> 1 is 0x2b:
0 1 0 1 0 1 1 0 >> 1
---------------
0 1 0 1 0 1 1
AND:-A bitwise AND takes two binary representations of equal length and performs the logical AND operation on each pair of corresponding bits.
the result is 1 if the first bit is 1 AND the second bit is 1. Otherwise, the result is 0. For example:
0101 (decimal 5)
AND 0011 (decimal 3)
= 0001 (decimal 1)
The & operator performs a bitwise AND on two integers.
0 1 0 1 0 1 1 0
& 0 0 1 1 0 0 1 0 --------------
0 0 0 1 0 0 1 0

Bit shifts or bitwise operations

Bit shifts:-The bit shifts are sometimes considered bitwise operations, since they operate on the binary representation of an integer instead of its numerical value;
The bit shifts operators are used to perform bitwise operations on the binary representation of an integer instead of its numerical value.

Sign Bit:-A sign bit is found in the left most position of the number and is know as most significant bit (MSB) which indicates the status of a number i.e. the number is positive or negative. If the value of the sign bit is 0 then the number is positive; otherwise the number is negative, if the value of the sign bit is 1.
I. Signed Left Shift ("<<") :-The signed left shift ("<<") operator shifts a bit (or bits) to the left by the distance specified in the right operand.
II. Signed Right Shift (">>") :-The signed right shift (">>") operator shifts a bit (or bits) to the right by the distance specified in the right operand and fills the left most bit by the sign bit.

III. Unsigned Right Shift (">>>"):-The unsigned right shift (">>>") operator behave like the signed right shift operator. i.e. it shifts a bit (or bits) to the right. But unlike ">>" operator, this operator always shifts zeros into the leftmost position by the distance specified in the right operand. So the result of applying the >>>operator is always positive.

For example, the expression "14>>>2"; shifts all bits of the number 14 to the right placing a zero to the left for each blank place Thus the value 1110 becomes 0011 or 3 in decimal.

Batch file

A batch file is a text file that contains a sequence of commands for a computer operating system. It's called a batch file because it batches (bundles or packages) into a single file a set of commands that would otherwise have to be presented to the system interactively from a keyboard one at a time. A batch file is usually created for command sequences for which a user has a repeated need. Commonly needed batch files are often delivered as part of an operating system.
a batch file is a text file containing a series of commands intended to be executed by the command interpreter.

In the Disk Operating System (DOS), a batch file has the file name extension ".BAT". (The best known DOS batch file is the AUTOEXEC.BAT file that initializes DOS when you start the system.) In UNIX-based operating systems, a batch file is called a shell script. In IBM's mainframe VM operating systems, it's called an EXEC.

Array and Pointer and Difference

*pointer of array:-All the variables can be manipulated in the memory by their addresses. CPU uses these addresses to fetch them, change them and save them. So, all variables have an address (not only those that you pointed to them). We can find out the address of a variable by (&) operator, in form of:
1.int* ptr=&intvar

array of pointer:-
An array is just a sequence of variables.

Differences:

1) A pointer is a place in memory that keeps address of another place inside, while an array is a single, preallocated chunk of contiguous elements (all of the same type), fixed in size and location.

2) Array like pointers can't be initialized at definition like arrays.
char car[3]={'a','b',66};
char* cpt=new char[3];

3) When we allocate memory for a pointer to use it as a dynamic array. The memory can be resized or freed later. But this is not the case for arrays.

For example:
char* pta=new char[12];
4.)Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them.Arrays use subscripted variables to access and manipulate data.Array variables can be equivalently written using pointer expression.

Advantages and Disadvantages

1.)Assembly language is a symbolic representation of a processor's native code.
2.)Assemble language is hardware particular and not as prone to errors in code that are for genric hardware.because it is written for a hardware platform.
3.)It is possible to write fast and efficient .
4.)It use a very small amount of memory.
5.)Requires fewer instructions to accomplish the same result.
6.)Easy to make insertions and deletions.
Disadvantages:
1.)Programs written in such languages cannot be executed on small sized computers.
2.)It takes lot of time to code or write the program, as it is more complex in nature.
3.)Lack of portability of program between computers of different makes.
4.)Maintenance of assembly language is notoriously difficult,.

assembler directive

An assembler directive is a message to the assembler that tells the assembler something it needs to know in order to carry out the assembly process; for example, an assemble directive tess the assembler where a program is to be located in memory.
<label> EQU <value> Equate
ORG <value> Origin
<label> DC <value> Define constant
<label> DS <value> Define storage
END <value> End of assembly language
In each case, the term <label> indicates a user-defined label (i.e., symbolic name) that must start in column 1 of the program, and <value> indicates a value that must be supplied by the programmer (this may be a number, or a symbolic name that has a value).
1.)Equate:-The EQU assembler directive simply equates a symbolic name to a numeric value.
2.)Origin:-The origin directive tells the assembler where to load instructions and data into memory.
3.)Define Constrant:-The define constant assembler directive allows you to put a data value in memory at the time that the program is first loaded.
4.)Define Storage:-The define storage directive is used to reserve one or more memory locations.
5.)END - END directive is placed after the last
statement of a program to tell the assembler that this is the end
of the program module. The assembler will ignore any
statement after an END directive.
6.)ENDP - End Procedure.
7.)ENDS - End Segment.
8.)GROUP - The GROUP directive is
used to group the logical segments.
9.)INCLUDE - This INCLUDE directive is
used to insert a block of source code from the named file
into the current source module.
10.)TYPE - TYPE operator instructs the assembler to
determine the type of a variable and determines the number of
bytes specified to that variable.
11.)PTR-used to assign a specific type of variable.
12.)EVEN-INSTRUCT to increment the location of the counter to the next even address.

Assembly language vs machine language

1.)Assembly language is more human-readable than machine language.
2.)statements in assembly language are written using short codes for the instruction and arguments, such as "MOV $12 SP", as opposed to machine language, where everything is written as numbers.
3.)assembler is used to translate the assembly language
4.)Assembly language can have comments and macros as well, to ease programming and understanding then machine language.
5.It is fast and efficient to write Assembly language then machine language.
6.)It use a very small amount of memory then m/c language.

Assembly language

Assembly language is is a low-level programming language ana symbolic representation of a processor's native code. Assembly languages are also known as symbolic languages as they use symbols to represent the arithmetic and logical operations. It uses mnemonics and symbolic operands .
This reduces coding time and the amount of information the programmer has to remember. They use assembler to convert the program in to machine language (object program).
A utility program called an assembler is used to translate assembly language statements into the target computer's machine code.

Sunday, November 27, 2011

Global Positioning System

The Global Positioning System (GPS) is a navigation and precise-positioning tool.Using the Global Positioning System the
following two values can be determined anywhere on Earth :
1. One’s exact location (longitude, latitude and height co-ordinates) accurate to within a range of 20 m to
approx. 1 mm.
2. The precise time (Universal Time Coordinated, UTC)

BASIC CONCEPT OF GPS RECEIVER AND ITS COMPONENTS
The main components of a GPS receiver are shown in Fig. 10. These are:
- Antenna with pre-amplifier
- RF section with signal identification and signal processing
- Micro-processor for receiver control, data sampling and data processing
- Precision oscillator
- Power supply
- User interface, command

1.)Antenna
Sensitive antenna of the GPS receiver detects the electromagnetic wave
signal transmitted by GPS satellites and converts the wave energy to electric
current] amplifies the signal strength and sends them to receiver electronics.
2.)RF Section with Signal Identification and Processing
The incoming GPS signals are down converted to a lower frequency in
the RS section and processed within one or more channels.
3.)Microprocessor
To control the operation of a GPS receiver, a microprocessor is essential
for acquiring the signals, processing of the signal and the decoding of the
broadcast message.
4.)Precision Oscillator
A reference frequency in the receiver is generated by the precision oscillator.
5.)Memory Capacity
For port processing purposes all data have to be stored on internal or
external memory devices.

*APPLICATIONS OF GPS:-
*Providing Geodetic control.
* Survey control for Photogrammetric control surveys and mapping.
* Finding out location of offshore drilling.
*Pipeline and Power line survey.
* Navigation of civilian ships and planes.
* Crustal movement studies.
* Geophysical positioning, mineral exploration and mining.
*Determination of a precise geoid using GPS data.
*Estimating gravity anomalies using GPS.
* Offshore positioning: shiping, offshore platforms, fishing boats etc.

Bit or Boud Rate

Bit rates :-measure of the number of data bits (that's 0's and 1's) transmitted in one second in a communication channel. A figure of 2400 bits per second means 2400 zeros or ones can be transmitted in one second, hence the abbreviation "bps".

Baud rate:-A baud rate, means the number of times a signal in a communications channel changes state or varies. For example, a 2400 baud rate means that the channel can change states up to 2400 times per second. The term "change state", means that it can change from 0 to 1 or from 1 to 0 up to X (in this case, 2400) times per second.