Category Archives: All

All posts

Fedora – Install Skype

You can install Skype from repository.

Go on :

First create a file named

Put this code on this file :

Save the file.

Use :

This is all.

Posted in Linux. Tagged with , .

warning: implicit declaration of function …

Some errors you might encounter when you compile with code::blocks.

It seems that your header files have no prototype declared for some of the functions.

In this case the function itself is implicitly treated as the function prototype.

You need add some parentheses. If you code is like :

…then the code will be:

Posted in Errors. Tagged with .

Gnome online accounts – error proxy

The error is this:

To solve this you need to do this steps:

Under System Settings->Network->Network proxy – this is under online Accounts on same menu, switching to None will solve this error

Posted in Linux. Tagged with .

Hacking on assembly code: Dynamic memory allocation on stack?

So I started dabbling with assembly language programming a couple of days ago. This was the next logical step in the “going lower down” move I have been doing ever since I started writing programs in Visual Basic some years ago (there, I admitted it). Since then I went through C#, Java, C++, C and now finally assembly. And it is fun to watch a program die in so many innovative ways. It is helping me understand the internals of a program much better.

One of the first things I learnt about assembly programming was that I needed to use completely different syscall numbers and instructions for x86_64 as compared to i386. For example, the syscall number for exit on i386 is 1 while on x86_64 it is 60. Same goes for write — 4 on i386 and 1 on x86_64. I spent half an our trying to figure out why my program was calling fstat on x86_64 while a similar program built with –32 would work fine.

Crossing all these hurdles, I finally wrote a slightly more complicated (but still useless) program than a hello world. This is a program that takes in an integer string through the command line, converts it to an integer, converts it back to string and prints it back out. Pretty useful huh πŸ™‚

Now for the interesting part in the code. I always thought of dynamic memory allocation as something you can only do through the OS using the brk() and/or mmap() syscalls. Generally we do this indirectly through malloc() and friends. But what I ended up doing in my program is allocating memory on the stack on the fly. Here’s the code snippet:

The complete code along with the makefile is at the end of this post. You can build it if you have an x86_64 installation. What I do above is simply:

  1. Read a digit from the number
  2. Move the stack pointer ahead to make room for a byte
  3. Store the ascii representation of that number into that byte

I could not use the push instruction itself, since it can only push 16, 32 or 64 bit stuff on to the stack (with pushw, pushl, pushq). If you push a single byte value, it will be stored in one of the above sizes, not in just 1 byte. What I wanted was to create a string on the fly without limiting myself to a fixed size array, so this seemed to be the only approach. While this works, I still need to find out a few more things about this:

  1. Is it safe?
  2. If it is safe, then is there a similar way to do this in C without embedding assembly code? This would be really cool, especially in usage scenarios such as the above. Admitted that the above scenario is pretty useless in itself, but I’m sure there must be similar examples out there that are at least a little more useful.

The code:

The makefile:

If you save the source as foo.s, you can build it with:

Written by Siddhesh Poyarekar

Posted in Assembler, Programming. Tagged with , , .

error: ‘for’ loop initial declarations are only allowed in C99 mode

Some errors you might encounter when you compile with code::blocks.

The one of many reason is you have written a code like:

To solve this error , just write code like this:

Posted in Errors. Tagged with .