-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Acorn C 2.0 crashes in B-Em #233
Comments
Update: BeebEm's regress in the ARM emulation has been fixed (in case the emulation code has been taken from there) though there is still some problem with the Y2K RTC workaround that causes a problem for the compiler. |
Yes you are right, that was my fault. Running fpe before the compiler works. |
On the fpe, I wouldn't say it was your fault - it just seems that the aborted run of the compiler has left things in a a strange state. The ARM eval ROM doesn't work on the Sprow ARM emulation. Reading up on the ARM, it may be that the ARM eval ROM assumes 26-bit addresses where R15 also contains the flags, and the newer Sprow ARM does not offer compatibility with the 26-bit mode. There are some possibilities as to how work out what is going wrong:
|
As far as I know there is no test suite publically available for the original ARM1 processor. But there is one for the ARM2 if that helps, it's from the Amber project, which reimplemented the ARM2 in Verilog. May that help? |
Some other useful data points might be to test:
I'll try to do that tomorrow. Dave |
Ok, I modified the memory read/write functions to trap to the debugger when attempting to read or write an invalid memory address and also had the debugger trace instructions to a file. The trap was not triggered by the ROM or any of the preparation command but was triggered by the compiler:
the 74 is the PC, not the location being read. The last instructions logged were:
So it has executed a branch. Looking at the code leading up to the branch:
To me that looks like it could be valid code. After the branch:
it looks less like valid code to me. It looks to be using the mul instruction that is ARM2. I realise from this that there some things I am not sure about. According to WikiChip, the ARM1 was produced in very small numbers which would be consistent with it being in the ARM Evaluation System but is that right? Is this compiler ARM1 code or ARM2? |
Doing some reading, it seems the ARM evaluation system is definitely ARM1 but on the possibility that the C compiler is expecting ARM2 I looked at WikiChip (https://en.wikichip.org/wiki/arm/armv2) and the differences seem to be confined to the four multiply instructions (MUL, MULS, MLA, MLAS) and the instructions for communicating with a co-processor. Interestingly, the B-Em ARM emulation had code for the multiply instructions commented out. Adding a debug message if there is an attempt to use these gave this in the log:
|
A couple of observations:
So this was designed to run on Arthur 1.2 on the first generation of Archimedes machines (A305/A310/A440) which were ARM2. RobC has successfully run this on the Matchbox Co Pro ARM Eval system, but that's actually also an ARM2 core, so is a bit misleading. See this link. It's possible this would run on the original ARM Eval system if the multiply instruction caused an undefined instruction trap and was emulated in software. Maybe that's the difference here.... What does b-em do with an ARM2 multply instruction? What does beebem do with an ARM2 multply instruction? What does the real ARM1 CPU do with an ARM2 multiply? |
BeebEm uses David Sharp's Tarmac emulator, which does emulate MUL, also SWP. Related BeebEm issue: stardot/beebem-windows#140 |
For reference, the documentation for the original ARM1 CPU: (thanks to Graham Toal for scanning this, and BigEd for uploading) My reading of this is that the opcode that became multiply in ARM2 would is a ligitimate AND instruction in ARM1. So I don't think it would trap. |
Should have nothing to do with the load/exec address reused as timestamps. If the 12 upper bits of the load/exec address are 1's, it's interpreted as an timestamp as then the load/exec address is invalid (out of addressable memory range). The error you are seeing is (at least in BeebEm) due to some Y2K fix and the linker "thinks" that the timestamp in the library is in the future and refuses to use it. |
Very interesting case, as the compiler explicitely has switches to produce binaries for the Brazil supervisor used in the ARM evaluation board ("-super"). The obvious question if this should be fixed at all in B-Em arises as fixing it would definitely would violate the precision of the emulation as it's not a emulated ARM1 anymore. |
B-Em has Y2K fixed and as-original versions of both the Master MOS ROMs (w/MOS 3.22 and w/MOS 3.52 are the fixed versions). Of course, the linker may also have a Y2K bug. The "ARM Evaluation System" model will use standard MOS 3.20 but you can get 3.22 by selecting "BBC Master 128 w/MOS 3.22" and then selecting ARM separately as the tube. |
When you commented out multiply, did that include the The error with multiply commented out on PiTubeDirect is not the same as the error with B-Em. Also, uncommenting the implementation of multiply in B-Em does not fix the problem. Chris mentions the SWP instruction. Maybe there are other differences between ARMv1 and ARMv2 that WikiChip did not mention? |
Yes, that's exactly what I did.
I was wondering if that's just because the system ended up jumping "into the weeds" so the exact error might vary depending on the memory contents. But is could very well be something else.
OK, so it looks like there is something else going on in b-em.
SWP was apparently added in ARM3 (1989) so I guess that's not likely to be used in a C compiler from 1988. Dave |
OK, let me try to look at the b-em issue....
Look's like b-em is using the 8th August 1986 Brazil version of the ARM Tube ROM, which is different to PiTubeDirect: So lets switch to than original 6th June 1986 version: Source:
Yes, we now get the object file corrupt error:
I think that all makes sense now. |
Thanks for that. So, there is also an issue with the compiler and the August version of the ROM. That is not something I would have thought of. |
Apparantly so, but what exactly I have no idea. It could be:
Maybe your trace could answer this, if you looked back a few hundred instuctions before the crash? |
IanB found the sources for the Brazil kernel (including the 14th August 1986 date), which are posted here: I think this may be for the A500 Co Pro (which included MEMC/VIDC/IODC chips) rather than the ARM1 Eval Co Pro. But it was clearly derived from the ARM1 Eval client ROM, and seems to maintain the ability to build for that. I would suggest you switch to the original ARM 1.00 tube ROM. |
I have pushed a branch that contains a fix for this, in the form of a selectable ARM2 tube processor that still runs the ROM from the ARM evaluation system (July version). |
Drifting slightly here, I notice in the data processing group of ARM instructions the 'S' versions, which set the flags, are consistently distinguished from the versions that don't by bit 20 in the instruction encoding being set. Using this scheme it would possible to encode the non-S versions of the TST, TEQ, CMP and CMN instructions. Before the SWAP instructions were introduced, it would be logical for these instructions to be effectively NOPs, i.e. storage of the result of the AND, EOF - or + is suppressed because it is a test instruction and setting the flags is suppressed as it is the non-S version. Is this actually the case, though? |
Problem
Acorn C 2.01A for the ARM evaluation board crashes in B-Em (compiler and linker, both crash) with the following message:
How to reproduce
Download the SCSI image from: https://garm.twilightparadox.com/nextcloud/s/YsMKPeoi4GL97M4 which has Acorn C 2.01A installed
Turn on the ARM 2nd processor, mount the image and run:
Expected result
Compiler produces a working output without crashing
Notes
The text was updated successfully, but these errors were encountered: