I am (unfortunately) only casually acquainted with the work of Isaac Asimov, one of the 'fathers' of sci-fi writing.
He wrote alot about robots, which I suppose are only really computers with legs. He came up with Asimov's Three Laws of Robotics
which he believed should be coded into any AI or 'free-thinking' machine.
I think they are incredibly clever in their simplicity. People have tried to come with better, but I've never seen anything that comes close. The man was a genius.
Here is a link
to a piece by Roger Clarke discussing Asimov's Laws. He extends them, but they basically remain the same:
An Extended Set of the Laws of Robotics
A robot may not act unless its actions are subject to the Laws of Robotics
A robot may not injure humanity, or, through inaction, allow humanity to come to harm
A robot may not injure a human being, or, through inaction, allow a human being to come to harm, unless this would violate a higher-order Law
A robot must obey orders given it by human beings, except where such orders would conflict with a higher-order Law
A robot must obey orders given it by superordinate robots, except where such orders would conflict with a higher-order Law
A robot must protect the existence of a superordinate robot as long as such protection does not conflict with a higher-order Law
A robot must protect its own existence as long as such protection does not conflict with a higher-order Law
A robot must perform the duties for which it has been programmed, except where that would conflict with a higher-order law
The Procreation Law
A robot may not take any part in the design or manufacture of a robot unless the new robot's actions are subject to the Laws of Robotics