16/32 bit C Programming
What does 16/32-bit mean?
A binary digit, or bit, is the smallest unit of data that any computer can process. The more units any computer can process at the same time, the faster it is. Most computers manipulate bits in groups of 16 or 32. Operating system is classified as 16-bit or 32-bit depending upon the microprocessor. Depending upon OS, program is defined as 16/32 bit programming. If you have two computers whose processing speed is same and one process 32 bits at a time while the other processes 16 bits, the 32 bit computer will be about twice as fast as the other one.
Now a days, all computers uses 32bit or 64 bit processor.16 bit programs today are confined to embedded domains only. We can say that 16 bit programs are used when we have very limited memory. Because of this we can access 2^20 or 1 MB of memory as address bus length is 20 bit in a 16 bit processor but in modern computer we need large amount of memory for our regular and scientific work. This need is fulfilled by use of 32 bit programming, where we can access 2^32 or 4 GB of memory as address bus is 32 bit length.
In 16 bit programming the maximum data size of an integer variable is (2^16-1) or 65535 as data bus width is 16 bit. But in 32 bit programming we can store (2^32-1) or 4294967295 amount of data in the same variable. So the amount of data that can be stored in the same variable is more.
32bit process memory layout
A 32 bit compiler like GCC work over Linux operating system, which is designed over 80386 microprocessors. The Linux operating system deals with 4 GB virtual memory. The virtual memory of Linux system is divided into 3 GB User Space and 1 GB Kernel Space. For each process the entire 3GB user space is different but all processes share a common 1 GB kernel space.
16 bit process memory layout
The best example of 16 bit compiler is Turbo C.Turbo C works over MSDOS operating system which is designed over 8086 microprocessor. Every 16 bit program in MSDOS can address maximum of upto 1 MB of memory.
Limitations of 16 bit programming
- Multitasking is not possible.
- Resource hungry applications such as math packages, graphics and network are impossible to design with this amount of memory.
- Multimedia applications are impossible as they require more memory.
- 16 bit processors spend a significant amount of time manipulating stack elements when dealing with floating point numbers.
- Running 16 bit programs can reduce the number of users a processor supports by 40% and increase the memory required for each user by 50%.
Advantages of 32 bit programming
- Applications such as network program, graphics program are possible in 32 bit programming.
- Floating point calculations are efficient in 32 bit programming environment as in 16 bit processor a lot of time is spent in stack element manipulation which is not present in 32 bit environment.
- Another advantage of 32 bit systems is faster multitasking where two or more applications run at the same time.
Basically we can say that with the changing world we should now adopt the 32 bit programming for development in modern computers. So if you are serious in C programming, then switch to 32 bit programming as industries demand 32 bit programmers not 16 bit programmers. But when you are dealing with memory system (embedded programs and real time systems) 16 bit programs should be used.So we cant say 16 bit programs are completely obsolete but its’ applications are quite limited now a days.