C Language : Pointer Fundamental

No comments
Pointer Fundamental

In the simplest term pointer is a nearly integer variable which stores a memmory address of a computer which may contain other variable or even another pointer.

If a variable contains address of another variable than it is said that first variable points to second. Pointer can also be represented as a refrence to another variable but there is very subtle diffrence in the two statements which is mostly dependent upon situation and enviorment.

Pointer is generally of size of integer on the machine but it may be of different type which indicates the type of variable the pointer is pointing to decides pointers properties and behaviour. Pointer of one type cannot be implicitly converted from one type to another but can be explicitly converted using type casting. In such a conversion a pointer always assumes that it is point to a object of its type but reality may differ and if used incorrectly may lead to disasters including permanent machine damage.

Also it is important to note that all operation perform on pointers are done through two operators '*' (Star) and '&' (Ampercent). '&' is a unary operator that returns a memmory address of a variable. '*' is complement of '&' and return value stored at a memmory location stored in a pointer. '*' can interpreted as statement "at address" while '&' can be interpreted as statement "address of".


Pointer Variable

Declaring a pointer variable is quite similar to declaring an normal variable all you have to do is to insert a star '*' operator before it.


General form of pointer declaration is -

type* name;

where type represent the type to which pointer thinks it is pointing to.

Pointers to machine defined as well as user-defined types can be made.

Multiple pointers of similar type can be declared in one statement but make sure you use * before every one otherwise they will become a variable of that type.

Pointer Assignment

This is a type of expression used to assign value of one pointer to another using assignment operator '=' . In this value of right hand side points to memmory address of variable stored in left hand side pointer. As a result both pointers point to same memmory location after this expression.

Pointer of similar type can be used in expression easily as shown below but for diffrent type pointers you need to type cast them as shown in next section.

//
#include ‹stdio.h›
int main ()
{
   char ch = a;
   char* p1, *p2;
   p1 = &ch;
   p2 = p1; // Pointer Assignement Taking Place 
   printf (" *p1 = %c And *p2 = %c", *p1,*p2); // Prints 'a' twice
   return 0;
}

No comments :

Post a Comment

Digital Electronic : Logic Family

No comments

TTL Logic Family

The transistor-transistor-logic (TTL) family was developed in the use of transistor switches for logical operations and defines the binary values as




0 V to 0.8 V = logic 0
2 V to 5 V = logic 1


TTL is the largest family of digital ICs, but the CMOS family is growing rapidly. They are inexpensive, but draw a lot of power and must be supplied with +5 volts. Individual gates may draw 3 to 4 mA.
The low power Schottky versions of TTL chips draw only 20% of the power, but are more expensive. Part numbers for these chips have LS in the middle of them.

CMOS Logic Family

The complementary metal oxide semiconductor family (CMOS) has equivalents to most of the TTL chips. CMOS chips are much lower in power requirements (drawing about 1 mA) and operate with a wide range of supply voltages (typically 3 to 18 volts). The CMOS model number will have a C in the middle of it, e.g., the 74C04 is the CMOS equivalent to the TTL 7404. A bigh drawback is extreme sensitivity to static electricity - they must be carefully protected from static discharges.

NMOS and PMOS Logic ICs

P- and N-channel Metal Oxide Semiconductors (PMOS and NMOS) offer the advantage of higher component density than TTL chips. There are not nearly so many TTL equivalents (CMOS family does much better here). They are sensitive to damage from electrical discharge.

Component Designations


Integrated circuits in the TTL logic family have part numbers which are four to five digit numbers. With the introduction of other types of construction of devices, letters were added to center of the numbers to remind the user that basic TTL chips are not being used. The device numbers begin with a prefix which tells about its series followed by another number which identifies the individual device.

7400         the TTL designation
74C00 the CMOS equivalent
74LS00 the low-power Schottky implementation


No comments :

Post a Comment

GIGO:

No comments

garbage in, garbage out

Often abbreviated as GIGO, this is a famous computer axiom meaning that if invalid data is entered into a system, the resulting output will also be invalid. Although originally applied to computer software, the axiom holds true for all systems, including, for example, decision-making systems.

No comments :

Post a Comment

Firmware : Software that stored in ROM

No comments


Firmware is a software program or set of instructions programmed on a hardware device. It provides the necessary instructions for how the device communicates with the other computer hardware. But how can software be programmed onto hardware? Good question. Firmware is typically stored in the flash ROM of a hardware device. While ROM is "read-only memory," flash ROM can be erased and rewritten because it is actually a type of flash memory.
Firmware can be thought of as "semi-permanent" since it remains the same unless it is updated by a firmware updater. You may need to update the firmware of certain devices, such as hard drivesand video cards in order for them to work with a new operating system. CD and DVD drive manufacturers often make firmware updates available that allow the drives to read faster media. Sometimes manufacturers release firmware updates that simply make their devices work more efficiently.
You can usually find firmware updates by going to the "Support" or "Downloads" area of a manufacturer's website. Keeping your firmware up-to-date is often not necessary, but it is still a good idea. Just make sure that once you start a firmware updater, you let the update finish, because most devices will not function if their firmware is not recognized.

No comments :

Post a Comment

UEFI: a new technology for computer hardware interface

No comments
UEFI: The acronym stands for Unified Extensible Firmware Interface and is designed to be more flexible than its venerable predecessor.



