Microsoft offer $100 for XP

Posted on Updated on

After April 8, 2014, support and security updates for XP will no longer be available.

Microsoft trying to motivate customers around globe to upgrade PC’s to windows 8.1.

So here is the offer from microsoft

read microsoft support is ending

Microsoft Store to use offer

Don’t have windows Xp and want offer ?

Read the rest of this entry »

Some Interesting Pointer Tricks

Posted on Updated on

I was browsing on Quora when I stumbled across some interesting answers on pointers. They were worth sharing, so here they are with the sources mentioned at the bottom.


Encoding information in the low-order bits of pointers.

The setup: The memory addresses of objects are aligned to specific boundaries—generally what we call natural alignment, which means objects are aligned to a memory address that is a multiple of their size. So a 64-bit integer is aligned to an eight-byte boundary;


is a proper


pointer on x86-64 but


is not. If a pointer is always aligned to an eight-byte boundary, then the low-order three bits are always zero.

The trick: You can stick whatever you want in those low-order bits, so long as you take them out before dereferencing the pointer. If your bottom three bits have to be zero, then you get three bits of “free” storage. To make this easy, you define a couple macros. One macro (called


in my example) masks out the low-order bits and returns a proper pointer. Another macro (


in my example) masks out the high-order bits and returns the encoded data. To prevent the accidental dereferencing of the pointer before masking out the encoded data—which, aside from the pointer not pointing directly at your data, might be an alignment violation—the usual pattern is to store your pointers in

unsigned long

types, although a


is a more portable alternative.

Example: Here’s an example, which defines three flags that you may OR into the pointer. Note this particular example requires a platform where pointers and longs are both 64-bits, but you could easily modify it for a 32-bit system.


#include <stdio.h>

#define POINTER(p) (unsigned long*)(p & 0xffffffffffffff8UL)
#define DATA(p) (p & 7)

#define FLAG1 1
#define FLAG2 2
#define FLAG3 4

