Linux Port
Pages: 1 ... 8 9 10 11 12 13 14 15 16 17 18 19 20
Martin Philips (9013) 48 posts |
Aarch32 is supported in the application layer (EL0) SWIs are trapped and re-directed.. |
Kuemmel (439) 384 posts |
I see…so if future ARM chips will drop that Aarch32 application layer support the apps won’t run anymore at all with the Linux Port or an emulation layer will jump in ? |
Chris Gransden (337) 1202 posts |
When there is no Aarch32, QEmu is used so will run anywhere that can run QEmu. |
Martin Philips (9013) 48 posts |
In the meantime, work could be done to improve performance of QEmu and also work done to port RISC OS over to 64-bits…. if ABI ILP32 is used for c code… Something like https://wiki.debian.org/Arm64ilp32Port |
David J. Ruck (33) 1629 posts |
I used ILP32 for something a long time ago, can’t remember for the life of me what, but I’m not sure what advantage it would bring to running RISC OS under QEmu. |
Martin Philips (9013) 48 posts |
It would allow any RISC OS C code to be compiled into aarch64, but keeping the same pointer size I think it should be possible to cross-assemble the 32-bit asm into 64-bit asm using some sort of pre-processor… Not saying it wouldn’t need (a lot of) work So, you end up with something that can run on a 64-bit only CPU, w/o using QEmu (but is restricted to 32-bit addressing – which I doubt would be a practical restriction) |
Clive Semmens (2335) 3276 posts |
I’m far from convinced this is even theoretically possible, short of said pre-processor using some pretty clever AI to divine the purpose of each section of code and then recreate the function using the different instruction set. That clever AI is certainly beyond my capabilities. Divining the purpose of sections of code is not beyond me, nor I’m sure beyond others who could do it more quickly than I could – but the volume of such code is far too great for me or any likely team. Even if such a project were feasible, it would surely be better to convert the code to C (or some other higher level language) than to any particular assembly language. |
Martin Philips (9013) 48 posts |
Well, I think it’s not as bad as all that… - the Arm64 has 31 (ish) 64-bit registers and the Arm32 15 (ish) 32-bit registers… SWIs would be handled though a vector table probably.. Many of the instructions have a fairly straight forward mapping from Arm32 to Arm64 Anyway, it’s what binary JIT compilers do on-the-fly |
Rick Murray (539) 13806 posts |
So very much this. If we translate assembler to assembler, we’d be needing to fiddle every time the underlying architecture changes…in case nobody has noticed 😋, ARM changes stuff in backwards breaking ways – this isn’t the x86 world, your latest ARMv9 chip doesn’t boot up thinking it’s an 8MHz ARM2… |
Martin Philips (9013) 48 posts |
I agree, a re-write in C would be better…. but if you were meaning a translation from Arm32 into C equivalent statements, then I agree, that could also work, even if the code might be horrible to look at… I did ask ChatGPT to have a go and it did a fairly reasonable job (to my untrained eye!) |
Martin Philips (9013) 48 posts |
As a quick trial, I asked ChatGPT to have a go at some asm from the RISC OS Basic: Original:
(from https://gitlab.riscosopen.org/RiscOS/Sources/Programmer/BASIC/-/blob/master/s/Funct) |
Martin Philips (9013) 48 posts |
ChatGPT’s transliteration:
Points to note: 1. Data registers are prefixed with W when considering them as 32-bit, and X for 64-bit. 2. I replaced MOV instructions involving the Program Counter with CSEL for conditional operations in AArch64. 3. The STMFD and LDMFD in AArch32 are replaced by multiple STP and LDP instructions in AArch64, respectively. 4. The end of the function now has a RET instruction, which returns using the link register X30 in AArch64. |
Martin Philips (9013) 48 posts |
Not that I think ChatGPT can be relied upon, but it can give some useful info and ideas about how to handle various issues.. |
Stuart Swales (8827) 1349 posts |
Anything that can confuse TEQ with TST needs to go in the bin! |
Clive Semmens (2335) 3276 posts |
On the contrary, what it looks as though it does is fix the easy parts (possibly correctly, I’ve not checked), and leaves the parts that require an understanding of what’s going on at a higher level of abstraction in a complete mess. Which is exactly the parts that I can’t see how to write an automatic translator for too. |
Stuart Swales (8827) 1349 posts |
I think the required preprocessor here is a human. |
Clive Semmens (2335) 3276 posts |
My thunk almost exactly. Quite a few very patient humans more like? |
Martin Philips (9013) 48 posts |
Fair enough! But if you were writing a parser, it would just use the right instr, right? |
Martin Philips (9013) 48 posts |
In this example, which bits of higher level abstraction are going astray? I’m not proposing using ChatGPT by the way.. just using it to show the equivalence of (many) ARM32/ARM64 instrs… |
Clive Semmens (2335) 3276 posts |
Where there’s a right instruction, of course you’d use it. Often you’d need two or more instructions – and unless you’re going to produce very inefficient code, even more often you’d want to spot where you could merge two or more instructions into one or two. That’s nasty enough. The thing that would worry me most is spotting where there are implicit addresses that you’d only know about if you could see what the original author of the code wrote, that just isn’t there in a disassembly. |
Martin Philips (9013) 48 posts |
Yes, but I’m suggesting translating from the Source… |
Stuart Swales (8827) 1349 posts |
BASIC is peculiar in the RISC OS source for its lack of use of macros, being a Sophie thing. We used macros far more extensively elsewhere. |
Martin Philips (9013) 48 posts |
How does that help or hinder the translation process? |
Chris Gransden (337) 1202 posts |
The RPi 5 overclocks quite well. Runs stable @2.9GHz. Compiles a Rpi rom in about 3mins.
|
Rick Murray (539) 13806 posts |
I think for a straight translation from 32 bit to 64 bit we’d be flying into a maelstrom of difficulties. What exactly gets stacked given the differences, how the many conditionals are handled, and of course the big lurking fact that we’re ultimately going to have to accept partial solutions to only use 32 bit registers and addressing, or switch to 64 bit. All of those, and the other dozen or so things I’m too tired to think of, will turn a “simple translation” into a nightmare.
Good. Because ChatGPT is what one uses when they don’t understand the code or what it’s actually doing and they’re hoping for an easy solution.
Just out of interest, have you tried IA64? MIPS? RISC-V? I kind of imagine these days architectural differences are simply variations on much the same idea.
Can’t help but think that AI is failing if it can’t read chunks of code in assembler, and output something that sort of does the same thing in C. Because, I’m sorry, but so much water has passed under this bridge that it’s eroded away the fountains and the bridge has collapsed… We’re in this mess exactly because it’s a massive pile of machine code. If it becomes a different pile of machine code….well, then that’s two messes. |
Pages: 1 ... 8 9 10 11 12 13 14 15 16 17 18 19 20