Just as a challenge, I dug in, trying to come up with a solution for your 5x5 matrix. I managed to write the code to do the trick for any selection of 2x2, 3x3, 4x4 and the 5x5. I can rotate the outermost sqare 90 degrees in a clockwise or a counterclockwise direction, as many times as wanted, one by one.

As can be seen, the code is quite repetitive, in part, and is susceptible, with a little more work, of being greatly reduced by using more FOR/NEXT, or SELECT CASE/END SELECT, or DO/LOOP. In that manner, it could easily handle any size of square, up to the limit that I get, 127x127. Obviously, this would meet the OP's requirement of a 56x56 square.

Here's my code:

'ArrayRot, by Ralph A. Esquivel, 24 Jan 2008, creates a 5x5 array, then

'allows selecting any 2x2, 3x3 or 4x4 submatrix, or the 5x5 matrix, then

'rotate it +/-90ø (clock- or counterclock-wise), repeatedly

OPTION BASE 1 'I like to use arrays whose first element is 1.

SCREEN 12

CLS

'size of array will be S,S

SS = 5

DIM array0(SS, SS) AS STRING * 1 'initial array

DIM array1(SS, SS) AS STRING * 1 'final array

'create array0 and array1

FOR y = 1 TO SS

FOR x = 1 TO SS

READ m$

array0(x, y) = m$

array1(x, y) = m$

NEXT x

NEXT y

GOSUB printArray0

firstLine = y * vv 'first line of text

'draw grid

GOSUB drawGrid

'PART THAT REPEATS STARTS HERE

DO

DO

'clear all text below grid

LOCATE firstLine + 1, 1

FOR i = 1 TO 12

PRINT STRING$(78, " ")

NEXT i

'enter size of block to rotate

LOCATE firstLine + 1, 4

PRINT "Enter horizontal dimension of block to rotate 90ø (+/-2 to +/-5): ";

LINE INPUT k$

d$ = k$

d = VAL(d$)

PRINT d

LOOP WHILE d = 0 OR ABS(d) > 5

DO

DO

'clear old text

cellChosen$ = ""

LOCATE firstLine + 2, 4

FOR i = 1 TO 11

PRINT STRING$(78, " ")

NEXT i

'find right-bottom-most letter allowed for top of block w/ dimension chosen

rbmL$ = array1(SS + 1 - ABS(d), SS + 1 - ABS(d))

'enter letter for left-top letter of block to rotate

a$ = "Enter top-left cell of block (A TO " + rbmL$ + "): "

LOCATE firstLine + 2, 4

PRINT a$;

GOSUB inkey

L$ = UCASE$(k$)

PRINT L$

LOOP WHILE L$ = 0 OR L$ < "A" OR L$ > "Z"

'find x and y values for L$ in array1

FOR y = 1 TO SS

FOR x = 1 TO SS

