for a 8x8 keypad there are 64 possible results
that's an extraordinary convoluted way to get a result


why not
Code:
key var byte    ; high nibble column  low nibble row
  if portb then    'look for a 1
      key = ncd portb  'row    look for a 1
      key = key + (ncd portc )<<4
      PORTA.1 = 1  ' Data Available
      WHILE PORTB >0 :wend
  endif