Engine replacement 2.5L on 1997 Subaru Legacy Outback

Will a 2.5L engine out of a 1996 or 1998 subaru outback work in a 1997 Outback?

Asked by for the 1997 Subaru Legacy Outback
1 answer
I just put a 96 engine in my 97 car runs fine but now has a ck engine light on trying to figure out what to do now think i have tto change ecm but not sure