I assume the rectangles are given by their corners. From here you can write the equations of the side lines. The two centers also determine a line. Intersect the latter with 8 side lines. You want to learn how to solve the following problem:
Given three points A, B, C on the same straight line. Is B between A and C?
Once you know the answer, you can check which sides in the two rectangles are crossed by the line of centers. You'd have at most 4 points on that line.
Parametrize the line so that all 4 points will correspond to a value of the parameter. Compare the values.