This isn't by any means a new topic; Asimov codified it in his famous Three Laws back in 1942; and Wired ran an article in 2005 that considered some of the broader ethical implications of introducing ever-more-humanoid machines into society.
There now seems to be a burgeoning discussion on this topic, spread widely:
* Illah Nourbakhsh's lecture (below) has spawned a CMU class: http://ethicsandrobotics.posterous.com/
* Patrick Lin (along with George Bekey and others) at Cal Ploy SLO's Ethics + Emerging Technology Group have authored several good papers, with some intro and discussion at the Stanford Law Center for Internet and Society.
* There are several interesting blogs covering this area, such as moral machines
Evil Mad Scientist Valentines: 2016 Edition - Today we are releasing our newest set of “Download and Print” cards for Valentine’s day. This is our fourth year, and fourth set of cards: The 2013 set had...
5 hours ago