Page 1 of 1

Unaligned memory access

Posted: Thu Aug 04, 2005 8:55 am
by R0
How can I tell compiler to use "lwr/lwl" and "swr/swl" pairs instead of single "lw" and "sw" operations? I'd like to force compiler to generate those instructions for specified pointers. Is it possible ?

Posted: Wed Aug 10, 2005 8:12 am
by J.F.
Those are patented instructions and shouldn't be used. Use of those instructions could open you to patent license issues with MIPS (the company). They tend to be pretty pissy about the patent as well.

Posted: Wed Aug 10, 2005 8:36 am
by ooPo
I don't understand how an opcode can be patented and unavailable for use.

Posted: Wed Aug 10, 2005 3:15 pm
by mrbrown
GCC will automatically have the assembler generate lwl, etc. for any unaligned accesses within a struct or union.

J.F.'s confused, the patent is for competing processors, not for MIPS CPUs that already support lwl and friends.

Posted: Thu Aug 11, 2005 4:09 am
by J.F.
The patent covers the implementation of the instruction. As such, no third party can make similar instructions. That much is established in several court cases. Another court case established that an emulator violated the patent by having software versions of those instructions, even though the emulator didn't implement the instructions the same way as in the patent. Given the scope the courts have allowed the MIPS patent and MIPS aggressive litigation on it, I'm not about to say that simply USING the instructions doesn't also require a license. Remember that patents don't just cover the MAKING of an invention but the USAGE of the invention as well. Unlicensed use of a patented invention is a violation. In this case, the invention is the patented instructions.

Posted: Thu Aug 11, 2005 4:46 am
by mrbrown
Regardless of what you are blabbering about it's perfectly legal to use lwl/swl and lwr/swr on the PS1, PS2, PSP, and any other MIPS-based CPU that supports them. A company that licenses MIPS technology wouldn't implement those instructions if developers couldn't use them. That's silly.

With all that patent nonsense you didn't even bother to answer the guy's question.

Posted: Thu Aug 18, 2005 5:39 am
by J.F.
Given the flood of patent suits in the US, it's a perfectly valid line of reasoning that could only be answered for sure by a patent attourney. But MrBrown is right - it can probably be ignored by most folks.

As to the question - it's silly on the face of it. Look in ANY MIPS manual and you'll find the answer as well as example code.

Posted: Thu Aug 18, 2005 11:23 am
by Rk
i'm still new to PS2 programming, but can't you simply use assembly code for that patch ? (by patch i mean part of code that you need compiled differently) just write it in ASM and it should turn out ok... it's funny tho, the assembly language is the only universal language... no matter which compiler you use - it all comes to that, and even your fridge and TV and those little christmass music cards use assembly (altho embed in a single chip, but non-the-less)... isn't it cool to be a programmer or what ?:)))

Posted: Thu Aug 25, 2005 1:07 pm
by J.F.
I always preferred working in assembly language myself. You always know EXACTLY what the CPU is doing. Some things require a LITTLE more work, but I think it's worth the trade off.