Segmenation fault – core dump error assembly 32bit code on 64bit machine

I have a shiny 64 bit dell machine that tops ubuntu on it.
I working working on some other machine a bit of assemly code and I didn’t have a problem.
But when I run the same code my 64 machine i was getting the a segmentation falut error. Not surprising actually.
here is what I have done to resolve it:

1. Don’t forget to add .code32 at the beginning of your assembly file. [ talking about x86 architecture ]
2. Have the gcc multilib on your machine

sudo apt-get install gcc-4.7-multilib

3. When assembling and linking your file use

gcc -m32 -nostartfiles -o executablename filename.s

Change your executablename and filename.s accordingly