aboutsummaryrefslogtreecommitdiffstats
path: root/code/tools/lcc/x86/win32/tst/8q.sbk
blob: 2ffd76cf5e36234bc890939ca44b0a60b9e0d979 (plain)
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
.486
.model flat
extrn __fltused:near
extrn __ftol:near
public _main
_TEXT segment
_main:
push ebx
push esi
push edi
push ebp
mov ebp,esp
sub esp,4
mov dword ptr (-4)[ebp],0
L2:
mov edi,dword ptr (-4)[ebp]
lea edi,[edi*4]
mov dword ptr (_down)[edi],1
mov dword ptr (_up)[edi],1
L3:
inc dword ptr (-4)[ebp]
cmp dword ptr (-4)[ebp],15
jl L2
mov dword ptr (-4)[ebp],0
L6:
mov edi,dword ptr (-4)[ebp]
mov dword ptr (_rows)[edi*4],1
L7:
inc dword ptr (-4)[ebp]
cmp dword ptr (-4)[ebp],8
jl L6
push 0
call _queens
add esp,4
mov eax,0
L1:
mov esp,ebp
pop ebp
pop edi
pop esi
pop ebx
ret
public _queens
_queens:
push ebx
push esi
push edi
push ebp
mov ebp,esp
sub esp,4
mov dword ptr (-4)[ebp],0
L11:
mov edi,dword ptr (-4)[ebp]
cmp dword ptr (_rows)[edi*4],0
je L15
mov esi,dword ptr (20)[ebp]
mov ebx,edi
sub ebx,esi
cmp dword ptr (_up+28)[ebx*4],0
je L15
lea edi,[esi][edi]
cmp dword ptr (_down)[edi*4],0
je L15
mov edi,dword ptr (-4)[ebp]
mov esi,dword ptr (20)[ebp]
lea ebx,[esi][edi]
mov dword ptr (_down)[ebx*4],0
mov ebx,edi
sub ebx,esi
mov dword ptr (_up+28)[ebx*4],0
mov dword ptr (_rows)[edi*4],0
mov edi,dword ptr (20)[ebp]
mov esi,dword ptr (-4)[ebp]
mov dword ptr (_x)[edi*4],esi
cmp dword ptr (20)[ebp],7
jne L19
call _print
add esp,0
jmp L20
L19:
mov edi,dword ptr (20)[ebp]
lea edi,(1)[edi]
push edi
call _queens
add esp,4
L20:
mov edi,dword ptr (-4)[ebp]
mov esi,dword ptr (20)[ebp]
lea ebx,[esi][edi]
mov dword ptr (_down)[ebx*4],1
mov ebx,edi
sub ebx,esi
mov dword ptr (_up+28)[ebx*4],1
mov dword ptr (_rows)[edi*4],1
L15:
L12:
inc dword ptr (-4)[ebp]
cmp dword ptr (-4)[ebp],8
jl L11
mov eax,0
L10:
mov esp,ebp
pop ebp
pop edi
pop esi
pop ebx
ret
public _print
_print:
push ebx
push esi
push edi
push ebp
mov ebp,esp
sub esp,4
mov dword ptr (-4)[ebp],0
L23:
mov edi,dword ptr (-4)[ebp]
mov edi,dword ptr (_x)[edi*4]
lea edi,(49)[edi]
push edi
lea edi,(L27)
push edi
call _printf
add esp,8
L24:
inc dword ptr (-4)[ebp]
cmp dword ptr (-4)[ebp],8
jl L23
lea edi,(L28)
push edi
call _printf
add esp,4
mov eax,0
L22:
mov esp,ebp
pop ebp
pop edi
pop esi
pop ebx
ret
_TEXT ends
extrn _printf:near
_TEXT segment
_TEXT ends
_DATA segment
public _x
align 4
_x label byte
db 32 dup (0)
public _rows
align 4
_rows label byte
db 32 dup (0)
public _down
align 4
_down label byte
db 60 dup (0)
public _up
align 4
_up label byte
db 60 dup (0)
_DATA ends
_TEXT segment
align 1
L28 label byte
db 10
db 0
align 1
L27 label byte
db 37
db 99
db 32
db 0
_TEXT ends
end