nacedo 0 Newbie Poster

I have done this chunk of code that I want to ''translate'' in assembly language. It calculates the lenght of the longest common subsequence.

Can someone help me to translate this in PEP/8 assembly language ? The rest of my program is functionning quite good, but I cant find a way to populate my matrix. Its a multidimension and variable length matrix, and I find this very complex. I know there is no such thing in assembly because multi dimension arrays are in fact one dimension arrays. I am quite lost.

To simplify I can say that no string will be more that 100 characters.

Thanks for any insight.

public static void LCS() {

    matrix = new int[String1Lenght + 1][String2Lenght + 1];
    for (int i = String1Lenght - 1; i >= 0; i--) {
        for (int j = String2Lenght - 1; j >= 0; j--) {
            if (String1Array[i] == String2Array[j]) {
                matrix[i][j] = matrix[i + 1][j + 1] + 1;

            } else {
                matrix[i][j] = max(matrix[i + 1][j], matrix[i][j + 1]);

            }
        }
    }
    int i = 0, j = 0;
    while (i < String1Lenght && j < String2Lenght) {
        if (String1Array[i] == String2Array[j]) {
            i++;
            j++;
        } else if (matrix[i + 1][j] >= matrix[i][j + 1]) {
            i++;
        } else {
            j++;
        }
    }

    System.out.print(j);
    System.out.println("");
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.