Hello I have the following code:
\documentclass[12pt]{article}
\usepackage[top=0.3in, bottom=1.5in, left=0.8in, right=0.8in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{setspace}
\setlength{\parindent}{0cm}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[frame=single,title={Blinking both LEDs},breaklines=true]
#include <msp430g2553.h>
unsigned int i = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= 0x01;
P1DIR |= 0x40;
for(;;)
{
//Both LEDs blink simultaneously
P1OUT ^= 0x01;
P1OUT ^= 0x40;
//Or alternative P1OUT ^= 0x01|0x40
for(i=0;i<30000;i++);
//If I place P1OUT ^= 0x40; here then one LED blink and then the other
};
}
\end{lstlisting}
\end{document}
In the last comment why doesn't the new line starts from the beggining (meaning under the //) but instead starts with a little left margin? And also why the first comment is far more left than the rest of the code in its block?
I have uploaded an image also with tabs on. There is something wrong. When I experiment with tabs odd things happen and the document doesn't appear as it should be. The second image is based on the code I wrote in that post and I haven't experiment on that one.

tab, versus actual spaces which are being treated differently. You can try adjustingtabsize=<number>. Cutting and pasting your MWE works fine for me so the tabbing must be getting lost in the pasting here. – Peter Grill Mar 19 '14 at 19:09showtabs=trueto your listing – Andrew Swann Mar 19 '14 at 21:02listings, it's safer to stick to spaces instead. Most editors/IDEs can be configured to insert spaces (e.g. 4) instead of a tab character when the Tab key is pressed. Look into it. – jub0bs Mar 19 '14 at 21:40lstlistingenvironment, as in your MWE) as opposed to "standalone" listings (by using\lstinputlisting), the problem can be solved in your LaTeX editor alone. – jub0bs Mar 19 '14 at 21:52lstlisting(not\lstinputlisting), you can solve the problem completely in your LaTeX editor by searching for tab characters and replacing each of them by an appropriate number of spaces (typically, 2 or 4). – jub0bs Mar 19 '14 at 22:05