'''PRINT x; y,

IF array1(x, y) = L$ THEN

ex$ = "Yes"

EXIT FOR

END IF

NEXT x

IF ex$ = "Yes" THEN EXIT FOR

PRINT

NEXT y

'reset ex$

ex$ = ""

'evaluate if cell chosen is appropriate for block chosen

maxvalue = SS + 1 - ABS(d)

IF x > maxvalue THEN

cellChosen$ = "Bad"

PRINT " x ="; x; "is too large. Choose an appopriate cell"

GOSUB pause

END IF

IF y > maxvalue THEN

cellChosen$ = "Bad"

PRINT " y ="; y; "is too large. Choose an appopriate cell"

GOSUB pause

END IF

LOOP WHILE cellChosen$ = "Bad"

'create a temporary array for the block to be rotated

REDIM temp(x TO x + ABS(d) - 1, y TO y + ABS(d) - 1) AS STRING * 1

'rotate block chosen +/-90ø

IF d = 2 THEN

temp(x + 0, y + 0) = array1(x + 0, y + 1)

temp(x + 0, y + 1) = array1(x + 1, y + 1)

temp(x + 1, y + 0) = array1(x + 0, y + 0)

temp(x + 1, y + 1) = array1(x + 1, y + 0)

ELSEIF d = -2 THEN

temp(x + 0, y + 0) = array1(x + 1, y + 0)

temp(x + 0, y + 1) = array1(x + 0, y + 0)

temp(x + 1, y + 0) = array1(x + 1, y + 1)

temp(x + 1, y + 1) = array1(x + 0, y + 1)

END IF

IF d = 3 THEN

temp(x + 0, y + 0) = array1(x + 0, y + 2)

temp(x + 0, y + 1) = array1(x + 1, y + 2)

temp(x + 0, y + 2) = array1(x + 2, y + 2)

temp(x + 1, y + 0) = array1(x + 0, y + 1)

temp(x + 1, y + 1) = array1(x + 1, y + 1)

temp(x + 1, y + 2) = array1(x + 2, y + 1)

temp(x + 2, y + 0) = array1(x + 0, y + 0)

temp(x + 2, y + 1) = array1(x + 1, y + 0)

temp(x + 2, y + 2) = array1(x + 2, y + 0)

ELSEIF d = -3 THEN

temp(x + 0, y + 0) = array1(x + 2, y + 0)

temp(x + 0, y + 1) = array1(x + 1, y + 0)

temp(x + 0, y + 2) = array1(x + 0, y + 0)

temp(x + 1, y + 0) = array1(x + 2, y + 1)

temp(x + 1, y + 1) = array1(x + 1, y + 1)

temp(x + 1, y + 2) = array1(x + 0, y + 1)

temp(x + 2, y + 0) = array1(x + 2, y + 2)

temp(x + 2, y + 1) = array1(x + 1, y + 2)

temp(x + 2, y + 2) = array1(x + 0, y + 2)

END IF

IF d = 4 THEN

temp(x + 0, y + 0) = array1(x + 0, y + 3)

temp(x + 0, y + 1) = array1(x + 1, y + 3)

temp(x + 0, y + 2) = array1(x + 2, y + 3)

temp(x + 0, y + 3) = array1(x + 3, y + 3)

temp(x + 1, y + 0) = array1(x + 0, y + 2)

temp(x + 1, y + 1) = array1(x + 1, y + 2)

temp(x + 1, y + 2) = array1(x + 2, y + 2)

temp(x + 1, y + 3) = array1(x + 3, y + 2)

temp(x + 2, y + 0) = array1(x + 0, y + 1)

temp(x + 2, y + 1) = array1(x + 1, y + 1)

temp(x + 2, y + 2) = array1(x + 2, y + 1)

temp(x + 2, y + 3) = array1(x + 3, y + 1)

temp(x + 3, y + 0) = array1(x + 0, y + 0)

temp(x + 3, y + 1) = array1(x + 1, y + 0)

temp(x + 3, y + 2) = array1(x + 2, y + 0)

temp(x + 3, y + 3) = array1(x + 3, y + 0)

ELSEIF d = -4 THEN

temp(x + 0, y + 0) = array1(x + 3, y + 0)

temp(x + 0, y + 1) = array1(x + 2, y + 0)

temp(x + 0, y + 2) = array1(x + 1, y + 0)

temp(x + 0, y + 3) = array1(x + 0, y + 0)

temp(x + 1, y + 0) = array1(x + 3, y + 1)

temp(x + 1, y + 1) = array1(x + 2, y + 1)

temp(x + 1, y + 2) = array1(x + 1, y + 1)

temp(x + 1, y + 3) = array1(x + 0, y + 1)

temp(x + 2, y + 0) = array1(x + 3, y + 2)

temp(x + 2, y + 1) = array1(x + 2, y + 2)

temp(x + 2, y + 2) = array1(x + 1, y + 2)

temp(x + 2, y + 3) = array1(x + 0, y + 2)

temp(x + 3, y + 0) = array1(x + 3, y + 3)

temp(x + 3, y + 1) = array1(x + 2, y + 3)

temp(x + 3, y + 2) = array1(x + 1, y + 3)

temp(x + 3, y + 3) = array1(x + 0, y + 3)

END IF

IF d = 5 THEN

temp(x + 0, y + 0) = array1(x + 0, y + 4)

temp(x + 0, y + 1) = array1(x + 1, y + 4)

temp(x + 0, y + 2) = array1(x + 2, y + 4)

temp(x + 0, y + 3) = array1(x + 3, y + 4)

temp(x + 0, y + 4) = array1(x + 4, y + 4)

temp(x + 1, y + 0) = array1(x + 0, y + 3)

temp(x + 1, y + 1) = array1(x + 1, y + 3)

temp(x + 1, y + 2) = array1(x + 2, y + 3)

temp(x + 1, y + 3) = array1(x + 3, y + 3)

temp(x + 1, y + 4) = array1(x + 4, y + 3)

temp(x + 2, y + 0) = array1(x + 0, y + 2)

temp(x + 2, y + 1) = array1(x + 1, y + 2)

temp(x + 2, y + 2) = array1(x + 2, y + 2)

temp(x + 2, y + 3) = array1(x + 3, y + 2)

temp(x + 2, y + 4) = array1(x + 4, y + 2)

temp(x + 3, y + 0) = array1(x + 0, y + 1)

temp(x + 3, y + 1) = array1(x + 1, y + 1)

temp(x + 3, y + 2) = array1(x + 2, y + 1)

temp(x + 3, y + 3) = array1(x + 3, y + 1)

temp(x + 3, y + 4) = array1(x + 4, y + 1)

temp(x + 4, y + 0) = array1(x + 0, y + 0)

temp(x + 4, y + 1) = array1(x + 1, y + 0)

temp(x + 4, y + 2) = array1(x + 2, y + 0)

temp(x + 4, y + 3) = array1(x + 3, y + 0)

temp(x + 4, y + 4) = array1(x + 4, y + 0)

ELSEIF d = -5 THEN

temp(x + 0, y + 0) = array1(x + 4, y + 0)

temp(x + 0, y + 1) = array1(x + 3, y + 0)

temp(x + 0, y + 2) = array1(x + 2, y + 0)

temp(x + 0, y + 3) = array1(x + 1, y + 0)

temp(x + 0, y + 4) = array1(x + 0, y + 0)

temp(x + 1, y + 0) = array1(x + 4, y + 1)

temp(x + 1, y + 1) = array1(x + 3, y + 1)

temp(x + 1, y + 2) = array1(x + 2, y + 1)

temp(x + 1, y + 3) = array1(x + 1, y + 1)

temp(x + 1, y + 4) = array1(x + 0, y + 1)

temp(x + 2, y + 0) = array1(x + 4, y + 2)

temp(x + 2, y + 1) = array1(x + 3, y + 2)

temp(x + 2, y + 2) = array1(x + 2, y + 2)

temp(x + 2, y + 3) = array1(x + 1, y + 2)

temp(x + 2, y + 4) = array1(x + 0, y + 2)

temp(x + 3, y + 0) = array1(x + 4, y + 3)

temp(x + 3, y + 1) = array1(x + 3, y + 3)

temp(x + 3, y + 2) = array1(x + 2, y + 3)

temp(x + 3, y + 3) = array1(x + 1, y + 3)

temp(x + 3, y + 4) = array1(x + 0, y + 3)

temp(x + 4, y + 0) = array1(x + 4, y + 4)

temp(x + 4, y + 1) = array1(x + 3, y + 4)

temp(x + 4, y + 2) = array1(x + 2, y + 4)

temp(x + 4, y + 3) = array1(x + 1, y + 4)

temp(x + 4, y + 4) = array1(x + 0, y + 4)

END IF

'change elements in array1 to those in temp, the rotated block

IF d = 2 OR d = -2 THEN

array1(x + 0, y + 0) = temp(x + 0, y + 0)

array1(x + 0, y + 1) = temp(x + 0, y + 1)

array1(x + 1, y + 0) = temp(x + 1, y + 0)

array1(x + 1, y + 1) = temp(x + 1, y + 1)

END IF

IF d = 3 OR d = -3 THEN

array1(x + 0, y + 0) = temp(x + 0, y + 0)

array1(x + 0, y + 1) = temp(x + 0, y + 1)

array1(x + 0, y + 2) = temp(x + 0, y + 2)

array1(x + 1, y + 0) = temp(x + 1, y + 0)

array1(x + 1, y + 1) = temp(x + 1, y + 1)

array1(x + 1, y + 2) = temp(x + 1, y + 2)

array1(x + 2, y + 0) = temp(x + 2, y + 0)

array1(x + 2, y + 1) = temp(x + 2, y + 1)

array1(x + 2, y + 2) = temp(x + 2, y + 2)

END IF

IF d = 4 OR d = -4 THEN

array1(x + 0, y + 0) = temp(x + 0, y + 0)

array1(x + 0, y + 1) = temp(x + 0, y + 1)

array1(x + 0, y + 2) = temp(x + 0, y + 2)

array1(x + 0, y + 3) = temp(x + 0, y + 3)

array1(x + 1, y + 0) = temp(x + 1, y + 0)

array1(x + 1, y + 1) = temp(x + 1, y + 1)

array1(x + 1, y + 2) = temp(x + 1, y + 2)

array1(x + 1, y + 3) = temp(x + 1, y + 3)

array1(x + 2, y + 0) = temp(x + 2, y + 0)

array1(x + 2, y + 1) = temp(x + 2, y + 1)

array1(x + 2, y + 2) = temp(x + 2, y + 2)

array1(x + 2, y + 3) = temp(x + 2, y + 3)

array1(x + 3, y + 0) = temp(x + 3, y + 0)

array1(x + 3, y + 1) = temp(x + 3, y + 1)

array1(x + 3, y + 2) = temp(x + 3, y + 2)

array1(x + 3, y + 3) = temp(x + 3, y + 3)

END IF

IF d = 5 OR d = -5 THEN

array1(x + 0, y + 0) = temp(x + 0, y + 0)

array1(x + 0, y + 1) = temp(x + 0, y + 1)

array1(x + 0, y + 2) = temp(x + 0, y + 2)

array1(x + 0, y + 3) = temp(x + 0, y + 3)

array1(x + 0, y + 4) = temp(x + 0, y + 4)

array1(x + 1, y + 0) = temp(x + 1, y + 0)

array1(x + 1, y + 1) = temp(x + 1, y + 1)

array1(x + 1, y + 2) = temp(x + 1, y + 2)

array1(x + 1, y + 3) = temp(x + 1, y + 3)

array1(x + 1, y + 4) = temp(x + 1, y + 4)

array1(x + 2, y + 0) = temp(x + 2, y + 0)

array1(x + 2, y + 1) = temp(x + 2, y + 1)

array1(x + 2, y + 2) = temp(x + 2, y + 2)

array1(x + 2, y + 3) = temp(x + 2, y + 3)

array1(x + 2, y + 4) = temp(x + 2, y + 4)

array1(x + 3, y + 0) = temp(x + 3, y + 0)

array1(x + 3, y + 1) = temp(x + 3, y + 1)

array1(x + 3, y + 2) = temp(x + 3, y + 2)

array1(x + 3, y + 3) = temp(x + 3, y + 3)

array1(x + 3, y + 4) = temp(x + 3, y + 4)

array1(x + 4, y + 0) = temp(x + 4, y + 0)

array1(x + 4, y + 1) = temp(x + 4, y + 1)

array1(x + 4, y + 2) = temp(x + 4, y + 2)

array1(x + 4, y + 3) = temp(x + 4, y + 3)

array1(x + 4, y + 4) = temp(x + 4, y + 4)

END IF

'print new array1

GOSUB printArray1

LOCATE 17, 4

PRINT "Press <Esc> to quit exit program, any other key to continue"

GOSUB inkey

IF k$ = CHR$(27) THEN END

LOOP

END

'--------------

'DATA FOR ARRAY

DATA A,B,C,D,E

DATA F,G, H,I,J

DATA K,L,M,N,O

DATA P,Q,R,S,T

DATA U,V,W,X,Y

'===========================================================================

'SUBROUTINES

printArray0:

hh = 5: vv = 2

FOR y = 1 TO SS

FOR x = 1 TO SS

LOCATE y * vv + 1, x * hh + 4: PRINT array0(x, y)

NEXT x

NEXT y

RETURN

printArray1:

hh = 5: vv = 2

FOR y = 1 TO SS

FOR x = 1 TO SS

LOCATE y * vv + 1, x * hh + 4: PRINT array1(x, y)

NEXT x

NEXT y

RETURN

drawGrid:

'the following values were obtained by trial and error for horizontal lines

ht = 14 * 3: vt = 20

FOR x = 1 TO SS + 1

LINE (x * ht, vt)-(x * ht, 9 * vt), 15

NEXT x

'the following values were obtained by trial and error for vertical lines

va = 20: vt = vt + 12

FOR y = -1 TO SS

LINE (ht, y * vt + va)-(6 * ht, y * vt + va), 15

NEXT y

RETURN

inkey:

k$ = "": WHILE k$ = "": k$ = INKEY$: WEND

RETURN

pause:

WHILE INKEY$ = "": WEND

RETURN