Chess - Find all legal moves (except castling and en passant) Write the shortest code that calculates all possible (legal) moves of current player from a given FEN string. What is FEN string? (Wikipedia)  


Shortest code wins, language doesn't matter.
Output moves must obey chess rules of movement except en passant, castling, and pawn promotion. 
Ignore check, checkmate, and stalemate, king cannot be captured situations too.


You can set outputs differently as you want (for example: A2-A4, A2A4, a2a4, a2-&gt;a4...)

Test cases:


# INPUT 1:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1



# OUTPUT 1

A2-A4, A2-A3, B2-B4, B2-B3, C2-C4, C2-C3, D2-D4, D2-D3, E2-E4, E2-E3,
F2-F4, F2-F3, G2-G4, G2-G3, H2-H4, H2-H3, B1-A3, B1-C3, G1-F3, G1-H3



# INPUT 2

7k/8/8/8/8/8/PP6/Q1q4K w - - 0 1




# OUTPUT 2

A1-B1, A1-C1, A2-A3, A2-A4, B2-B3, B2-B4, H1-H2, H1-G1, H1-G2
C - 391 bytes
Takes input as command line arguments and prints to stdout with the squares labeled from 0 to 63.
OK, I had a few minutes so I tried to delete all the bits relating to the detection of check. I think it is now not very efficient though...
O(x,y){return((x&amp;7)-(y&amp;7))/5;}
B[64],*b=B,J=32,M,L,x,*X,N;
main(int c,char**V){
for(;x=*V[1]++;c=J&amp;2**V[2])
x&gt;56?*b++=x:x&gt;47?b+=x-48:0;
for(;b--&gt;B;)
for(M=-1,N=*b%J^16,*V=strchr(&quot;bGInFJOQrAHkAGHIqAGHIpGHIx&quot;,*b|J);*b&amp;&amp;*b&amp;J^c&amp;&amp;(M=M&lt;0?*++*V%J:-M,**V&lt;96);)
for(x=b-B,L=N?9^*b&amp;8:1+(x/8==1+c/6);L--*!(O(x,x+M)|O(x&gt;&gt;3,x+M&gt;&gt;3));L=!*X|~*X&amp;J^c&amp;&amp;N|(!*X^M&amp;1&amp;&amp;M&lt;0^!c)?printf(&quot;%d-%d &quot;,b-B,x),L*!*X:0)
X=B+(x+=M);}

478 byte check-detecting version
O(x,y){return((x&amp;7)-(y&amp;7))/5;}
B[64],*b=B,c,I,J=32;
main(int C,char**V){
int*D,M,L,t,x,*X,N;
for(;b-B&lt;64;C=c=J&amp;2**V[2])
(t=*V[1]++)&gt;56?*b++=t:t&gt;47?b+=t-48:0;
for(D=b;D--&gt;B;)
for(M=-1,N=*D%J^16,*V=strchr(&quot;bGInFJOQrAHkAGHIqAGHIpGHIx&quot;,*D|J);*D&amp;&amp;*D&amp;J^C&amp;&amp;(M=M&lt;0?*++*V%J:-M,**V&lt;96);)
for(x=D-B,L=N?9^*D&amp;8:1+(x/8==1+C/6);L--*!(O(x,x+M)|O(x&gt;&gt;3,x+M&gt;&gt;3));L=!*X|~*X&amp;J^C&amp;&amp;N|(!*X^M&amp;1&amp;&amp;M&lt;0^!C)?c^C?I|=*X%J==11:(*X=*D,*D=I=0,main(C^J,V+1),*D=*X,I||printf(&quot;%d-%d &quot;,D-B,x)),L*!(*X=t):0)
X=B+(x+=M),t=*X;}