Guest User

Untitled

a guest
Apr 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Test_Sudoku PROC
  2.  
  3.     ; Vladimir Goncharoff
  4.     ; ECE 267: Computer Organization I
  5.     ; University of Illinois at Chicago
  6.     ; Fall 2011 Semester
  7.     ; October 10, 2011
  8.     ;
  9.     ; Solution to Program 2
  10.     ;
  11.     ; EDX passes the address to the Sudoku matrix.
  12.     ; EAX returns 1 if the matrix is legal, or 0 if the matrix is not legal.
  13.  
  14.     .data
  15.         ; Here is where we keep track of the number of times a given digit
  16.         ; has appeared in a row, column, or sub-square:
  17.         Value_Count BYTE 10 dup(?)    
  18.  
  19.         ; A copy of EDX will be stored here:
  20.         Copy_of_Pointer DWORD ?
  21.     .code
  22.  
  23.  
  24.     mov Copy_of_Pointer,edx       ; save Copy_of_Pointer to Sudoku matrix
  25.  
  26. ;---------------------------------------------------------------------------
  27.     ; check row 0 for duplicate digits:
  28.  
  29.     mov edx,Copy_of_Pointer
  30.     ; add offset for the starting square:
  31.     add edx,9*0
  32.    
  33.     ; initialize pointer to Value_Count array:
  34.     mov ebx,OFFSET Value_Count
  35.  
  36.     ; reset Value_Count array to all zeros:
  37.     mov DWORD PTR [ebx+0],0
  38.     mov DWORD PTR [ebx+4],0
  39.     mov WORD  PTR [ebx+8],0
  40.  
  41.     mov eax,0
  42.  
  43.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  44.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  45.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  46.     inc BYTE PTR [ebx+eax]
  47.     mov al,[edx+2]
  48.     inc BYTE PTR [ebx+eax]
  49.     mov al,[edx+3]
  50.     inc BYTE PTR [ebx+eax]
  51.     mov al,[edx+4]
  52.     inc BYTE PTR [ebx+eax]
  53.     mov al,[edx+5]
  54.     inc BYTE PTR [ebx+eax]
  55.     mov al,[edx+6]
  56.     inc BYTE PTR [ebx+eax]
  57.     mov al,[edx+7]
  58.     inc BYTE PTR [ebx+eax]
  59.     mov al,[edx+8]
  60.     inc BYTE PTR [ebx+eax]
  61.  
  62.     ; check to see if any of the counter values exceeds 1:
  63.     .IF     (BYTE PTR [ebx+1] > 1)
  64.         jmp Illegal_Matrix_Detected
  65.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  66.         jmp Illegal_Matrix_Detected
  67.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  68.         jmp Illegal_Matrix_Detected
  69.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  70.         jmp Illegal_Matrix_Detected
  71.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  72.         jmp Illegal_Matrix_Detected
  73.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  74.         jmp Illegal_Matrix_Detected
  75.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  76.         jmp Illegal_Matrix_Detected
  77.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  78.         jmp Illegal_Matrix_Detected
  79.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  80.         jmp Illegal_Matrix_Detected
  81.     .ENDIF
  82. ;---------------------------------------------------------------------------
  83.     ; check row 1 for duplicate digits:
  84.  
  85.     mov edx,Copy_of_Pointer
  86.     ; add offset for the starting square:
  87.     add edx,9*1
  88.    
  89.     ; initialize pointer to Value_Count array:
  90.     mov ebx,OFFSET Value_Count
  91.  
  92.     ; reset Value_Count array to all zeros:
  93.     mov DWORD PTR [ebx+0],0
  94.     mov DWORD PTR [ebx+4],0
  95.     mov WORD  PTR [ebx+8],0
  96.  
  97.     mov eax,0
  98.  
  99.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  100.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  101.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  102.     inc BYTE PTR [ebx+eax]
  103.     mov al,[edx+2]
  104.     inc BYTE PTR [ebx+eax]
  105.     mov al,[edx+3]
  106.     inc BYTE PTR [ebx+eax]
  107.     mov al,[edx+4]
  108.     inc BYTE PTR [ebx+eax]
  109.     mov al,[edx+5]
  110.     inc BYTE PTR [ebx+eax]
  111.     mov al,[edx+6]
  112.     inc BYTE PTR [ebx+eax]
  113.     mov al,[edx+7]
  114.     inc BYTE PTR [ebx+eax]
  115.     mov al,[edx+8]
  116.     inc BYTE PTR [ebx+eax]
  117.  
  118.     ; check to see if any of the counter values exceeds 1:
  119.     .IF     (BYTE PTR [ebx+1] > 1)
  120.         jmp Illegal_Matrix_Detected
  121.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  122.         jmp Illegal_Matrix_Detected
  123.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  124.         jmp Illegal_Matrix_Detected
  125.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  126.         jmp Illegal_Matrix_Detected
  127.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  128.         jmp Illegal_Matrix_Detected
  129.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  130.         jmp Illegal_Matrix_Detected
  131.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  132.         jmp Illegal_Matrix_Detected
  133.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  134.         jmp Illegal_Matrix_Detected
  135.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  136.         jmp Illegal_Matrix_Detected
  137.     .ENDIF
  138. ;---------------------------------------------------------------------------
  139.     ; check row 2 for duplicate digits:
  140.  
  141.     mov edx,Copy_of_Pointer
  142.     ; add offset for the starting square:
  143.     add edx,9*2
  144.    
  145.     ; initialize pointer to Value_Count array:
  146.     mov ebx,OFFSET Value_Count
  147.  
  148.     ; reset Value_Count array to all zeros:
  149.     mov DWORD PTR [ebx+0],0
  150.     mov DWORD PTR [ebx+4],0
  151.     mov WORD  PTR [ebx+8],0
  152.  
  153.     mov eax,0
  154.  
  155.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  156.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  157.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  158.     inc BYTE PTR [ebx+eax]
  159.     mov al,[edx+2]
  160.     inc BYTE PTR [ebx+eax]
  161.     mov al,[edx+3]
  162.     inc BYTE PTR [ebx+eax]
  163.     mov al,[edx+4]
  164.     inc BYTE PTR [ebx+eax]
  165.     mov al,[edx+5]
  166.     inc BYTE PTR [ebx+eax]
  167.     mov al,[edx+6]
  168.     inc BYTE PTR [ebx+eax]
  169.     mov al,[edx+7]
  170.     inc BYTE PTR [ebx+eax]
  171.     mov al,[edx+8]
  172.     inc BYTE PTR [ebx+eax]
  173.  
  174.     ; check to see if any of the counter values exceeds 1:
  175.     .IF     (BYTE PTR [ebx+1] > 1)
  176.         jmp Illegal_Matrix_Detected
  177.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  178.         jmp Illegal_Matrix_Detected
  179.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  180.         jmp Illegal_Matrix_Detected
  181.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  182.         jmp Illegal_Matrix_Detected
  183.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  184.         jmp Illegal_Matrix_Detected
  185.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  186.         jmp Illegal_Matrix_Detected
  187.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  188.         jmp Illegal_Matrix_Detected
  189.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  190.         jmp Illegal_Matrix_Detected
  191.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  192.         jmp Illegal_Matrix_Detected
  193.     .ENDIF
  194. ;---------------------------------------------------------------------------
  195.     ; check row 3 for duplicate digits:
  196.  
  197.     mov edx,Copy_of_Pointer
  198.     ; add offset for the starting square:
  199.     add edx,9*3
  200.    
  201.     ; initialize pointer to Value_Count array:
  202.     mov ebx,OFFSET Value_Count
  203.  
  204.     ; reset Value_Count array to all zeros:
  205.     mov DWORD PTR [ebx+0],0
  206.     mov DWORD PTR [ebx+4],0
  207.     mov WORD  PTR [ebx+8],0
  208.  
  209.     mov eax,0
  210.  
  211.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  212.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  213.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  214.     inc BYTE PTR [ebx+eax]
  215.     mov al,[edx+2]
  216.     inc BYTE PTR [ebx+eax]
  217.     mov al,[edx+3]
  218.     inc BYTE PTR [ebx+eax]
  219.     mov al,[edx+4]
  220.     inc BYTE PTR [ebx+eax]
  221.     mov al,[edx+5]
  222.     inc BYTE PTR [ebx+eax]
  223.     mov al,[edx+6]
  224.     inc BYTE PTR [ebx+eax]
  225.     mov al,[edx+7]
  226.     inc BYTE PTR [ebx+eax]
  227.     mov al,[edx+8]
  228.     inc BYTE PTR [ebx+eax]
  229.  
  230.     ; check to see if any of the counter values exceeds 1:
  231.     .IF     (BYTE PTR [ebx+1] > 1)
  232.         jmp Illegal_Matrix_Detected
  233.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  234.         jmp Illegal_Matrix_Detected
  235.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  236.         jmp Illegal_Matrix_Detected
  237.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  238.         jmp Illegal_Matrix_Detected
  239.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  240.         jmp Illegal_Matrix_Detected
  241.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  242.         jmp Illegal_Matrix_Detected
  243.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  244.         jmp Illegal_Matrix_Detected
  245.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  246.         jmp Illegal_Matrix_Detected
  247.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  248.         jmp Illegal_Matrix_Detected
  249.     .ENDIF
  250. ;---------------------------------------------------------------------------
  251.     ; check row 4 for duplicate digits:
  252.  
  253.     mov edx,Copy_of_Pointer
  254.     ; add offset for the starting square:
  255.     add edx,9*4
  256.    
  257.     ; initialize pointer to Value_Count array:
  258.     mov ebx,OFFSET Value_Count
  259.  
  260.     ; reset Value_Count array to all zeros:
  261.     mov DWORD PTR [ebx+0],0
  262.     mov DWORD PTR [ebx+4],0
  263.     mov WORD  PTR [ebx+8],0
  264.  
  265.     mov eax,0
  266.  
  267.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  268.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  269.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  270.     inc BYTE PTR [ebx+eax]
  271.     mov al,[edx+2]
  272.     inc BYTE PTR [ebx+eax]
  273.     mov al,[edx+3]
  274.     inc BYTE PTR [ebx+eax]
  275.     mov al,[edx+4]
  276.     inc BYTE PTR [ebx+eax]
  277.     mov al,[edx+5]
  278.     inc BYTE PTR [ebx+eax]
  279.     mov al,[edx+6]
  280.     inc BYTE PTR [ebx+eax]
  281.     mov al,[edx+7]
  282.     inc BYTE PTR [ebx+eax]
  283.     mov al,[edx+8]
  284.     inc BYTE PTR [ebx+eax]
  285.  
  286.     ; check to see if any of the counter values exceeds 1:
  287.     .IF     (BYTE PTR [ebx+1] > 1)
  288.         jmp Illegal_Matrix_Detected
  289.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  290.         jmp Illegal_Matrix_Detected
  291.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  292.         jmp Illegal_Matrix_Detected
  293.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  294.         jmp Illegal_Matrix_Detected
  295.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  296.         jmp Illegal_Matrix_Detected
  297.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  298.         jmp Illegal_Matrix_Detected
  299.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  300.         jmp Illegal_Matrix_Detected
  301.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  302.         jmp Illegal_Matrix_Detected
  303.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  304.         jmp Illegal_Matrix_Detected
  305.     .ENDIF
  306. ;---------------------------------------------------------------------------
  307.     ; check row 5 for duplicate digits:
  308.  
  309.     mov edx,Copy_of_Pointer
  310.     ; add offset for the starting square:
  311.     add edx,9*5
  312.    
  313.     ; initialize pointer to Value_Count array:
  314.     mov ebx,OFFSET Value_Count
  315.  
  316.     ; reset Value_Count array to all zeros:
  317.     mov DWORD PTR [ebx+0],0
  318.     mov DWORD PTR [ebx+4],0
  319.     mov WORD  PTR [ebx+8],0
  320.  
  321.     mov eax,0
  322.  
  323.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  324.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  325.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  326.     inc BYTE PTR [ebx+eax]
  327.     mov al,[edx+2]
  328.     inc BYTE PTR [ebx+eax]
  329.     mov al,[edx+3]
  330.     inc BYTE PTR [ebx+eax]
  331.     mov al,[edx+4]
  332.     inc BYTE PTR [ebx+eax]
  333.     mov al,[edx+5]
  334.     inc BYTE PTR [ebx+eax]
  335.     mov al,[edx+6]
  336.     inc BYTE PTR [ebx+eax]
  337.     mov al,[edx+7]
  338.     inc BYTE PTR [ebx+eax]
  339.     mov al,[edx+8]
  340.     inc BYTE PTR [ebx+eax]
  341.  
  342.     ; check to see if any of the counter values exceeds 1:
  343.     .IF     (BYTE PTR [ebx+1] > 1)
  344.         jmp Illegal_Matrix_Detected
  345.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  346.         jmp Illegal_Matrix_Detected
  347.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  348.         jmp Illegal_Matrix_Detected
  349.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  350.         jmp Illegal_Matrix_Detected
  351.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  352.         jmp Illegal_Matrix_Detected
  353.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  354.         jmp Illegal_Matrix_Detected
  355.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  356.         jmp Illegal_Matrix_Detected
  357.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  358.         jmp Illegal_Matrix_Detected
  359.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  360.         jmp Illegal_Matrix_Detected
  361.     .ENDIF
  362. ;---------------------------------------------------------------------------
  363.     ; check row 6 for duplicate digits:
  364.  
  365.     mov edx,Copy_of_Pointer
  366.     ; add offset for the starting square:
  367.     add edx,9*6
  368.    
  369.     ; initialize pointer to Value_Count array:
  370.     mov ebx,OFFSET Value_Count
  371.  
  372.     ; reset Value_Count array to all zeros:
  373.     mov DWORD PTR [ebx+0],0
  374.     mov DWORD PTR [ebx+4],0
  375.     mov WORD  PTR [ebx+8],0
  376.  
  377.     mov eax,0
  378.  
  379.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  380.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  381.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  382.     inc BYTE PTR [ebx+eax]
  383.     mov al,[edx+2]
  384.     inc BYTE PTR [ebx+eax]
  385.     mov al,[edx+3]
  386.     inc BYTE PTR [ebx+eax]
  387.     mov al,[edx+4]
  388.     inc BYTE PTR [ebx+eax]
  389.     mov al,[edx+5]
  390.     inc BYTE PTR [ebx+eax]
  391.     mov al,[edx+6]
  392.     inc BYTE PTR [ebx+eax]
  393.     mov al,[edx+7]
  394.     inc BYTE PTR [ebx+eax]
  395.     mov al,[edx+8]
  396.     inc BYTE PTR [ebx+eax]
  397.  
  398.     ; check to see if any of the counter values exceeds 1:
  399.     .IF     (BYTE PTR [ebx+1] > 1)
  400.         jmp Illegal_Matrix_Detected
  401.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  402.         jmp Illegal_Matrix_Detected
  403.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  404.         jmp Illegal_Matrix_Detected
  405.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  406.         jmp Illegal_Matrix_Detected
  407.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  408.         jmp Illegal_Matrix_Detected
  409.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  410.         jmp Illegal_Matrix_Detected
  411.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  412.         jmp Illegal_Matrix_Detected
  413.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  414.         jmp Illegal_Matrix_Detected
  415.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  416.         jmp Illegal_Matrix_Detected
  417.     .ENDIF
  418. ;---------------------------------------------------------------------------
  419.     ; check row 7 for duplicate digits:
  420.  
  421.     mov edx,Copy_of_Pointer
  422.     ; add offset for the starting square:
  423.     add edx,9*7
  424.    
  425.     ; initialize pointer to Value_Count array:
  426.     mov ebx,OFFSET Value_Count
  427.  
  428.     ; reset Value_Count array to all zeros:
  429.     mov DWORD PTR [ebx+0],0
  430.     mov DWORD PTR [ebx+4],0
  431.     mov WORD  PTR [ebx+8],0
  432.  
  433.     mov eax,0
  434.  
  435.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  436.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  437.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  438.     inc BYTE PTR [ebx+eax]
  439.     mov al,[edx+2]
  440.     inc BYTE PTR [ebx+eax]
  441.     mov al,[edx+3]
  442.     inc BYTE PTR [ebx+eax]
  443.     mov al,[edx+4]
  444.     inc BYTE PTR [ebx+eax]
  445.     mov al,[edx+5]
  446.     inc BYTE PTR [ebx+eax]
  447.     mov al,[edx+6]
  448.     inc BYTE PTR [ebx+eax]
  449.     mov al,[edx+7]
  450.     inc BYTE PTR [ebx+eax]
  451.     mov al,[edx+8]
  452.     inc BYTE PTR [ebx+eax]
  453.  
  454.     ; check to see if any of the counter values exceeds 1:
  455.     .IF     (BYTE PTR [ebx+1] > 1)
  456.         jmp Illegal_Matrix_Detected
  457.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  458.         jmp Illegal_Matrix_Detected
  459.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  460.         jmp Illegal_Matrix_Detected
  461.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  462.         jmp Illegal_Matrix_Detected
  463.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  464.         jmp Illegal_Matrix_Detected
  465.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  466.         jmp Illegal_Matrix_Detected
  467.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  468.         jmp Illegal_Matrix_Detected
  469.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  470.         jmp Illegal_Matrix_Detected
  471.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  472.         jmp Illegal_Matrix_Detected
  473.     .ENDIF
  474. ;---------------------------------------------------------------------------
  475.     ; check row 8 for duplicate digits:
  476.  
  477.     mov edx,Copy_of_Pointer
  478.     ; add offset for the starting square:
  479.     add edx,9*8
  480.    
  481.     ; initialize pointer to Value_Count array:
  482.     mov ebx,OFFSET Value_Count
  483.  
  484.     ; reset Value_Count array to all zeros:
  485.     mov DWORD PTR [ebx+0],0
  486.     mov DWORD PTR [ebx+4],0
  487.     mov WORD  PTR [ebx+8],0
  488.  
  489.     mov eax,0
  490.  
  491.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  492.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  493.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  494.     inc BYTE PTR [ebx+eax]
  495.     mov al,[edx+2]
  496.     inc BYTE PTR [ebx+eax]
  497.     mov al,[edx+3]
  498.     inc BYTE PTR [ebx+eax]
  499.     mov al,[edx+4]
  500.     inc BYTE PTR [ebx+eax]
  501.     mov al,[edx+5]
  502.     inc BYTE PTR [ebx+eax]
  503.     mov al,[edx+6]
  504.     inc BYTE PTR [ebx+eax]
  505.     mov al,[edx+7]
  506.     inc BYTE PTR [ebx+eax]
  507.     mov al,[edx+8]
  508.     inc BYTE PTR [ebx+eax]
  509.  
  510.     ; check to see if any of the counter values exceeds 1:
  511.     .IF     (BYTE PTR [ebx+1] > 1)
  512.         jmp Illegal_Matrix_Detected
  513.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  514.         jmp Illegal_Matrix_Detected
  515.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  516.         jmp Illegal_Matrix_Detected
  517.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  518.         jmp Illegal_Matrix_Detected
  519.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  520.         jmp Illegal_Matrix_Detected
  521.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  522.         jmp Illegal_Matrix_Detected
  523.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  524.         jmp Illegal_Matrix_Detected
  525.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  526.         jmp Illegal_Matrix_Detected
  527.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  528.         jmp Illegal_Matrix_Detected
  529.     .ENDIF
  530. ;---------------------------------------------------------------------------
  531.     ; check column 0 for duplicate digits:
  532.  
  533.     mov edx,Copy_of_Pointer
  534.     ; add offset for the starting square:
  535.     add edx,0
  536.    
  537.     ; initialize pointer to Value_Count array:
  538.     mov ebx,OFFSET Value_Count
  539.  
  540.     ; reset Value_Count array to all zeros:
  541.     mov DWORD PTR [ebx+0],0
  542.     mov DWORD PTR [ebx+4],0
  543.     mov WORD  PTR [ebx+8],0
  544.  
  545.     mov eax,0
  546.  
  547.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  548.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  549.     mov al,[edx+9]               ; repeat for each of the remaining 8 squares
  550.     inc BYTE PTR [ebx+eax]
  551.     mov al,[edx+18]
  552.     inc BYTE PTR [ebx+eax]
  553.     mov al,[edx+27]
  554.     inc BYTE PTR [ebx+eax]
  555.     mov al,[edx+36]
  556.     inc BYTE PTR [ebx+eax]
  557.     mov al,[edx+45]
  558.     inc BYTE PTR [ebx+eax]
  559.     mov al,[edx+54]
  560.     inc BYTE PTR [ebx+eax]
  561.     mov al,[edx+63]
  562.     inc BYTE PTR [ebx+eax]
  563.     mov al,[edx+72]
  564.     inc BYTE PTR [ebx+eax]
  565.  
  566.     ; check to see if any of the counter values exceeds 1:
  567.     .IF     (BYTE PTR [ebx+1] > 1)
  568.         jmp Illegal_Matrix_Detected
  569.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  570.         jmp Illegal_Matrix_Detected
  571.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  572.         jmp Illegal_Matrix_Detected
  573.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  574.         jmp Illegal_Matrix_Detected
  575.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  576.         jmp Illegal_Matrix_Detected
  577.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  578.         jmp Illegal_Matrix_Detected
  579.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  580.         jmp Illegal_Matrix_Detected
  581.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  582.         jmp Illegal_Matrix_Detected
  583.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  584.         jmp Illegal_Matrix_Detected
  585.     .ENDIF
  586. ;---------------------------------------------------------------------------
  587.     ; check column 1 for duplicate digits:
  588.  
  589.     mov edx,Copy_of_Pointer
  590.     ; add offset for the starting square:
  591.     add edx,1
  592.    
  593.     ; initialize pointer to Value_Count array:
  594.     mov ebx,OFFSET Value_Count
  595.  
  596.     ; reset Value_Count array to all zeros:
  597.     mov DWORD PTR [ebx+0],0
  598.     mov DWORD PTR [ebx+4],0
  599.     mov WORD  PTR [ebx+8],0
  600.  
  601.     mov eax,0
  602.  
  603.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  604.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  605.     mov al,[edx+9]               ; repeat for each of the remaining 8 squares
  606.     inc BYTE PTR [ebx+eax]
  607.     mov al,[edx+18]
  608.     inc BYTE PTR [ebx+eax]
  609.     mov al,[edx+27]
  610.     inc BYTE PTR [ebx+eax]
  611.     mov al,[edx+36]
  612.     inc BYTE PTR [ebx+eax]
  613.     mov al,[edx+45]
  614.     inc BYTE PTR [ebx+eax]
  615.     mov al,[edx+54]
  616.     inc BYTE PTR [ebx+eax]
  617.     mov al,[edx+63]
  618.     inc BYTE PTR [ebx+eax]
  619.     mov al,[edx+72]
  620.     inc BYTE PTR [ebx+eax]
  621.  
  622.     ; check to see if any of the counter values exceeds 1:
  623.     .IF     (BYTE PTR [ebx+1] > 1)
  624.         jmp Illegal_Matrix_Detected
  625.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  626.         jmp Illegal_Matrix_Detected
  627.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  628.         jmp Illegal_Matrix_Detected
  629.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  630.         jmp Illegal_Matrix_Detected
  631.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  632.         jmp Illegal_Matrix_Detected
  633.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  634.         jmp Illegal_Matrix_Detected
  635.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  636.         jmp Illegal_Matrix_Detected
  637.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  638.         jmp Illegal_Matrix_Detected
  639.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  640.         jmp Illegal_Matrix_Detected
  641.     .ENDIF
  642. ;---------------------------------------------------------------------------
  643.     ; check column 2 for duplicate digits:
  644.  
  645.     mov edx,Copy_of_Pointer
  646.     ; add offset for the starting square:
  647.     add edx,2
  648.    
  649.     ; initialize pointer to Value_Count array:
  650.     mov ebx,OFFSET Value_Count
  651.  
  652.     ; reset Value_Count array to all zeros:
  653.     mov DWORD PTR [ebx+0],0
  654.     mov DWORD PTR [ebx+4],0
  655.     mov WORD  PTR [ebx+8],0
  656.  
  657.     mov eax,0
  658.  
  659.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  660.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  661.     mov al,[edx+9]               ; repeat for each of the remaining 8 squares
  662.     inc BYTE PTR [ebx+eax]
  663.     mov al,[edx+18]
  664.     inc BYTE PTR [ebx+eax]
  665.     mov al,[edx+27]
  666.     inc BYTE PTR [ebx+eax]
  667.     mov al,[edx+36]
  668.     inc BYTE PTR [ebx+eax]
  669.     mov al,[edx+45]
  670.     inc BYTE PTR [ebx+eax]
  671.     mov al,[edx+54]
  672.     inc BYTE PTR [ebx+eax]
  673.     mov al,[edx+63]
  674.     inc BYTE PTR [ebx+eax]
  675.     mov al,[edx+72]
  676.     inc BYTE PTR [ebx+eax]
  677.  
  678.     ; check to see if any of the counter values exceeds 1:
  679.     .IF     (BYTE PTR [ebx+1] > 1)
  680.         jmp Illegal_Matrix_Detected
  681.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  682.         jmp Illegal_Matrix_Detected
  683.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  684.         jmp Illegal_Matrix_Detected
  685.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  686.         jmp Illegal_Matrix_Detected
  687.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  688.         jmp Illegal_Matrix_Detected
  689.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  690.         jmp Illegal_Matrix_Detected
  691.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  692.         jmp Illegal_Matrix_Detected
  693.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  694.         jmp Illegal_Matrix_Detected
  695.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  696.         jmp Illegal_Matrix_Detected
  697.     .ENDIF
  698. ;---------------------------------------------------------------------------
  699.     ; check column 3 for duplicate digits:
  700.  
  701.     mov edx,Copy_of_Pointer
  702.     ; add offset for the starting square:
  703.     add edx,3
  704.    
  705.     ; initialize pointer to Value_Count array:
  706.     mov ebx,OFFSET Value_Count
  707.  
  708.     ; reset Value_Count array to all zeros:
  709.     mov DWORD PTR [ebx+0],0
  710.     mov DWORD PTR [ebx+4],0
  711.     mov WORD  PTR [ebx+8],0
  712.  
  713.     mov eax,0
  714.  
  715.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  716.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  717.     mov al,[edx+9]               ; repeat for each of the remaining 8 squares
  718.     inc BYTE PTR [ebx+eax]
  719.     mov al,[edx+18]
  720.     inc BYTE PTR [ebx+eax]
  721.     mov al,[edx+27]
  722.     inc BYTE PTR [ebx+eax]
  723.     mov al,[edx+36]
  724.     inc BYTE PTR [ebx+eax]
  725.     mov al,[edx+45]
  726.     inc BYTE PTR [ebx+eax]
  727.     mov al,[edx+54]
  728.     inc BYTE PTR [ebx+eax]
  729.     mov al,[edx+63]
  730.     inc BYTE PTR [ebx+eax]
  731.     mov al,[edx+72]
  732.     inc BYTE PTR [ebx+eax]
  733.  
  734.     ; check to see if any of the counter values exceeds 1:
  735.     .IF     (BYTE PTR [ebx+1] > 1)
  736.         jmp Illegal_Matrix_Detected
  737.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  738.         jmp Illegal_Matrix_Detected
  739.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  740.         jmp Illegal_Matrix_Detected
  741.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  742.         jmp Illegal_Matrix_Detected
  743.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  744.         jmp Illegal_Matrix_Detected
  745.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  746.         jmp Illegal_Matrix_Detected
  747.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  748.         jmp Illegal_Matrix_Detected
  749.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  750.         jmp Illegal_Matrix_Detected
  751.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  752.         jmp Illegal_Matrix_Detected
  753.     .ENDIF
  754. ;---------------------------------------------------------------------------
  755.     ; check column 4 for duplicate digits:
  756.  
  757.     mov edx,Copy_of_Pointer
  758.     ; add offset for the starting square:
  759.     add edx,4
  760.    
  761.     ; initialize pointer to Value_Count array:
  762.     mov ebx,OFFSET Value_Count
  763.  
  764.     ; reset Value_Count array to all zeros:
  765.     mov DWORD PTR [ebx+0],0
  766.     mov DWORD PTR [ebx+4],0
  767.     mov WORD  PTR [ebx+8],0
  768.  
  769.     mov eax,0
  770.  
  771.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  772.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  773.     mov al,[edx+9]               ; repeat for each of the remaining 8 squares
  774.     inc BYTE PTR [ebx+eax]
  775.     mov al,[edx+18]
  776.     inc BYTE PTR [ebx+eax]
  777.     mov al,[edx+27]
  778.     inc BYTE PTR [ebx+eax]
  779.     mov al,[edx+36]
  780.     inc BYTE PTR [ebx+eax]
  781.     mov al,[edx+45]
  782.     inc BYTE PTR [ebx+eax]
  783.     mov al,[edx+54]
  784.     inc BYTE PTR [ebx+eax]
  785.     mov al,[edx+63]
  786.     inc BYTE PTR [ebx+eax]
  787.     mov al,[edx+72]
  788.     inc BYTE PTR [ebx+eax]
  789.  
  790.     ; check to see if any of the counter values exceeds 1:
  791.     .IF     (BYTE PTR [ebx+1] > 1)
  792.         jmp Illegal_Matrix_Detected
  793.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  794.         jmp Illegal_Matrix_Detected
  795.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  796.         jmp Illegal_Matrix_Detected
  797.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  798.         jmp Illegal_Matrix_Detected
  799.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  800.         jmp Illegal_Matrix_Detected
  801.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  802.         jmp Illegal_Matrix_Detected
  803.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  804.         jmp Illegal_Matrix_Detected
  805.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  806.         jmp Illegal_Matrix_Detected
  807.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  808.         jmp Illegal_Matrix_Detected
  809.     .ENDIF
  810. ;---------------------------------------------------------------------------
  811.     ; check column 5 for duplicate digits:
  812.  
  813.     mov edx,Copy_of_Pointer
  814.     ; add offset for the starting square:
  815.     add edx,5
  816.    
  817.     ; initialize pointer to Value_Count array:
  818.     mov ebx,OFFSET Value_Count
  819.  
  820.     ; reset Value_Count array to all zeros:
  821.     mov DWORD PTR [ebx+0],0
  822.     mov DWORD PTR [ebx+4],0
  823.     mov WORD  PTR [ebx+8],0
  824.  
  825.     mov eax,0
  826.  
  827.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  828.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  829.     mov al,[edx+9]               ; repeat for each of the remaining 8 squares
  830.     inc BYTE PTR [ebx+eax]
  831.     mov al,[edx+18]
  832.     inc BYTE PTR [ebx+eax]
  833.     mov al,[edx+27]
  834.     inc BYTE PTR [ebx+eax]
  835.     mov al,[edx+36]
  836.     inc BYTE PTR [ebx+eax]
  837.     mov al,[edx+45]
  838.     inc BYTE PTR [ebx+eax]
  839.     mov al,[edx+54]
  840.     inc BYTE PTR [ebx+eax]
  841.     mov al,[edx+63]
  842.     inc BYTE PTR [ebx+eax]
  843.     mov al,[edx+72]
  844.     inc BYTE PTR [ebx+eax]
  845.  
  846.     ; check to see if any of the counter values exceeds 1:
  847.     .IF     (BYTE PTR [ebx+1] > 1)
  848.         jmp Illegal_Matrix_Detected
  849.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  850.         jmp Illegal_Matrix_Detected
  851.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  852.         jmp Illegal_Matrix_Detected
  853.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  854.         jmp Illegal_Matrix_Detected
  855.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  856.         jmp Illegal_Matrix_Detected
  857.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  858.         jmp Illegal_Matrix_Detected
  859.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  860.         jmp Illegal_Matrix_Detected
  861.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  862.         jmp Illegal_Matrix_Detected
  863.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  864.         jmp Illegal_Matrix_Detected
  865.     .ENDIF
  866. ;---------------------------------------------------------------------------
  867.     ; check column 6 for duplicate digits:
  868.  
  869.     mov edx,Copy_of_Pointer
  870.     ; add offset for the starting square:
  871.     add edx,6
  872.    
  873.     ; initialize pointer to Value_Count array:
  874.     mov ebx,OFFSET Value_Count
  875.  
  876.     ; reset Value_Count array to all zeros:
  877.     mov DWORD PTR [ebx+0],0
  878.     mov DWORD PTR [ebx+4],0
  879.     mov WORD  PTR [ebx+8],0
  880.  
  881.     mov eax,0
  882.  
  883.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  884.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  885.     mov al,[edx+9]               ; repeat for each of the remaining 8 squares
  886.     inc BYTE PTR [ebx+eax]
  887.     mov al,[edx+18]
  888.     inc BYTE PTR [ebx+eax]
  889.     mov al,[edx+27]
  890.     inc BYTE PTR [ebx+eax]
  891.     mov al,[edx+36]
  892.     inc BYTE PTR [ebx+eax]
  893.     mov al,[edx+45]
  894.     inc BYTE PTR [ebx+eax]
  895.     mov al,[edx+54]
  896.     inc BYTE PTR [ebx+eax]
  897.     mov al,[edx+63]
  898.     inc BYTE PTR [ebx+eax]
  899.     mov al,[edx+72]
  900.     inc BYTE PTR [ebx+eax]
  901.  
  902.     ; check to see if any of the counter values exceeds 1:
  903.     .IF     (BYTE PTR [ebx+1] > 1)
  904.         jmp Illegal_Matrix_Detected
  905.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  906.         jmp Illegal_Matrix_Detected
  907.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  908.         jmp Illegal_Matrix_Detected
  909.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  910.         jmp Illegal_Matrix_Detected
  911.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  912.         jmp Illegal_Matrix_Detected
  913.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  914.         jmp Illegal_Matrix_Detected
  915.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  916.         jmp Illegal_Matrix_Detected
  917.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  918.         jmp Illegal_Matrix_Detected
  919.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  920.         jmp Illegal_Matrix_Detected
  921.     .ENDIF
  922. ;---------------------------------------------------------------------------
  923.     ; check column 7 for duplicate digits:
  924.  
  925.     mov edx,Copy_of_Pointer
  926.     ; add offset for the starting square:
  927.     add edx,7
  928.    
  929.     ; initialize pointer to Value_Count array:
  930.     mov ebx,OFFSET Value_Count
  931.  
  932.     ; reset Value_Count array to all zeros:
  933.     mov DWORD PTR [ebx+0],0
  934.     mov DWORD PTR [ebx+4],0
  935.     mov WORD  PTR [ebx+8],0
  936.  
  937.     mov eax,0
  938.  
  939.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  940.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  941.     mov al,[edx+9]               ; repeat for each of the remaining 8 squares
  942.     inc BYTE PTR [ebx+eax]
  943.     mov al,[edx+18]
  944.     inc BYTE PTR [ebx+eax]
  945.     mov al,[edx+27]
  946.     inc BYTE PTR [ebx+eax]
  947.     mov al,[edx+36]
  948.     inc BYTE PTR [ebx+eax]
  949.     mov al,[edx+45]
  950.     inc BYTE PTR [ebx+eax]
  951.     mov al,[edx+54]
  952.     inc BYTE PTR [ebx+eax]
  953.     mov al,[edx+63]
  954.     inc BYTE PTR [ebx+eax]
  955.     mov al,[edx+72]
  956.     inc BYTE PTR [ebx+eax]
  957.  
  958.     ; check to see if any of the counter values exceeds 1:
  959.     .IF     (BYTE PTR [ebx+1] > 1)
  960.         jmp Illegal_Matrix_Detected
  961.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  962.         jmp Illegal_Matrix_Detected
  963.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  964.         jmp Illegal_Matrix_Detected
  965.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  966.         jmp Illegal_Matrix_Detected
  967.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  968.         jmp Illegal_Matrix_Detected
  969.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  970.         jmp Illegal_Matrix_Detected
  971.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  972.         jmp Illegal_Matrix_Detected
  973.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  974.         jmp Illegal_Matrix_Detected
  975.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  976.         jmp Illegal_Matrix_Detected
  977.     .ENDIF
  978. ;---------------------------------------------------------------------------
  979.     ; check column 8 for duplicate digits:
  980.  
  981.     mov edx,Copy_of_Pointer
  982.     ; add offset for the starting square:
  983.     add edx,8
  984.    
  985.     ; initialize pointer to Value_Count array:
  986.     mov ebx,OFFSET Value_Count
  987.  
  988.     ; reset Value_Count array to all zeros:
  989.     mov DWORD PTR [ebx+0],0
  990.     mov DWORD PTR [ebx+4],0
  991.     mov WORD  PTR [ebx+8],0
  992.  
  993.     mov eax,0
  994.  
  995.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  996.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  997.     mov al,[edx+9]               ; repeat for each of the remaining 8 squares
  998.     inc BYTE PTR [ebx+eax]
  999.     mov al,[edx+18]
  1000.     inc BYTE PTR [ebx+eax]
  1001.     mov al,[edx+27]
  1002.     inc BYTE PTR [ebx+eax]
  1003.     mov al,[edx+36]
  1004.     inc BYTE PTR [ebx+eax]
  1005.     mov al,[edx+45]
  1006.     inc BYTE PTR [ebx+eax]
  1007.     mov al,[edx+54]
  1008.     inc BYTE PTR [ebx+eax]
  1009.     mov al,[edx+63]
  1010.     inc BYTE PTR [ebx+eax]
  1011.     mov al,[edx+72]
  1012.     inc BYTE PTR [ebx+eax]
  1013.  
  1014.     ; check to see if any of the counter values exceeds 1:
  1015.     .IF     (BYTE PTR [ebx+1] > 1)
  1016.         jmp Illegal_Matrix_Detected
  1017.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1018.         jmp Illegal_Matrix_Detected
  1019.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1020.         jmp Illegal_Matrix_Detected
  1021.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1022.         jmp Illegal_Matrix_Detected
  1023.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1024.         jmp Illegal_Matrix_Detected
  1025.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1026.         jmp Illegal_Matrix_Detected
  1027.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1028.         jmp Illegal_Matrix_Detected
  1029.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1030.         jmp Illegal_Matrix_Detected
  1031.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1032.         jmp Illegal_Matrix_Detected
  1033.     .ENDIF
  1034. ;---------------------------------------------------------------------------
  1035.     ; check upper-left sub-square for duplicate digits:
  1036.  
  1037.     mov edx,Copy_of_Pointer
  1038.     ; add offset for the starting square:
  1039.     add edx,0
  1040.    
  1041.     ; initialize pointer to Value_Count array:
  1042.     mov ebx,OFFSET Value_Count
  1043.  
  1044.     ; reset Value_Count array to all zeros:
  1045.     mov DWORD PTR [ebx+0],0
  1046.     mov DWORD PTR [ebx+4],0
  1047.     mov WORD  PTR [ebx+8],0
  1048.  
  1049.     mov eax,0
  1050.  
  1051.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  1052.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  1053.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  1054.     inc BYTE PTR [ebx+eax]
  1055.     mov al,[edx+2]
  1056.     inc BYTE PTR [ebx+eax]
  1057.     mov al,[edx+9]
  1058.     inc BYTE PTR [ebx+eax]
  1059.     mov al,[edx+10]
  1060.     inc BYTE PTR [ebx+eax]
  1061.     mov al,[edx+11]
  1062.     inc BYTE PTR [ebx+eax]
  1063.     mov al,[edx+18]
  1064.     inc BYTE PTR [ebx+eax]
  1065.     mov al,[edx+19]
  1066.     inc BYTE PTR [ebx+eax]
  1067.     mov al,[edx+20]
  1068.     inc BYTE PTR [ebx+eax]
  1069.  
  1070.     ; check to see if any of the counter values exceeds 1:
  1071.     .IF     (BYTE PTR [ebx+1] > 1)
  1072.         jmp Illegal_Matrix_Detected
  1073.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1074.         jmp Illegal_Matrix_Detected
  1075.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1076.         jmp Illegal_Matrix_Detected
  1077.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1078.         jmp Illegal_Matrix_Detected
  1079.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1080.         jmp Illegal_Matrix_Detected
  1081.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1082.         jmp Illegal_Matrix_Detected
  1083.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1084.         jmp Illegal_Matrix_Detected
  1085.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1086.         jmp Illegal_Matrix_Detected
  1087.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1088.         jmp Illegal_Matrix_Detected
  1089.     .ENDIF
  1090. ;---------------------------------------------------------------------------
  1091.     ; check upper-middle sub-square for duplicate digits:
  1092.  
  1093.     mov edx,Copy_of_Pointer
  1094.     ; add offset for the starting square:
  1095.     add edx,3
  1096.    
  1097.     ; initialize pointer to Value_Count array:
  1098.     mov ebx,OFFSET Value_Count
  1099.  
  1100.     ; reset Value_Count array to all zeros:
  1101.     mov DWORD PTR [ebx+0],0
  1102.     mov DWORD PTR [ebx+4],0
  1103.     mov WORD  PTR [ebx+8],0
  1104.  
  1105.     mov eax,0
  1106.  
  1107.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  1108.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  1109.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  1110.     inc BYTE PTR [ebx+eax]
  1111.     mov al,[edx+2]
  1112.     inc BYTE PTR [ebx+eax]
  1113.     mov al,[edx+9]
  1114.     inc BYTE PTR [ebx+eax]
  1115.     mov al,[edx+10]
  1116.     inc BYTE PTR [ebx+eax]
  1117.     mov al,[edx+11]
  1118.     inc BYTE PTR [ebx+eax]
  1119.     mov al,[edx+18]
  1120.     inc BYTE PTR [ebx+eax]
  1121.     mov al,[edx+19]
  1122.     inc BYTE PTR [ebx+eax]
  1123.     mov al,[edx+20]
  1124.     inc BYTE PTR [ebx+eax]
  1125.  
  1126.     ; check to see if any of the counter values exceeds 1:
  1127.     .IF     (BYTE PTR [ebx+1] > 1)
  1128.         jmp Illegal_Matrix_Detected
  1129.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1130.         jmp Illegal_Matrix_Detected
  1131.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1132.         jmp Illegal_Matrix_Detected
  1133.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1134.         jmp Illegal_Matrix_Detected
  1135.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1136.         jmp Illegal_Matrix_Detected
  1137.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1138.         jmp Illegal_Matrix_Detected
  1139.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1140.         jmp Illegal_Matrix_Detected
  1141.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1142.         jmp Illegal_Matrix_Detected
  1143.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1144.         jmp Illegal_Matrix_Detected
  1145.     .ENDIF
  1146. ;---------------------------------------------------------------------------
  1147.     ; check upper-right sub-square for duplicate digits:
  1148.  
  1149.     mov edx,Copy_of_Pointer
  1150.     ; add offset for the starting square:
  1151.     add edx,6
  1152.    
  1153.     ; initialize pointer to Value_Count array:
  1154.     mov ebx,OFFSET Value_Count
  1155.  
  1156.     ; reset Value_Count array to all zeros:
  1157.     mov DWORD PTR [ebx+0],0
  1158.     mov DWORD PTR [ebx+4],0
  1159.     mov WORD  PTR [ebx+8],0
  1160.  
  1161.     mov eax,0
  1162.  
  1163.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  1164.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  1165.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  1166.     inc BYTE PTR [ebx+eax]
  1167.     mov al,[edx+2]
  1168.     inc BYTE PTR [ebx+eax]
  1169.     mov al,[edx+9]
  1170.     inc BYTE PTR [ebx+eax]
  1171.     mov al,[edx+10]
  1172.     inc BYTE PTR [ebx+eax]
  1173.     mov al,[edx+11]
  1174.     inc BYTE PTR [ebx+eax]
  1175.     mov al,[edx+18]
  1176.     inc BYTE PTR [ebx+eax]
  1177.     mov al,[edx+19]
  1178.     inc BYTE PTR [ebx+eax]
  1179.     mov al,[edx+20]
  1180.     inc BYTE PTR [ebx+eax]
  1181.  
  1182.     ; check to see if any of the counter values exceeds 1:
  1183.     .IF     (BYTE PTR [ebx+1] > 1)
  1184.         jmp Illegal_Matrix_Detected
  1185.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1186.         jmp Illegal_Matrix_Detected
  1187.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1188.         jmp Illegal_Matrix_Detected
  1189.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1190.         jmp Illegal_Matrix_Detected
  1191.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1192.         jmp Illegal_Matrix_Detected
  1193.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1194.         jmp Illegal_Matrix_Detected
  1195.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1196.         jmp Illegal_Matrix_Detected
  1197.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1198.         jmp Illegal_Matrix_Detected
  1199.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1200.         jmp Illegal_Matrix_Detected
  1201.     .ENDIF
  1202. ;---------------------------------------------------------------------------
  1203.     ; check middle-left sub-square for duplicate digits:
  1204.  
  1205.     mov edx,Copy_of_Pointer
  1206.     ; add offset for the starting square:
  1207.     add edx,27
  1208.    
  1209.     ; initialize pointer to Value_Count array:
  1210.     mov ebx,OFFSET Value_Count
  1211.  
  1212.     ; reset Value_Count array to all zeros:
  1213.     mov DWORD PTR [ebx+0],0
  1214.     mov DWORD PTR [ebx+4],0
  1215.     mov WORD  PTR [ebx+8],0
  1216.  
  1217.     mov eax,0
  1218.  
  1219.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  1220.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  1221.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  1222.     inc BYTE PTR [ebx+eax]
  1223.     mov al,[edx+2]
  1224.     inc BYTE PTR [ebx+eax]
  1225.     mov al,[edx+9]
  1226.     inc BYTE PTR [ebx+eax]
  1227.     mov al,[edx+10]
  1228.     inc BYTE PTR [ebx+eax]
  1229.     mov al,[edx+11]
  1230.     inc BYTE PTR [ebx+eax]
  1231.     mov al,[edx+18]
  1232.     inc BYTE PTR [ebx+eax]
  1233.     mov al,[edx+19]
  1234.     inc BYTE PTR [ebx+eax]
  1235.     mov al,[edx+20]
  1236.     inc BYTE PTR [ebx+eax]
  1237.  
  1238.     ; check to see if any of the counter values exceeds 1:
  1239.     .IF     (BYTE PTR [ebx+1] > 1)
  1240.         jmp Illegal_Matrix_Detected
  1241.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1242.         jmp Illegal_Matrix_Detected
  1243.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1244.         jmp Illegal_Matrix_Detected
  1245.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1246.         jmp Illegal_Matrix_Detected
  1247.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1248.         jmp Illegal_Matrix_Detected
  1249.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1250.         jmp Illegal_Matrix_Detected
  1251.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1252.         jmp Illegal_Matrix_Detected
  1253.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1254.         jmp Illegal_Matrix_Detected
  1255.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1256.         jmp Illegal_Matrix_Detected
  1257.     .ENDIF
  1258. ;---------------------------------------------------------------------------
  1259.     ; check center sub-square for duplicate digits:
  1260.  
  1261.     mov edx,Copy_of_Pointer
  1262.     ; add offset for the starting square:
  1263.     add edx,30
  1264.    
  1265.     ; initialize pointer to Value_Count array:
  1266.     mov ebx,OFFSET Value_Count
  1267.  
  1268.     ; reset Value_Count array to all zeros:
  1269.     mov DWORD PTR [ebx+0],0
  1270.     mov DWORD PTR [ebx+4],0
  1271.     mov WORD  PTR [ebx+8],0
  1272.  
  1273.     mov eax,0
  1274.  
  1275.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  1276.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  1277.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  1278.     inc BYTE PTR [ebx+eax]
  1279.     mov al,[edx+2]
  1280.     inc BYTE PTR [ebx+eax]
  1281.     mov al,[edx+9]
  1282.     inc BYTE PTR [ebx+eax]
  1283.     mov al,[edx+10]
  1284.     inc BYTE PTR [ebx+eax]
  1285.     mov al,[edx+11]
  1286.     inc BYTE PTR [ebx+eax]
  1287.     mov al,[edx+18]
  1288.     inc BYTE PTR [ebx+eax]
  1289.     mov al,[edx+19]
  1290.     inc BYTE PTR [ebx+eax]
  1291.     mov al,[edx+20]
  1292.     inc BYTE PTR [ebx+eax]
  1293.  
  1294.     ; check to see if any of the counter values exceeds 1:
  1295.     .IF     (BYTE PTR [ebx+1] > 1)
  1296.         jmp Illegal_Matrix_Detected
  1297.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1298.         jmp Illegal_Matrix_Detected
  1299.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1300.         jmp Illegal_Matrix_Detected
  1301.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1302.         jmp Illegal_Matrix_Detected
  1303.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1304.         jmp Illegal_Matrix_Detected
  1305.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1306.         jmp Illegal_Matrix_Detected
  1307.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1308.         jmp Illegal_Matrix_Detected
  1309.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1310.         jmp Illegal_Matrix_Detected
  1311.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1312.         jmp Illegal_Matrix_Detected
  1313.     .ENDIF
  1314. ;---------------------------------------------------------------------------
  1315.     ; check middle-right sub-square for duplicate digits:
  1316.  
  1317.     mov edx,Copy_of_Pointer
  1318.     ; add offset for the starting square:
  1319.     add edx,33
  1320.    
  1321.     ; initialize pointer to Value_Count array:
  1322.     mov ebx,OFFSET Value_Count
  1323.  
  1324.     ; reset Value_Count array to all zeros:
  1325.     mov DWORD PTR [ebx+0],0
  1326.     mov DWORD PTR [ebx+4],0
  1327.     mov WORD  PTR [ebx+8],0
  1328.  
  1329.     mov eax,0
  1330.  
  1331.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  1332.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  1333.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  1334.     inc BYTE PTR [ebx+eax]
  1335.     mov al,[edx+2]
  1336.     inc BYTE PTR [ebx+eax]
  1337.     mov al,[edx+9]
  1338.     inc BYTE PTR [ebx+eax]
  1339.     mov al,[edx+10]
  1340.     inc BYTE PTR [ebx+eax]
  1341.     mov al,[edx+11]
  1342.     inc BYTE PTR [ebx+eax]
  1343.     mov al,[edx+18]
  1344.     inc BYTE PTR [ebx+eax]
  1345.     mov al,[edx+19]
  1346.     inc BYTE PTR [ebx+eax]
  1347.     mov al,[edx+20]
  1348.     inc BYTE PTR [ebx+eax]
  1349.  
  1350.     ; check to see if any of the counter values exceeds 1:
  1351.     .IF     (BYTE PTR [ebx+1] > 1)
  1352.         jmp Illegal_Matrix_Detected
  1353.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1354.         jmp Illegal_Matrix_Detected
  1355.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1356.         jmp Illegal_Matrix_Detected
  1357.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1358.         jmp Illegal_Matrix_Detected
  1359.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1360.         jmp Illegal_Matrix_Detected
  1361.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1362.         jmp Illegal_Matrix_Detected
  1363.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1364.         jmp Illegal_Matrix_Detected
  1365.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1366.         jmp Illegal_Matrix_Detected
  1367.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1368.         jmp Illegal_Matrix_Detected
  1369.     .ENDIF
  1370. ;---------------------------------------------------------------------------
  1371.     ; check lower-left sub-square for duplicate digits:
  1372.  
  1373.     mov edx,Copy_of_Pointer
  1374.     ; add offset for the starting square:
  1375.     add edx,54
  1376.    
  1377.     ; initialize pointer to Value_Count array:
  1378.     mov ebx,OFFSET Value_Count
  1379.  
  1380.     ; reset Value_Count array to all zeros:
  1381.     mov DWORD PTR [ebx+0],0
  1382.     mov DWORD PTR [ebx+4],0
  1383.     mov WORD  PTR [ebx+8],0
  1384.  
  1385.     mov eax,0
  1386.  
  1387.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  1388.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  1389.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  1390.     inc BYTE PTR [ebx+eax]
  1391.     mov al,[edx+2]
  1392.     inc BYTE PTR [ebx+eax]
  1393.     mov al,[edx+9]
  1394.     inc BYTE PTR [ebx+eax]
  1395.     mov al,[edx+10]
  1396.     inc BYTE PTR [ebx+eax]
  1397.     mov al,[edx+11]
  1398.     inc BYTE PTR [ebx+eax]
  1399.     mov al,[edx+18]
  1400.     inc BYTE PTR [ebx+eax]
  1401.     mov al,[edx+19]
  1402.     inc BYTE PTR [ebx+eax]
  1403.     mov al,[edx+20]
  1404.     inc BYTE PTR [ebx+eax]
  1405.  
  1406.     ; check to see if any of the counter values exceeds 1:
  1407.     .IF     (BYTE PTR [ebx+1] > 1)
  1408.         jmp Illegal_Matrix_Detected
  1409.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1410.         jmp Illegal_Matrix_Detected
  1411.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1412.         jmp Illegal_Matrix_Detected
  1413.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1414.         jmp Illegal_Matrix_Detected
  1415.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1416.         jmp Illegal_Matrix_Detected
  1417.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1418.         jmp Illegal_Matrix_Detected
  1419.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1420.         jmp Illegal_Matrix_Detected
  1421.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1422.         jmp Illegal_Matrix_Detected
  1423.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1424.         jmp Illegal_Matrix_Detected
  1425.     .ENDIF
  1426. ;---------------------------------------------------------------------------
  1427.     ; check lower-middle sub-square for duplicate digits:
  1428.  
  1429.     mov edx,Copy_of_Pointer
  1430.     ; add offset for the starting square:
  1431.     add edx,57
  1432.    
  1433.     ; initialize pointer to Value_Count array:
  1434.     mov ebx,OFFSET Value_Count
  1435.  
  1436.     ; reset Value_Count array to all zeros:
  1437.     mov DWORD PTR [ebx+0],0
  1438.     mov DWORD PTR [ebx+4],0
  1439.     mov WORD  PTR [ebx+8],0
  1440.  
  1441.     mov eax,0
  1442.  
  1443.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  1444.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  1445.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  1446.     inc BYTE PTR [ebx+eax]
  1447.     mov al,[edx+2]
  1448.     inc BYTE PTR [ebx+eax]
  1449.     mov al,[edx+9]
  1450.     inc BYTE PTR [ebx+eax]
  1451.     mov al,[edx+10]
  1452.     inc BYTE PTR [ebx+eax]
  1453.     mov al,[edx+11]
  1454.     inc BYTE PTR [ebx+eax]
  1455.     mov al,[edx+18]
  1456.     inc BYTE PTR [ebx+eax]
  1457.     mov al,[edx+19]
  1458.     inc BYTE PTR [ebx+eax]
  1459.     mov al,[edx+20]
  1460.     inc BYTE PTR [ebx+eax]
  1461.  
  1462.     ; check to see if any of the counter values exceeds 1:
  1463.     .IF     (BYTE PTR [ebx+1] > 1)
  1464.         jmp Illegal_Matrix_Detected
  1465.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1466.         jmp Illegal_Matrix_Detected
  1467.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1468.         jmp Illegal_Matrix_Detected
  1469.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1470.         jmp Illegal_Matrix_Detected
  1471.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1472.         jmp Illegal_Matrix_Detected
  1473.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1474.         jmp Illegal_Matrix_Detected
  1475.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1476.         jmp Illegal_Matrix_Detected
  1477.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1478.         jmp Illegal_Matrix_Detected
  1479.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1480.         jmp Illegal_Matrix_Detected
  1481.     .ENDIF
  1482. ;---------------------------------------------------------------------------
  1483.     ; check lower-right sub-square for duplicate digits:
  1484.  
  1485.     mov edx,Copy_of_Pointer
  1486.     ; add offset for the starting square:
  1487.     add edx,60
  1488.    
  1489.     ; initialize pointer to Value_Count array:
  1490.     mov ebx,OFFSET Value_Count
  1491.  
  1492.     ; reset Value_Count array to all zeros:
  1493.     mov DWORD PTR [ebx+0],0
  1494.     mov DWORD PTR [ebx+4],0
  1495.     mov WORD  PTR [ebx+8],0
  1496.  
  1497.     mov eax,0
  1498.  
  1499.     mov al,[edx+0]               ; overwrite al (eax) with digit at this square
  1500.     inc BYTE PTR [ebx+eax]       ; increment counter for this digit
  1501.     mov al,[edx+1]               ; repeat for each of the remaining 8 squares
  1502.     inc BYTE PTR [ebx+eax]
  1503.     mov al,[edx+2]
  1504.     inc BYTE PTR [ebx+eax]
  1505.     mov al,[edx+9]
  1506.     inc BYTE PTR [ebx+eax]
  1507.     mov al,[edx+10]
  1508.     inc BYTE PTR [ebx+eax]
  1509.     mov al,[edx+11]
  1510.     inc BYTE PTR [ebx+eax]
  1511.     mov al,[edx+18]
  1512.     inc BYTE PTR [ebx+eax]
  1513.     mov al,[edx+19]
  1514.     inc BYTE PTR [ebx+eax]
  1515.     mov al,[edx+20]
  1516.     inc BYTE PTR [ebx+eax]
  1517.  
  1518.     ; check to see if any of the counter values exceeds 1:
  1519.     .IF     (BYTE PTR [ebx+1] > 1)
  1520.         jmp Illegal_Matrix_Detected
  1521.     .ELSEIF (BYTE PTR [ebx+2] > 1)
  1522.         jmp Illegal_Matrix_Detected
  1523.     .ELSEIF (BYTE PTR [ebx+3] > 1)
  1524.         jmp Illegal_Matrix_Detected
  1525.     .ELSEIF (BYTE PTR [ebx+4] > 1)
  1526.         jmp Illegal_Matrix_Detected
  1527.     .ELSEIF (BYTE PTR [ebx+5] > 1)
  1528.         jmp Illegal_Matrix_Detected
  1529.     .ELSEIF (BYTE PTR [ebx+6] > 1)
  1530.         jmp Illegal_Matrix_Detected
  1531.     .ELSEIF (BYTE PTR [ebx+7] > 1)
  1532.         jmp Illegal_Matrix_Detected
  1533.     .ELSEIF (BYTE PTR [ebx+8] > 1)
  1534.         jmp Illegal_Matrix_Detected
  1535.     .ELSEIF (BYTE PTR [ebx+9] > 1)
  1536.         jmp Illegal_Matrix_Detected
  1537.     .ENDIF
  1538. ;---------------------------------------------------------------------------
  1539.  
  1540. Matrix_is_Legal:
  1541.     ; If we made it this far, the Sudoku matrix is legal (return EAX = 1).
  1542.     mov eax,1
  1543.     ret
  1544.  
  1545. Illegal_Matrix_Detected:
  1546.     ; An illegal Sudoku matrix was detected (return EAX = 0).
  1547.     mov eax,0
  1548.     ret
  1549.  
  1550. Test_Sudoku ENDP
Add Comment
Please, Sign In to add comment