How to test big-endian code?

Programming, for all ages and all languages.
Post Reply
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

How to test big-endian code?

Post by Solar »

I have a piece of code that does some bit-fiddling, which should work on Little Endian and Big Endian alike.

Unfortunately the company has shut down the last of the AIX boxes (that I had access to), which were my go-to point to test BE code.

So... how do you test big-endian code? Online compilers like ideone.com are all LE. Emulation? Some small board / box that runs a BE Linux? I'd probably even be willing to shell out a couple of bucks if it gave me a big-endian testbed. One I could use to test heavily C++17-ish code...
Every good solution is obvious once you've found it.
User avatar
zaval
Member
Member
Posts: 656
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: How to test big-endian code?

Post by zaval »

I bought for myself iMac g5. openbsd and linux can run on it.
it's even 64 bit. theoretically. with 512MB of RAM. :mrgreen:
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
davidv1992
Member
Member
Posts: 223
Joined: Thu Jul 05, 2007 8:58 am

Re: How to test big-endian code?

Post by davidv1992 »

You could also look into using some ARM based board, as arm still supports both endian conventions.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: How to test big-endian code?

Post by Solar »

RaspberryPi draws a blank, as does Arduino...
Every good solution is obvious once you've found it.
User avatar
iansjack
Member
Member
Posts: 4689
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to test big-endian code?

Post by iansjack »

How about an old SPARC box from eBay? Buy-it-nows for about £50 in UK. You might strike lucky with an auctioned one.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: How to test big-endian code?

Post by Schol-R-LEA »

I would start by trying it in QEMU emulating MIPS BE (which is actually the default for MIPS on QEMU; the MIPS little-endian emulation is given as 'mipsel' rather than 'mips').
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
User avatar
iansjack
Member
Member
Posts: 4689
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to test big-endian code?

Post by iansjack »

User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: How to test big-endian code?

Post by Solar »

I think I have completed the circle, coming back home.

I installed WinUAE (which, being the owner of a licensed copy of AmigaForever, I have the ROM and OS files for), downloaded the DICE C compiler, and by putting the bit-fiddling stuff into out-of-context C files, am now able to put the Endian-dependent logic to the actual test.

Not quite what I would have preferred, but a workable solution.

And it feels like it was just yesterday, seeing the Amiga Workbench again...
Every good solution is obvious once you've found it.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: How to test big-endian code?

Post by Solar »

Actually a good friend of mine happened to have an A3000 in his garage, complete with a SCSI hard drive. (The A3000 being the only Amiga that ever came with a MMU out-of-the-box -- you need the MMU to run a Unix on it.) The beauty is now sitting in my room, pending a test run after almost two decades of inactivity.

If it doesn't work out, the UAE / C solution is good enough for me.

(Auctioned Amigas are anything but cheap. The nostalgics associated with the platform, combined with the scarcity of late-era hardware, made prices go up instead of down over time...)
Every good solution is obvious once you've found it.
Post Reply