first get a manual.
head over to xs400.com for the "paperwork"
an '81 could either be the rare dohc bike or the last of the sohc bikes so you need to let me know the first 3 letters/number of the engine.
you should have electronic ignition, so everything sounds fine there. Make sure you have the right grade plugs in, then as airhead said, check compression is 155 psi, warm with throttle fully open. could indicate either sticky piston rings or worn bore.
another thing is these bikes don't like standing, modern fuel gums up in a month.
I'd give it an "italian service" ie give it some beans to clear the engine out!