Wave goodbye to BIOS, say hello to UEFI, a new technology that will drastically reduce start-up times.
The next generation of home computers will be able to boot up in just a few seconds, as 25-year-old BIOS technology makes way for new start-up software known as UEFI.
BIOS technology, which has been used to boot up computers since 1979, was never designed to last as long as it has, and is one of the reasons modern computers take so long to get up and running.
By contrast, UEFI – which stands for Unified Extensible Firmware Interface – has been built to meet modern computing needs, and will soon be the pre-eminent technology in many new computers, enabling them to go from ‘off’ to ‘on’ in seconds.
Pronounced “bye-ose,” BIOS is an acronym for basic input/output system. The BIOS is built-in software that determines what a computer can do without accessing programs from a disk. On PCs, the BIOS contains all the code required to control the keyboard, display screen, disk drives, serial communications, and a number of miscellaneous functions.
The BIOS is typically placed on a ROM chip that comes with the computer (it is often called a ROM BIOS). This ensures that the BIOS will always be available and will not be damaged by disk failures. It also makes it possible for a computer to boot itself.
 Below are the major BIOS manufacturers:
When you turn on your computer, several events occur automatically:
  1. The CPU “wakes up” (has power) and reads the x86 code in the BIOS chip.
  2. The code in the BIOS chip runs a series of tests, called the POST forPower On Self-Test, to make sure the system devices are working correctly. In general, the BIOS:
    • Initializes system hardware and chipset registers
    • Initializes power management
    • Tests RAM (Random Access Memory)
    • Enables the keyboard
    • Tests serial and parallel ports
    • Initializes floppy disk drives and hard disk drive controllers
    • Displays system summary information
  3. During POST, the BIOS compares the system configuration data obtained from POST with the system information stored on a CMOS –Complementary Metal-Oxide Semiconductor – memory chip located on the motherboard. (This CMOS chip, which is updated whenever new system components are added, contains the latest information about system components.)


 4. After the POST tasks are completed, the BIOS looks for the boot program responsible for loading the operating  system.  Usually, the BIOS looks on the floppy disk drive A: followed by drive C:
        5. After being loaded into memory, the boot program then loads the system configuration information (contained in the registry in a Windows environment) and device drivers.
       6. Finally, the operating system is loaded, and, if this is a Windows environment, the programs in the Start Up folder are executed.
            The BIOS has two fundamental weaknesses. Firstly, it is based on 16-bit assembly code and cannot directly address  the latest 64-bit hardware, and secondly, there are no set standards for specifications, so manufacturers come up with  their own versions.

The participants of the UEFI Forum wanted to set this straight. From the outset, each process has been precisely defined. Thus, the boot process or platform initialization (PI) is clearly described in phases. Immediately after powering up the PC, the Pre-EFI Initialization (PEI) is executed, which initializes the CPU, memory and chipset. This is then followed by the Driver Execution Environment (DXE). At this point, the rest of the hardware is initialized. This process saves the time required for booting because UEFI can integrate various drivers that need not be reloaded during booting. Thanks to these drivers, the user already has access to network card, including features such as network booting and remote assistance at the early stage of the boot process. With the graphics processor enabled, a fancy user interface is also presented.

However, biggest time-saving feature of UEFI is the fact that not all the installed hard drives will be scanned for the boot loader, since the boot drive is set during the installation of the operating system in the UEFI. The default boot loader is run without consuming much time searching the drives.
The faster boot time is not the only advantage of UEFI; applications can be stored on virtually any non-volatile storage device installed on the PC. For example, programs and diagnostic tools such as antivirus or system management tools can be run from an EFI partition on the hard drive. This feature will be very useful to original equipment manufacturers (OEM), who can distribute systems with extra functions in addition to the standard EFI firmware stored on the motherboard’s ROM.
UEFI fully supports 3 TB hard drives
The classic BIOS can access only up to 232 sectors of 512 bytes in size, which  translates to a total of 2 TB. So the upcoming 3 TB variants of Western Digital Caviar Green and Seagate Barracuda XT won’t be fully compatible with the current BIOS. Seagate uses larger sectors to make the full capacity usable on Windows, but the BIOS cannot boot from this drive.
UEFI, on the other hand, works with GUID partition table (GPT) with 64-bit long addresses and can handle up to 264 sectors that address up to 9 Zettabyte (1 zettabyte equals 1 billion terabytes).
The GUID Partition Table (GPT) was introduced as part of the Unified Extensible Firmware Interface (UEFI) initiative. GPT provides a more flexible mechanism for partitioning disks than the older Master Boot Record (MBR) partitioning scheme that was common to PCs.
A partition is a contiguous space of storage on a physical or logical disk that functions as if it were a physically separate disk. Partitions are visible to the system firmware and the installed operating systems. Access to a partition is controlled by the system firmware before the system boots the operating system, and then by the operating system after it is started.
MBR disks support only four partition table entries. If more partitions are wanted, a secondary structure known as an extended partition is necessary. Extended partitions can then be subdivided into one or more logical disks.
GPT disks can grow to a very large size. The number of partitions on a GPT disk is not constrained by temporary schemes such as container partitions as defined by the MBR Extended Boot Record (EBR).
The GPT disk partition format is well defined and fully self-identifying. Data critical to platform operation is located in partitions and not in unpartitioned or “hidden” sectors. GPT disks use primary and backup partition tables for redundancy and CRC32 fields for improved partition data structure integrity. The GPT partition format uses version number and size fields for future expansion. Each GPT partition has a unique identification GUID and a partition content type, so no coordination is necessary to prevent partition identifier collision. Each GPT partition has a 36-character Unicode name. This means that any software can present a human-readable name for the partition without any additional understanding of the partition.
Below given Windows OS supports GPT:
  • Windows 7
  • Windows Server 2008
  • Windows Server 2008 R2
  • Windows Vista
  • Windows Server 2003 SP1
  • Windows Server 2003 (64-bit)
  • Windows XP x64 edition

source: Wikipidia

No comments :

Post a Comment