Unaligned memory access

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
R0
Posts: 7
Joined: Sat Oct 02, 2004 6:38 am

Unaligned memory access

Post 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 ?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post 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.
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

I don't understand how an opcode can be patented and unavailable for use.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post 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.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post 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.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post 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.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post 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.
Rk
Posts: 17
Joined: Thu Aug 11, 2005 9:48 pm

Post 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 ?:)))
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post 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.
Post Reply