Yes it will work and not be an issue, although I would prefer to see a little more overhead since a PSU runs cooler, quieter, and more efficiently when not running close to its capacity. Still if I already had the 500w PSU installed I would not hesitate to install the 5850, especially if it is a good PSU.
You might google the name of your PSU plus the word "reviews" and see if any of them have the tables or graphs that show how temperature, noise, and efficiency are affect by the load placed on it.
If you need to know the total load, just use the standard calculator:
The 5870 might be touch and go - I would not do it.
Here is a review (very respected site) showing power requirements for both cards in basic systems (I say basic because the review is to test the card more than power requirements and added components, specific components. or OC the graphics card could increase power needs). Note that the 5870 is only 401w under load.