Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Test_Sudoku PROC
- ; Vladimir Goncharoff
- ; ECE 267: Computer Organization I
- ; University of Illinois at Chicago
- ; Fall 2011 Semester
- ; October 10, 2011
- ;
- ; Solution to Program 2
- ;
- ; EDX passes the address to the Sudoku matrix.
- ; EAX returns 1 if the matrix is legal, or 0 if the matrix is not legal.
- .data
- ; Here is where we keep track of the number of times a given digit
- ; has appeared in a row, column, or sub-square:
- Value_Count BYTE 10 dup(?)
- ; A copy of EDX will be stored here:
- Copy_of_Pointer DWORD ?
- .code
- mov Copy_of_Pointer,edx ; save Copy_of_Pointer to Sudoku matrix
- ;---------------------------------------------------------------------------
- ; check row 0 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,9*0
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+3]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+4]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+5]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+6]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+7]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+8]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check row 1 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,9*1
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+3]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+4]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+5]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+6]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+7]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+8]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check row 2 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,9*2
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+3]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+4]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+5]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+6]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+7]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+8]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check row 3 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,9*3
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+3]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+4]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+5]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+6]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+7]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+8]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check row 4 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,9*4
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+3]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+4]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+5]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+6]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+7]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+8]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check row 5 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,9*5
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+3]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+4]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+5]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+6]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+7]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+8]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check row 6 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,9*6
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+3]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+4]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+5]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+6]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+7]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+8]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check row 7 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,9*7
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+3]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+4]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+5]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+6]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+7]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+8]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check row 8 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,9*8
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+3]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+4]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+5]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+6]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+7]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+8]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check column 0 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,0
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+9] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+27]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+36]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+45]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+54]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+63]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+72]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check column 1 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,1
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+9] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+27]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+36]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+45]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+54]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+63]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+72]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check column 2 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,2
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+9] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+27]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+36]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+45]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+54]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+63]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+72]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check column 3 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,3
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+9] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+27]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+36]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+45]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+54]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+63]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+72]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check column 4 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,4
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+9] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+27]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+36]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+45]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+54]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+63]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+72]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check column 5 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,5
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+9] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+27]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+36]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+45]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+54]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+63]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+72]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check column 6 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,6
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+9] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+27]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+36]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+45]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+54]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+63]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+72]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check column 7 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,7
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+9] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+27]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+36]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+45]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+54]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+63]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+72]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check column 8 for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,8
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+9] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+27]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+36]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+45]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+54]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+63]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+72]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check upper-left sub-square for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,0
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+9]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+10]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+11]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+19]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+20]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check upper-middle sub-square for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,3
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+9]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+10]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+11]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+19]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+20]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check upper-right sub-square for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,6
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+9]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+10]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+11]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+19]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+20]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check middle-left sub-square for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,27
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+9]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+10]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+11]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+19]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+20]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check center sub-square for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,30
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+9]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+10]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+11]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+19]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+20]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check middle-right sub-square for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,33
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+9]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+10]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+11]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+19]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+20]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check lower-left sub-square for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,54
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+9]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+10]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+11]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+19]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+20]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check lower-middle sub-square for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,57
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+9]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+10]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+11]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+19]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+20]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- ; check lower-right sub-square for duplicate digits:
- mov edx,Copy_of_Pointer
- ; add offset for the starting square:
- add edx,60
- ; initialize pointer to Value_Count array:
- mov ebx,OFFSET Value_Count
- ; reset Value_Count array to all zeros:
- mov DWORD PTR [ebx+0],0
- mov DWORD PTR [ebx+4],0
- mov WORD PTR [ebx+8],0
- mov eax,0
- mov al,[edx+0] ; overwrite al (eax) with digit at this square
- inc BYTE PTR [ebx+eax] ; increment counter for this digit
- mov al,[edx+1] ; repeat for each of the remaining 8 squares
- inc BYTE PTR [ebx+eax]
- mov al,[edx+2]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+9]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+10]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+11]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+18]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+19]
- inc BYTE PTR [ebx+eax]
- mov al,[edx+20]
- inc BYTE PTR [ebx+eax]
- ; check to see if any of the counter values exceeds 1:
- .IF (BYTE PTR [ebx+1] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+2] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+3] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+4] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+5] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+6] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+7] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+8] > 1)
- jmp Illegal_Matrix_Detected
- .ELSEIF (BYTE PTR [ebx+9] > 1)
- jmp Illegal_Matrix_Detected
- .ENDIF
- ;---------------------------------------------------------------------------
- Matrix_is_Legal:
- ; If we made it this far, the Sudoku matrix is legal (return EAX = 1).
- mov eax,1
- ret
- Illegal_Matrix_Detected:
- ; An illegal Sudoku matrix was detected (return EAX = 0).
- mov eax,0
- ret
- Test_Sudoku ENDP
Add Comment
Please, Sign In to add comment