1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
| include irvine32.inc .data chess dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,04 a dd 8 dup(1) b dd 15 dup(1) x dd 15 dup(1) sum dd 0 msg1 db '第',0 msg2 db '种可能的摆法:',0 msg3 db ' ',0 msg4 db '八皇后摆法总数:',0 .code main proc push 0 call putqueen lea edx,msg4 call writestring mov eax,sum call writedec
exit main endp
putqueen proc push ebp mov ebp,esp pushad mov ecx,[ebp+8] mov ebx,0 again: cmp ebx,8 jge final cmp a[ebx*4],0 jz next mov eax,ecx add eax,ebx cmp b[eax*4],0 jz next mov eax,ecx sub eax,ebx add eax,7 cmp x[eax*4],0 jz next mov [x+eax*4],0 mov eax,ecx add eax,ebx mov [b+eax*4],0 mov [a+ebx*4],0 mov eax,ecx mov edx,32 mul edx mov [chess+eax+ebx*4],1
cmp ecx,7 jnz L1 inc sum lea edx,msg1 call writestring mov eax,sum call writedec lea edx,msg2 call writestring call crlf mov esi,0 cmp esi,8 again_1: cmp esi,8 jge L2 lea edx,msg3 call writestring mov edi,0 again_2: cmp edi,8 jge next_1 mov eax,esi mov edx,32 mul edx mov eax,[chess+eax+edi*4] call writedec mov al,' ' call writechar next_2: inc edi jmp again_2 next_1: call crlf inc esi jmp again_1
L1: mov eax,ecx inc eax push eax call putqueen L2: mov eax,ecx mov edx,32 mul edx mov [chess+eax+ebx*4],0 mov eax,ecx add eax,ebx mov [b+eax*4],1 mov eax,ecx sub eax,ebx add eax,7 mov [x+eax*4],1 mov [a+ebx*4],1
next: inc ebx jmp again
final: popad pop ebp
ret 4 putqueen endp
end main
|