Many of us 'old-timers' here in Spain had a residence card (a very useful document - similar to a Spanish id card). These were taken away along with our 'residencia' in around 2009 and, in substitution, we were given a letter from the police (i.e. the Ministry of the Interior) to carry around at all times with our passport as proof of identity. Silly and impractical. The letter itself states that 'as an EU citizen, the bearer has the right of abode in Spain'. However, in the calamitous event of a Brexit, we would no longer be 'EU Citizens', and therefore the letter would no longer be valid. Non-EU citizens can be 'resident' in Spain, and no doubt we could try to obtain a new 'residencia'. This could be easy, or hard, depending on the Ministry of the Interior, which would be influenced by two considerations.
1, which party or coalition will eventually take control of Parliament in Madrid and
2, how will London treat its no-longer-EU migrants and students.