In short: it depends.
Chainrings tend to be much more compatible across gear counts than anything else in the drivetrain. It amounts to "does the chain fit", and when you're talking 8/9 speed the chain width is the same anyway, so yes, that will work.
The real question is whether the bolt pattern is compatible between the two, because that's where the real variation is. But it's probably obvious - look at it, try it. Pull one chainring off and hold it next to the other bike. If the bolt holes line up you're good to go.
If you're asking whether you can swap the cranks with chainrings attached, that's harder to answer. The first question is whether the bottom brackets are compatible. There are several sorts these days, with the traditional square taper being superseded by larger diameter axles of various shapes. If those are the same, the next question is clearance between the chainrings and chainstay. The only reliable way to test that is trying it, for which you'll need the right tool(s) to pull the cranks off. With many modern bottom brackets that's as simple as undoing the bolts and pulling them off by hand, with square taper you need a special tool. When putting the other chainring on, watch that you're not pressing the chainring against the frame as you do the bolts up. Then make sure there's a few mm of clearance between frame and chainrings.