write a program to print square matrices of ‘x’. The printing job starts with the left-most corner and proceeds in a spiral way. The program should be paused for 10 milliseconds between printing each two symbols. Below are three snapshots of an execution of the program. (Note the edge length of square is an even number.)
TITLE Example of ProceduresINCLUDE Irvine32.inc.datasymbol= 'x'delay_time = 10space = ' 'iterative byte "ITERATIVE",0recursive byte "RECURSIVE",0.codemain PROC ; displays "ITERATIVE" mov dh, 3 mov dl, 12 call gotoxy mov edx, offset iterative call writestring ; prints the square using iteration mov bl, 10 ; top-left x mov bh, 6 ; top-left y mov al, 25 ; bottom-right x mov ah, 21 ; bottom-right y call spiral_print ; displays "RECURSIVE" mov dh, 3 mov dl, 32 call gotoxy mov edx, offset recursive call writestring mov dh,3 ;find the size of x mov dl,29 ;find the size of y call gotoxy ;go to the start location for recurive ; prints the square using recursion mov bl, 30 ; top-left x mov bh, 6 ; top-left y mov al, 45 ; bottom-right x mov ah, 21 ; bottom-right y call spiral_print_recurs ; moves the cursor for "Press any key to continue" mov dh, 22 mov dl, 10 call gotoxy call waitmsg exitmain ENDP; Receives BL (top-left x), BH (top-left y); AL (bottom-right x), AH (bottom-right y); Precondition: (BL-AL)==(AH-BH), (BL-AL+1) is even; Returns: nothing; Description: Prints a square of constant symbol. The top-left corner of ; the square is (BL, BH). The bottom-right corner of the square; is (AL, AH). The program pauses for constant delay_time milliseconds.; Algorithm: recursionspiral_print_recurs proc USES EAX EBX EDX ECX ESI cmp bl, al ja end_proc ; jumps to the end when bl is greater than bl inc dl ;for next location on one row inc dh ;for next loaction on one column mov cl,al sub cl,bl movzx esi,cl call horizontal_print call vertical_print call horizontal_print_rev call vertical_print_rev sub al,1 add bl,1 call spiral_print_recurs ; implement the rest of the procedureend_proc: retspiral_print_recurs endp; Receives BL (top-left x), BH (top-left y); AL (bottom-right x), AH (bottom-right y); Precondition: (BL-AL)==(AH-BH), (BL-AL+1) is even; Returns: nothing; Description: Prints a square of constant symbol. The top-left corner of ; the square is (BL, BH). The bottom-right corner of the square; is (AL, AH). The program pauses for constant delay_time milliseconds.; Algorithm: iterationspiral_print proc USES EAX EBX EDX ECX ESI mov dh,4 ;find the size of x mov dl,10 ;find the size of y call gotoxy ;go to the first location mov cl, al sub cl, bl movzx esi, cl ;confirm the times of first loop add cl, 1 shr cl, 1 ; divides cl by 2 L5: mov ecx,esi ;the number of loop L1: mov eax,delay_time ;every time print with delay time call gotoxy ;located call delay mov al,symbol ;print * call writechar inc dl ;cursor point next location loop L1 mov ecx,esi ;the number of loop L2: mov eax,delay_time ;every time print with delay time call gotoxy call delay mov al,symbol call writechar inc dh ;cursor point next location loop L2 mov ecx,esiL3: ; it is the same with the before loop mov eax,delay_time ;every time print with delay time call gotoxy call delay mov al,symbol call writechar dec dl loop L3 mov ecx,esiL4: ; mov eax,delay_time ;every time print with delay time call gotoxy call delay mov al,symbol call writechar dec dh loop L4 sub esi,2 ;every time we print a square we also need to subtract ;two js endloop ;judge if print over it will jump inc dl ;for next location on one row inc dh ;for next loaction on one column loop L5endloop: ret ; implement the rest of the procedurespiral_print endp; Receives: DH (row), DL (col), ESI (# of prints); Returns: nothing; Description: prints symbol for ESI times from (DL, DH); each print increments DH vertical_print proc USES ECX EAX ESI mov ecx,esi L1: mov eax,delay_time call gotoxy call delay mov al,symbol ;print * call writechar inc dh ;cursor point next location loop L1 ; implement this procedure retvertical_print endp; Receives: DH (row), DL (col), ESI (# of prints); Returns: nothing; Description: prints symbol for ESI times from (DL, DH) ; each print increments DLhorizontal_print proc USES ECX EAX ESI mov ecx,esi ;the number of loop L2: mov eax,delay_time call gotoxy ;located call delay mov al,symbol ;print * call writechar inc dl ;cursor point next location loop L2 ret ; implement this procedure horizontal_print endp; Receives: DH (row), DL (col), ESI (# of prints); Returns: nothing; Description: prints symbol for ESI times from (DL, DH); each print decrements DH vertical_print_rev proc USES ECX EAX ESI mov ecx,esi L3: mov eax,delay_time call gotoxy call delay mov al,symbol call writechar dec dh ;cursor point next location loop L3 ret ; implement this procedure vertical_print_rev endp; Receives: DH (row), DL (col), ESI (# of prints); Returns: nothing; Description: prints symbol for ESI times from (DL, DH) ; each print decrements DLhorizontal_print_rev proc USES ECX EAX ESI mov ecx,esi ;the number of loop L4: mov eax,delay_time call gotoxy ;located call delay mov al,symbol call writechar dec dl ;cursor point next location loop L4 ret ; implement this procedure horizontal_print_rev endpEND main