When you buy a computer, at least in the US, you don't own the software.
(US only)
Actually, you do own it -- the specific *copy* of it -- just like you own a book. That much is undisputed in any serious court hearing. In order to really not own it, you would have to actually sign a lease, obligating you to return it at some point.
Owning it is quite different from owning the "copyright" or the "patent rights", etc. To use a funny parallel example, it's quite possible to own land without owning the right to build buildings on the land, without owning the right to hunt on the land, etc. etc. etc. You can own the land and have lost most of your rights over it through easements and various other actions.
The right to copy software which you own for purposes of running it is protected by law, too. (There was contrary law, but most of this law is based on bad Supreme Court precedent which claims that software in RAM is "fixed in a medium of expression", which it isn't. The whole line of reasoning will have to be tossed because it's contrary to fact.)
There's some very disputed law in the middle of this area. The corporations will claim that you don't have the right to modify it, but when it actually goes to the courts, it usually seems that you are permitted to modify for personal use, though not for profit.
What you definitely don't have the right to do, according to the courts, is to redistribute copies. And of course the software distributor is within their rights to make the software totally obfusticated, so that any modification you make must be made by machine-code hacking.
The situation is quite convoluted. With patents it's even messier because pure software patents are all invalid (for multiple reasons, confirmed repeatedly by the Supreme Court), but the Federal Circuit and the patent office keep wanting to issue and enforce them... that IS going to need to change, and very fast, because it's causing nothing but trouble for all of American industry.
- - - Updated - - -
So anyone who thinks that even right-to-repair gives them rights to software code is mistaken. The manufacturer might be required to allow independent shops to install the software, and the DMCA will protect that software from reverse-engineering, but the idea that you then own rights to the code - other than a license to use - is silly.
...actually reverse engineering is protected by law. It's an actual legal right. Anyway.
Regarding trade secrets, any code which is distributed inside a mass-produced, mass-distributed device has not been kept secret. Period. That would be like claiming something was secret when it was plastered on every wall. That's the object code, mind you.
The DMCA is yet another matter. The "anti-circumvention" provisions are either a nullity (if you take the literal meaning of "effectively") or unconstitutional (if you take the DVD companies' fascist interpretation of "effectively" to mean "ineffectively").