N-Queens Problem. Brute force solution. Debugging help needed

As you probably know, the N-Queens problem involves placing N- queens on an NxN chess board such that no two queens are attacking each other. I'm trying out a brute force method to get this working.

Strangely enough, it works for N values Less than 9. But for N=9,10,11,... etc., the code fails. I am unable to ascertain why this is happening.

I've attached the entire code for the problem. I'd appreciate if someone told me where it is failing.

The value N is implemented as a macro BS in the code, almost on top. The output is a matrix of 0's and 1's. A 1 represents a queen, a 0 is a blank square.

Thanks in advance.