Saturday, 2 June 2012

Introduction to PHP

PHP stands for Hypertext Preprocessor.
PHP is a server side scripting language which are executed by the server.
PHP is an easy language which supports many databases.
It is platform independent language and can be run on different platform.

The server installed on your PC should support and then you can make some PHP file and execute it.
Generally all the server support php if they doesn't just install php. It is free to use and available as an open source.

The basic syntax of a php code is

 Whatever written in this script tag is a php code.
A php file must have .php extension

Rest will be explained in the next article

Thursday, 31 May 2012

DAVV Indore CET 2012

Program linking algorithm

1.Program_linked_origin = <link origin> from linker command
2.For each object module
a.T_origin = translated origin of the object module.  OM_size = size of the object module.
c.Read the machine language program in work_area.
d.Read LINKTAB of the object module.
e.for each LINKTAB entry with type = public definition                    name=symbol                                                                      linked_address = translated_address + relocation_factor               Enter(name,linked_address) in NTAB.
f.Enter (object module name, program_linked_origin) in NTAB.
3.For each object module
a.T_origin = translated origin of the object module.
      Program_linked_origin = load_address from NTAB.
b.For each LINKTAB entry with type = EXT
i.Address_in_work_area = address of work_area + program_linked_origin - <link_origin> + translated address – t_origin.
ii.Search symbol in NTAB and copy its linked address. Add the linked address to the operand address in the word with the address address_in_work_area.

Linking requirement

In c program files are translated separately. Thus only function calls that cross files boundaries and references to global data require linking.
A reference to an external symbol can be resolved only if symbol is declared as a public definition in some object module. This observation forms the basis of program linking.
The linker process all object modules being linked and builds a table of all public definitions and their load time addresses.
Linking for symbol is simply a matter of searching for that symbol in this table and copying its linked address into the word containing the external reference.
A name table (NTAB) is defined for use in program linking. Each entry of the table contains 2 fields.
1.Symbol : symbolic name of public definition or an object module.
2.Linked address : for a public definition, this field contains linked address of the symbol. For an object module, it contains the linked origin of the object module.
Most information in NTAB is derived from LINKTAB entries with type = public definition.

Self Relocating Programs

A self-relocating program is a program which can perform the relocation of its own address sensitive instructions.
It contains two provisions for relocation
1.A table of information concerning the address sensitive instruction exists as a part of program.
2.Code to perform the relocation of address sensitive instructions also exists as a part of the program. This is called the relocating logic.
The start address of the relocating logic is specified as the execution start address of the program.
The relocating logic gains control when the program is loaded in memory for execution.  It uses the load address and the information concerning address sensitive instructions to perform its own relocation.
A self relocating program can execute in any area of the memory.
This is very important in time sharing operating system where the load address of a program is likely to be different for different executions.

Relocation algorithm

Prg_linked_origin=<link origin> from linker cmd.
For each object module
1.T_origin = translated origin of the object module. OM_size= size of object of the object module.
2.Relocation_factor=prg_linked_origin - t_origin.
3.Read the machine language program in work_area.
4.Read RELOCTAB  of the object module.
5.For each entry in RELOCTAB
a.Trans_addr = address in RELOCTAB ENTRY.
b.Address_in_work_area := address of work_area + translated_addresst_origin.
c.Add relocation_factor to the operand address in the word with the address address_in_work_area.
6.Program_linked_origin=program_linked_origin + OM_size.


linking is the process of binding an external reference to the correct link time address.
An application program consisting of a set of program units. A program unit interacts with another program by using addresses of instructions and data in its own instructions.
To realize such interactions both units of program must contain public definitions and external references.
1.Public definition : a symbol defined in a program unit which may be referenced in other program unit.
2.External reference : a reference to a symbol which is not defined in the program unit containing the reference.
Before the execution of program it necessary that for each program unit, every external reference in program units should be bound to the correct link time address.
An external reference is said to be unresolved until linking is performed for it. It is said to be resolved when its linking is completed.
Entry and Extern statements : The entry statement lists the public definitions of a program unit, it lists those symbols defined in the program unit. Which may be referenced in other program units. The extern statements lists the symbols to which external references are made in the program unit.
Binary Program : a binary program is a machine language program comprising a set of program unit.
1.Program unit has relocated to the area starting at its link origin.
2.Linking has been performed for each external reference in program unit.
To form a binary program from a set of object modules, the programmer invokes the linker using the command
Linker <link origin>, <object module names> [,<execution start address>]
Where <link origin> specifies the memory address to be given to the first word of the binary program. <execution start address> is usually a pair (program unit name, offset in program unit ).
The linker converts this into the linked start address.
This is stored with the binary program for use when the program is to be executed.

Object Module
The object module of a program contains all information necessary to relocate and link the program with other programs. The object module of a program consists of 4 components.
1.Header : the header contains translated origin, size and execution start address of program.
2.Program : this component contains the machine language program corresponding to program.
3.Relocation table (RELOCTAB): this table describes Instruction register requirement of program. Each relocation table contains a single field. It stores Translated address of an address sensitive instruction.
4.Linking Table (LINKTAB) : this table contains information concerning the public definition and external references in program.