-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrain Boggle.asm
1073 lines (917 loc) · 22.2 KB
/
Brain Boggle.asm
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
INCLUDE Irvine32.inc
.data
Starting_time byte "The starting time is : ",0
Current_time byte "The current time is :",0
Finish_time byte "The Ending time is : ",0
level byte "LEVEL #",0
levelnumber dword 1
hours dword ?
minutes dword ?
founddd byte ?
seconds dword ?
str2 byte "found",0
total dword ?
Points dword 0h
PPoints byte "POINTS :",0
FinishTime Dword ?
limit dword 01517Fh
Enterword byte "Please enter a word that you beleive is present in the puzzle (Remember! It should be a legitemate word) :",0AH,0
Found byte "Good news! This word is indeed present in the puzzle :)",0AH,0
Notfound byte "Sorry! This word is not present in the puzzle :( ",0AH,0
Timesup byte "Uh oh! Looks like your time's up ",0AH,0AH,0AH,0
currenttime byte "00:00:00",0AH,0
timelimit byte "00:00:00",0AH,0
tempo dword 1 dup (?)
tempo1 dword 1 dup (?)
middlecoordinate dword 1 dup(?)
wlevel byte "level",1 dup(?),".txt",0
levelll byte "level.txt",0
matrix_char byte ?,0
actual dword ?,0
handlee handle ?,0
handleee handle ?,0
row1 byte 0
col1 byte 0
minimum byte ?,0
random_integer byte 3
stack_pointer_matrix_1 dword ?
stack_pointer_matrix_2 dword ?
temp1 byte ?
flag byte 0
stack_upwards dword ?
wordd Dword 50 dup(?)
len1 Dword ?
strl Dword 50 dup(?)
dic byte 1 dup(?),".txt",0
temppp byte "temp.txt",0
message byte 1 dup (?)
mess byte 0Ah,0
level1 byte "1"
flaggg byte ?
titlee byte "-|BRAIN BOGGLE|-",0
startgameoption byte "Please press ENTER key to start the game",0AH,0
exitoption byte "Enter SPACE key to exit the game",0AH,0
.code
Search proto arr: ptr dword,tempp:ptr dword,arr2: ptr dword,len:dword,row:dword,col:dword,counter:dword,temprow:dword,endrow:dword,endcol:dword ;Search(char **matrix,char **temp,char *string,int lengthofstring,int row,int col,int counter,int temprow)
printpuzzle proto Matrix:ptr dword,Row:dword,Column:dword
main PROC
Beginning:
mov ecx,7
l110: ;This loop is to print the title of the game along with the design
mov ebx,119
cmp ecx,4
JE printtitle
jmp else110
printtitle:
mov dl,50
mov dh,3
call gotoxy
mov edx,offset titlee
call writestring ;printing game title
jmp loop110
else110:
xchg ebx,ecx
l100:
mov eax,42
call writechar ;printing asterisks
loop l100
xchg ebx,ecx
loop110:
call crlf
loop l110
mov dl,40
mov dh,12
call gotoxy
mov edx,offset startgameoption ;printing start game option
call writestring
mov dl,40
mov dh,15
call gotoxy
mov edx,offset exitoption
call writestring ;printing exit game option
call crlf
l131:
mov dl,56
mov dh,18
call gotoxy
call readchar ;reading the option selected by the user
cmp al,13
JE levels ;start the game if user presses enter key
cmp al,10
JE levels ;start the game if user presses enter key
cmp al,32
JE exittt ;EXIT the game if user presses SPACE key
JMP l131
mov ecx,0
mov edx,0
mov ebx,0
levels:
call clrscr
mov eax,3
call RandomRange
cmp eax,0
je levels
mov random_integer,al
mov Points,0
mov flaggg,0
invoke createfile,addr temppp,generic_read,do_not_share,NULL,create_always,file_attribute_normal,0
mov handlee,eax
invoke setfilepointer, handlee,0,0,file_current
invoke readfile,handlee,offset message,1,addr actual,0
mov eax,handlee
call closefile
invoke createfile,addr levelll,generic_read,do_not_share,NULL,open_existing,file_attribute_normal,0
mov handlee,eax
invoke setfilepointer, handlee,0,0,file_current
invoke readfile,handlee,offset message,1,addr actual,0
mov dl,message
mov wlevel[5],dl
mov level1,dl
mov eax,handlee
call closefile
invoke createfile,addr wlevel,generic_read,do_not_share,NULL,open_existing,file_attribute_normal,0
mov handleee,eax
mov ecx,0
mov ebx,0
mov eax,0
mov edx,0
mov temp1,0
mov flag,0
call checking_file_empty
call clrscr
mov eax,handleee
call closefile
mov al,minimum
invoke createfile,addr levelll,generic_read,do_not_share,NULL,create_always,file_attribute_normal,0
mov handlee,eax
invoke setfilepointer, handlee,0,0,file_current
invoke readfile,handlee,offset message,1,addr actual,0
mov eax,handlee
call closefile
mov al,flaggg
cmp al,0
je L33
mov al,wlevel[5];
cmp al,"1"
je level22
cmp al,"2"
je level33
jmp exittt
level22:
mov cl,"2"
mov level1,cl
jmp l33
level33:
mov cl,"3"
mov level1,cl
l33:
invoke createfile,addr levelll,generic_write,do_not_share,NULL,open_existing,file_attribute_normal,0
mov handlee,eax
mov ecx,0
invoke setfilepointer, handlee,0,0,file_current
invoke writefile,handlee,offset level1,1,addr actual,0
mov eax,handlee
call closefile
mov al,flaggg
cmp al,0
je beginning
jmp levels
exittt:
exit
main ENDP
checking_file_empty proc
mov ecx,0
finidng_random_matrix:
invoke setfilepointer, handlee,0,0,file_current
invoke readfile,handlee,offset matrix_char,1,addr actual,0
mov al,matrix_char
mov bl,'*'
cmp bl,al
jne finidng_random_matrix
inc temp1
mov bl,temp1
cmp bl,random_integer
je calling_fun
jmp finidng_random_matrix
calling_fun:
mov row1,0
mov col1,0
call pushing_matrix
ret
checking_file_empty endp
pushing_matrix PROC
mov edx,0
l1: ;for pushing 2d matrix
mov eax,0
invoke setfilepointer, handlee,0,0,file_current
invoke readfile,handlee,offset matrix_char,1,addr actual,0
mov al,matrix_char
mov cl,'1'
mov bl,13
cmp al,cl
jae check_min
if_not_number:
cmp al,bl
je enter_
mov bl,10
cmp al,bl
je l1
mov bl,' '
cmp al,bl
je l1
push eax
inc col1
jmp l1
enter_:
mov bl,col1
mov temp1,bl
mov col1,0
inc row1
jmp l1
check_min:
mov cl,'9'
cmp al,cl
ja if_not_number
sub al,48
mov minimum,al
inc col1
matrix_pushed:
dec temp1
mov bl,temp1
mov col1,bl
mov al,col1
mov bl,row1
checking_flag:
mov bl,1
cmp flag,bl
jne for_finding_esp
for_finding_esp2:
mov eax,0
mov al,col1
mul row1
mov bl,4
mul bl ;each esp is of 4 bytes
mov ebx,eax
mov al,row1
mov cl,4
mul cl
add ebx,eax
sub ebx,4
add esp,ebx
mov al,row1
mov cl,col1
mov stack_pointer_matrix_2,esp
add esp,4
sub esp,ebx
mov al,[esp]
mov esi, offset stack_upwards
mov [esi],ebx
sub esp,4
inc col1
invoke printpuzzle,stack_pointer_matrix_1,row1,col1
call maingame
add esp,stack_upwards
add esp,4
ret
jmp done
for_finding_esp:
mov eax,0
mov al,col1
mul row1
mov bl,4
mul bl ;each esp is of 4 bytes
mov ebx,eax
mov al,row1
mov cl,4
mul cl
add ebx,eax
sub ebx,4
add esp,ebx
mov stack_pointer_matrix_1,esp
sub esp,ebx
invoke setfilepointer, handlee,0,0,file_begin
mov temp1,0
mov flag,1
mov row1,0
call checking_file_empty
add esp,stack_upwards
add esp,4
done:
ret
pushing_matrix endp
maingame proc uses eax ebx ecx edx edi esi ;main screen
mov dl,0
mov dh,7
call gotoxy
mov edx,offset PPoints ;Printing string "Points"
call writestring
call GetMseconds ;Getting number of milliseconds elapsed since midnight
mov edx,0
mov ebx,1000d
div ebx ;Converting those milliseconds into seconds
mov total,eax
mov dl,88
mov dh,7
call gotoxy
mov edx,offset Starting_Time
call writestring ;Printing string "Starting time"
call printtime ;Printing Starting time
mov ebx,1d
imul ebx,120d
add eax,ebx ;Adding additional number of seconds equal to the time provided to the player for that particular level
mov FinishTime,eax
cmp eax,limit ;To see if the finish time has more seconds then the number of seconds present in a typical day
JA great
JMP elfo
great:
sub eax,limit ;Subtracting seconds of a day from the finish time seconds to get how many seconds of the new day will be used
mov FinishTime,eax
elfo:
print:
mov dh,8
mov dl,88
call gotoxy
mov edx,offset Finish_Time
call writestring ;Printing string "Finish time"
call printtime ;Printing Finish time
Mov dl,88
Mov dh,9
Call GotoXY
mov edx,offset Current_Time
call writestring ;Printing String current time
mov dl,0
mov dh,byte ptr[ row1]
add dh,11
call gotoxy
mov edx,offset Enterword
call writestring ;Printing String "Enter a word"
startit: ;Main loop for Game
mov dl,lengthof PPoints
mov dh,7
call gotoxy
mov eax,Points
call writedec ;Printing Points earned uptill now
sub esp,4
mov edi,esp ;Saving the address of first letter of the word searched
add esp,4
mov ecx,0
l1:
Mov dl,88
add dl,lengthof Current_Time
Mov dh,9
Call GotoXY
push ecx ;We have to push because we are also using ecx to save length of the word being entered
mov ecx,0FFFFFFFh ;Producing delay
l2:
loop l2
pop ecx
mov eax,0
call GetMseconds ;Getting number of milliseconds that have elapsed since midnight
mov edx,0
mov ebx,1000d
div ebx ;To convert those milliseconds into seconds
call printtime ;Printing Current time
mov eax,total
cmp eax,FinishTime ;To see if current time is equal to or has passed Finish time that was decided
JAE exitt ;Jump to exit if current time has indeed passed finish time or is equal to it
mov dl,0
add dl,cl
mov dh,byte ptr row1
add dh,12
call gotoxy ;Going back down to continue taking input
mov eax,0
call readkey ;Reading a character
JZ l1
cmp al,13
JE goforsearch ;if character is equal to enter key, then go to search function to see if entered string is present in the matrix or not
cmp al,8
JE looop ; if character is equal to backspace key then jump to looop label
sub esp,4
mov ah,0
mov ebp,esp
inc ecx
mov [ebp],eax
jmp loopp
looop: ;if user pressed backspace key
cmp ecx,0 ;to see if the user has even entered a key
JE loopp ;if user hasn't entered any key yet
dec ecx ;else decrement length of string
add esp,4 ;to overwrite the character that was entered before backspace
mov ebp,esp
loopp:
call writechar
mov eax,0
call writechar
jmp l1
goforsearch: ;If user has entered "ENTER" key
call crlf
mov tempo1,ecx ; to save the length of string(word) entered
mov eax,0
mov edx,0
mov founddd,0
mov esi,edi
mov eax,tempo1
cmp eax,0
je l88
l99:
mov eax,[esi]
mov wordd[edx],eax
mov eax,tempo1
inc edx
sub esi,4
cmp edx,eax
jne l99
l88:
mov edx,0
mov eax,0
mov edx,wordd[0]
mov dic,dl
mov eax,tempo1
mov len1,eax
push eax
push 0
push 0
push 0
call searchh
pop eax
pop eax
pop eax
pop eax
mov eax,handlee
call closefile
mov al,founddd
cmp al,1
jne l77
mov eax,len1
push eax
push 0
push 0
push 0
mov founddd,1
call tempp
pop eax
pop eax
pop eax
pop eax
mov eax,handlee
call closefile
mov al,founddd
cmp al,1
jne l77
mov eax,0
mov edx,0
invoke Search,stack_pointer_matrix_1,stack_pointer_matrix_2,addr [edi],tempo1,0,0,0,0,row1,col1 ;This function will see if the entered string is present in the matrix
call crlf
cmp edx,1 ;edx is working as a flag
JE foundd ;if flag==1 then go to foundd label
l77:
mov edx,offset Notfound ;else print not found message
call writestring
JMP nextt ;jmp to nexxt to search for the next word if time permits
foundd: ;if word was found in the matrix
invoke createfile,addr temppp,generic_write,do_not_share,NULL,open_existing,file_attribute_normal,0
mov handlee,eax
mov ecx,0
invoke setfilepointer, handlee,0,0,file_end
invoke writefile,handlee,offset wordd,len1,addr actual,0
invoke setfilepointer, handlee,0,0,file_end
invoke writefile,handlee,addr mess,1,addr actual,0
mov eax,handlee
call closefile
inc Points ;increment the points
mov edx,offset Found ;print found message
call writestring
nextt: ;preparation for the next word search
mov ecx,tempo1
imul ecx,4
add esp,ecx ;removing the word from string
Jmp startit ;going back to searching a new word
exitt: ;if time is over
mov dl,0
mov dh,byte ptr row1
add dh,14
call gotoxy
mov edx,offset timesup
call writestring ;print timesup message
imul ecx,4
add esp,ecx ;removing the word from string
mov eax,Points
movzx edx,minimum
cmp eax,edx
jb s
mov flaggg,1
s:
ret
maingame endp
printpuzzle proc uses ecx edx eax ebx edi Matrix:ptr dword,Row:dword,Column:dword
mov ecx,7
l110:
mov ebx,119
cmp ecx,4
JE printlevel
jmp else110
printlevel:
mov dl,52
mov dh,3
call gotoxy
mov edx,offset level
call writestring
mov al,level1
sub al,48
call writedec ;printing level number
jmp loop110
else110:
xchg ebx,ecx
l100:
mov eax,42
call writechar
loop l100
xchg ebx,ecx
loop110:
call crlf
loop l110
mov edx,0
mov edi,Matrix ;to print the matrix in the middle
mov eax,column
mov ebx,2
mul ebx
mov middlecoordinate,eax
mov ecx,row
add ecx,2
mov eax,0
mov ebx,7
l112:
mov dl,59
sub dl,byte ptr middlecoordinate
mov dh,bl
call gotoxy
inc ebx
mov edx,Column
xchg edx,ecx
mov eax,124
call writechar
mov eax,32
call writechar
l113:
mov eax,row
add eax,2
cmp edx,eax
JE elsoto
cmp edx,1
JE elsoto
mov eax,[edi]
sub edi,4
JMP loopi
elsoto:
mov eax,0
mov eax,45
loopi:
call writechar ;printing matrix
mov eax,32
call writechar
call writechar
loop l113
mov eax,124
call writechar
xchg edx,ecx
loop l112
ret 12
printpuzzle endp
printtime proc uses eax ecx
mov total,eax ;Total number of seconds elapsed since midnight
mov ebx,3600d
mov edx,0
div ebx ;Dividing seconds by 3600 to get number of hours
mov edx,0
call writedec ;Printing Number of hours
push eax
mov al,':'
call writechar
pop eax
mov hours,eax
imul eax,ebx ;Multiplying hours by 3600 to get the exact number of seconds present in that exact amount of hours
mov edx,0
mov ecx,total
sub ecx,eax ;Subtracting the exact number of seconds by the seconds(that have passed since midnight)
mov eax,ecx
mov ebx,60d
div ebx ;Dividing the subtracted seconds by 60 to get the minutes
call writedec ;printing number of minutes
push eax
mov al,':'
call writechar
pop eax
mov minutes,eax
mov eax,hours ;accessing the hours that we calculated earlier
mov ebx,60d
imul eax,ebx ;multiplying the calculated hours by 60 to get number of minutes
add eax,minutes ;adding the above calculated number of minutes with the number of minutes that we calculated a couple steps earlier
imul eax,ebx ;multiplying the minutes with 60 to get the exact number of seconds present in that exact amount of minutes
mov ecx,total
sub ecx,eax ;subtracting the above calculated seconds from the number of seconds that have elapsed since midnight
mov eax,ecx
call writedec ;printing the number of seconds
mov eax,32
call writechar
ret
printtime endp
Search proc uses ecx arr: ptr dword,tempp:ptr dword,arr2: ptr dword,len:dword,row:dword,col:dword,counter:dword,temprow:dword,endrow:dword,endcol:dword ;printt(char **matrix,char **tempmatrix,char *string,int lengthofstring,int row,int col,int counter,int temprow
mov esi,tempp
mov edi,arr2
cmp temprow,-1
JE returnfalse ;if (row<0) {return false}
mov eax,endrow
cmp temprow,eax
JE returnfalse ;if (row>2) {return false}
mov eax,endcol
cmp col,eax
JE returnfalse ;if (col>4) {return false}
cmp col,-1
JE returnfalse ;if (col<0) {return false}
JMP and1 ;else
returnfalse:
mov edx,2
ret 40
and1: ;if (row!<0 && row!>2 && col!>4 && col!<0)
mov tempo,edi
mov eax,counter
mov ecx,3
quickk:
add eax,counter
loop quickk
sub tempo,eax
xchg tempo,eax
mov eax,[eax]
xchg tempo,eax ;tempo=arr2[counter]
mov eax,row
add eax,col
mov ebx,[esi+eax*4]
cmp ebx,tempo
JE else0 ;JUMP if (temp[row][col]==arr2[counter])
JMP else1 ;else
else0: ;if (temp[row][col]==arr2[counter])
mov eax,len
dec eax
cmp eax,counter
JE lfound ;JUMP if (temp[row][col]==arr2[counter] && counter==len-1)
JMP else2 ;JUMP if (temp[row][col]==arr2[counter] && counter!=len-1)
lfound: ;IF THE SEARCHED WORD IS FOUND IN THE PUZZLE
mov edx,1 ;flag=1
ret 40 ;return
else1: ;if (temp[row][col]!=arr[counter]){
mov eax,ebx
cmp counter,0
JE counterzero ;JUMP if (temp[row][col]!=arr2[counter] && counter==0)
JMP returnfalse ;else if (temp[row][col]!=arr2[counter] && counter!=0){return false}
llfound:
mov eax,row
add eax,col
mov edi,arr
mov ebx,[edi+eax*4]
mov [esi+eax*4],ebx ;temp[row][col]=arr[row][col]
JMP lfound
else2: ; if (temp[row][col]==arr2[counter]{
mov eax,row
add eax,col
mov ebx,1
mov [esi+eax*4],ebx ; temp[row][col]=1; (to eliminate any chance of repetition)
add counter,1
add col,1
invoke Search, arr,tempp,arr2,len,row,col,counter,temprow,endrow,endcol ;col+1 //Search(arr,tempp,len,row,col+1,counter+1,temprow)
sub col,1
sub counter,1
cmp edx,1 ;checking if (flag==1)
JE llfound ; if (flag==1) { return true}
add counter,1
mov eax,endcol
add row,eax
add temprow,1
invoke Search, arr,tempp,arr2,len,row,col,counter,temprow,endrow,endcol ;row+1 //Search(arr,tempp,len,row+1,col,counter+1,temprow+1)
mov eax,endcol
sub row,eax
sub temprow,1
sub counter,1
cmp edx,1 ;checking if (flag==1)
JE llfound ; if (flag==1) { return true}
sub col,1
add counter,1
invoke Search, arr,tempp,arr2,len,row,col,counter,temprow,endrow,endcol ;col-1 //Search(arr,tempp,len,row,col-1,counter+1,temprow)
add col,1
sub counter,1
cmp edx,1 ;checking if (flag==1)
JE llfound ; if (flag==1) { return true}
add counter,1
mov eax,endcol
sub row,eax
sub temprow,1
invoke Search, arr,tempp,arr2,len,row,col,counter,temprow,endrow,endcol ;row-1 //Search(arr,tempp,len,row-1,col,counter+1,temprow-1)
mov eax,endcol
add row,eax
add temprow,1
sub counter,1
cmp edx,1 ;checking if (flag==1)
JE llfound ; if (flag==1) { return true}
add counter,1
mov eax,endcol
add row,eax
add col,1
add temprow,1
invoke Search, arr,tempp,arr2,len,row,col,counter,temprow,endrow,endcol ;row+1,col+1 //Search(arr,tempp,len,row+1,col+1,counter+1,temprow+1)
mov eax,endcol
sub row,eax
sub col,1
sub temprow,1
sub counter,1
cmp edx,1 ;checking if (flag==1)
JE llfound ; if (flag==1) { return true}
add counter,1
mov eax,endcol
sub row,eax
sub col,1
sub temprow,1
invoke Search, arr,tempp,arr2,len,row,col,counter,temprow,endrow,endcol ;row-1,col-1 //Search(arr,tempp,len,row,col-1,counter+1,temprow-1)
mov eax,endcol
add row,eax
add col,1
add temprow,1
sub counter,1
cmp edx,1 ;checking if (flag==1)
JE llfound ; if (flag==1) { return true
add counter,1
mov eax,endcol
add row,eax
sub col,1
add temprow,1
invoke Search, arr,tempp,arr2,len,row,col,counter,temprow,endrow,endcol ;row+1,col-1 //Search(arr,tempp,len,row+1,col-1,counter+1,temprow+1)
mov eax,endcol
sub row,eax
add col,1
sub temprow,1
sub counter,1
cmp edx,1 ;checking if (flag==1)
JE llfound ; if (flag==1) { return true}
add counter,1
mov eax,endcol
sub row,eax
add col,1
sub temprow,1
invoke Search, arr,tempp,arr2,len,row,col,counter,temprow,endrow,endcol ;row-1,col+1 //Search(arr,tempp,len,row-1,col+1,counter+1,temprow-1)
mov eax,endcol
add row,eax
sub col,1
add temprow,1
sub counter,1
cmp edx,1 ;checking if (flag==1)
JE llfound ;if (flag==1) {return true}
mov eax,row
add eax,col
mov edi,arr
mov ebx,[edi+eax*4]
mov [esi+eax*4],ebx ;temp[row][col]=arr[row][col]
checkingcounter:
cmp counter,0
JE counterzero
JMP returnfalse ;if (counter!=0) return false
counterzero: ;if (counter==0){
mov eax,endcol
dec eax
cmp col,eax ;check if if(col==4)
JE lastcol
add col,1 ;else {col+1}
invoke Search, arr,tempp,arr2,len,row,col,0,temprow,endrow,endcol ;Search(arr,tempp,len,row,col+1,counter=0,temprow)
sub col,1
cmp edx,1 ;if (flag==1){
JE returnn ;return true}
JMP returnfalse ;else {return false}
lastcol: ;if(col==4){
mov eax,endcol
add row,eax ;row+1
add temprow,1 ;rownumber+1
invoke Search, arr,tempp,arr2,len,row,0,0,temprow,endrow,endcol ;Search(arr,tempp,len,row+1,col=0,counter=0,temprow+1)
sub temprow,1
mov eax,endcol
sub row,eax
cmp edx,1 ; checking if(flag==1)
JE returnn ;if (flag==1) { return true}
JMP returnfalse ; else {return false}
returnn:
ret 40
Search endp
searchh proc
push ebp
mov ebp,esp
invoke createfile,addr dic,generic_read,do_not_share,NULL,open_existing,file_attribute_normal,0
mov handlee,eax
mov ecx,0
l1:
invoke setfilepointer, handlee,0,0,file_current
invoke readfile,handlee,offset message,1,addr actual,0
mov al,message
cmp al,10
jne p1
mov edx,0
mov ecx,[ebp+12]
mov edx,[ebp+8]
mov ebx,[ebp+16]
cmp ecx,ebx
jne l11
mov ebx,[ebp+20]
cmp ebx,ecx
jne l11
jmp ex1
l11:
mov ebx,0
mov [ebp+16],ebx
mov ecx,0
mov [ebp+12],ecx
inc edx
mov [ebp+8],edx
cmp edx,2
je exitt
jmp l4
p1:
mov edx,0
mov [ebp+8],edx
l4:
cmp al,13
je l5
cmp al,10
je l5
mov edx,[ebp+12]
inc edx
mov [ebp+12],edx
l5:
mov edx,[ebp+16]
mov ebx,wordd[edx]
cmp al,bl
jne l9
inc edx
mov [ebp+16],edx
l9:
jmp l1
ex1:
mov founddd,1
exitt:
leave
ret
searchh endp
tempp proc
push ebp
mov ebp,esp