This is about expanding input and outputs
http://www.st.com/stonline/books/pdf/docs/13709.pdf
I needed 16 I/O points and will most likely use the the 595 and 165 chips though I'll need to generate and interrupt for the inputs rather than do a continuous scan.