int main() {
unsigned long v = 0;
unsigned long p = (unsigned long) &v;

printf("p=%lu\n", p);
printf("POINTER(p)=%p\n", POINTER(p));
printf("DATA(p)=%lu\n", DATA(p));

p |= FLAG2;

printf("p=%lu\n", p);
printf("POINTER(p)=%p\n", POINTER(p));
printf("DATA(p)=%lu\n", DATA(p));

return 0;

Cool, but this seems like more work than it is worth? Often true! This sort of trick is useful when you have many, many pointers. For example, this is a common technique when implementing memory management systems where you might have a pointer to every active page in the system. Three bits with which to set read & write access flags are all you need.




Creating a doubly linked list with a single pointer

You can make a doubly linked list with a single pointer, which actually stores the XOR of its previous and next nodes’ addresses. For the head, this will just be the next element’s address.

Now, when traversing the list in the forward direction, instead of doing

n = n->next

, you do

n = n->next ^ prev

For the reverse direction, note that the tail’s next pointer will actually contain its previous node. So to traverse backwards, you just start with

n = tail
node *n = (forward ? head : tail), *prev = 0, *t;
while(/* some condition */) {
    t = n;
    n = n->next ^ prev;
    prev = t;


Insertion and deletion are similarly modified.

All of this is just a cute trick though- you should probably not use it unless writing code for some heavily memory constrained embedded system.



String Copy

while(*t++ = *s++) ;

Introduction to Linear data Structures

Posted on Updated on

Which data Structure is can be called as linear Data Structure ?

Data Structure is called linear, If its elements form a Sequence.

  • Array

This is most commonly used linear data structure, used for collection of sequential data to be stored and accessed using index.

memory requirements are array size + some extra buffer.

in c/c++

int array[100];

array is linear data structure with ((100*(size of int on respective machine)) + some buffer )  size


Read the rest of this entry »

XNA-The Basics

Posted on Updated on

Now, I assume that you have set up XNA. We’ll be going further and start creating our own tower defence game. However, before that I’ll explain some basic things about XNA to you so that we won’t have any hitches further in our journey.

  1. First of all, create a new project.
  2. Select Visual C# and then select XNA Game Studio 4.0
  3. Select Windows Game.
  4. Give some name to your project and click on OK.
  5. Your game will be created.


Now, when the project is created, you will see a C# file. The name will be Game1.cs.  Here you will be seeing five (6, if you count the constructor) methods:

  • Initialize
    Initialize method is a bit of a black sheep among these methods. It acts like a constructor. It is the first method to be executed by the XNA Framework. All initialization activities should be done in this method. Initialize calls the LoadContent method.
  • LoadContent
    Load Content method is called exactly once. All the the sprites which you want to load are to be loaded through this method. It is called by initialize. Its function is similar to the Initialize method. All that you can do in the initialize method, you can do here. However, this method is used rather than the Initialize method. Initialize method is rarely used.
  • UnloadContent
    This method unloads any content that is loaded by the Load Content method. Again, this method should be used only if your game’s performance is degrading due to many sprites being in memory. Small games almost always never use this method.
  • Update
    This is the most important method of all. All your game logic goes in this method. This method is called 60 times per second. This method updates the sprites on the screen according to the logic described in the method. Anything not related to drawing and related to gaming logic comes in this method.
  • Draw
    This is the most important method after Update. It draws sprites and other components to the screen. This is called variable number of times per second. The draw method uses Spritebatches to draw components on the screen. More on drawing later.

If you press F5, you will see a blue screen. This means you created a new project succesfully.

The XNA program flow is as follows:

  1. In your Solution Explorer window, you will see a file called Program.cs, which creates an object of your current game. This object calls the game’s Run() method.
  2. This run method calls the Initialize method of the Game1.cs class which inherits the Game classs.
  3. The initialize method calls the Load Content method which then calls the Update method.
  4. After the update method, the draw method is called. For the rest of the execution, Update and Draw are interleaved in execution.

In next posts, I will tell you how to draw some simple textures onto the screen and how to make them move around. Once these basics are out of the way, then we can proceed to creating a tower defence game.

Microsoft makes MS-DOS source code available

Image Posted on

Little History:

Its been 30 years since Microsoft released MS-DOS. It was the beginning of the personal computer era. MS DOS started with IBM giving the contract to Microsoft to develop an operating system for their PC. Initially, Microsoft had provided BASIC language interpreter to IBM. This early relationship paved the way for IBM hardware and Microsoft software in the coming years. At that time Microsoft had 100 employees out of which 35 worked hard on the early MS DOS.


Well, the early MS DOS did nothing more than managing the files and loading programs. The later versions added more functionality like installing device drivers, input redirection, etc.

Computer History Museum:

Some of you may be surprised but there’s a museum to preserve all the computer artifacts and the stories that had led to computer evolution. Its located in Mountain View, California (yes, the same place where Google has its HQ). A must visit for computer people if you ever travel to US. Its this museum’s project to make the source code available.

Downloading the source code:

The zip file contains four subdirectories:

  • v11source: 7 assembler code files, and an explanatory email from Tim Paterson
  • v11object: 27 files, some binary programs and some sample programs
  • v20source: 118 text files, mostly assembler code and some documentation
  • v20object: 38 files, some binary and some documentation

Its written in Assembly for 8086, which some of you maybe familiar with. You probably won’t understand all of it. But look at what this represents, this is the source code that made millions of dollars and is the foundation of what most people use today.

Creating games in Windows

Posted on Updated on

Everybody wants to create games but very few know how to. Even if someone has the requisite skills, knowledge is a barrier to entry in the gaming field.

The common questions which a newcomer to the gaming field faces:

  1. How to start?
  2. Which frameworks should be used?
  3. Which language should it be coded in?
  4. How to create art?

Read the rest of this entry »