# 8051 program

Status
Not open for further replies.

#### thug

##### New Member
how do i check i 8051 programming if a matric is symmetric or not for eg If the value stored in 60H is 3 and values stored in 61H, 62H, . . ., 69H are 1, 4, 3, 4, 1, 2, 3, 2, 1 . then psw.5 shud be set to 1. matrix dimension m can be 2, 3, or 4. Assume the matrix M to be stored in row-major form, i.e., element M(1, 1) is in the 1st location, M(1, 2) is in the 2nd location, . . . , M(m, m − 1) is in the (m − 1)*m-th location and M(m, m) in the m^2 -th location ;

.so wat i thought was that i could enter the values in the addresses mentioned . now in case of 2*2 matrix the numbers at 62h and 63h should be equal.similarly that at 62h-64h,63h-67h and 66h-68h for 3*3 matrix like that.so i used cjne to check if matrix dimension is 2 or 3 or 4 and in case i checked the condition like if 62h and 63h are equal using cjne. my problem is that i am not able to get the output in keil. and i am not able to figure out the problem.the logic seems fine to me but i would like to know whether the logic is wrong or are there any possible mistakes which i should take care of

Last edited:

#### rjenkinsgb

##### Well-Known Member
Treat it as a 2D array, X and Y.

Use nested loops to count X and Y, up to the limit.
The test within the inner loop is then

If matrix(x,y) <> matrix(y,x) it's not symmetrical so exit with false result.

If you complete both loops without that happening, it's symmetrical

The loop counts would be 0 to size-1
To simplify array addressing, use a separate Y offset value, starting at 0 and add the size to that when you increment the Y count value.

The address offset from the first array address is then Y offset + X count; no multiplication needed.

#### JimB

##### Super Moderator
Don't create multiple threads on the same subject, it only creates confusion.

JimB
One of the moderators.

Status
Not open for further replies. 