15 December 2019, 22:29 | #1 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
System takeover crashes in some cases
I have a source for a system takeover and restore here: https://github.com/skeetor/amiga-uti...stemTakeover.s
Now, when I compile and execute this with my gcc projects it appears to work. Started it several times and had no problem. https://github.com/skeetor/amiga-uti...evelop/VAsmGCC Strangely, when I use this in an ASM only project, I always get a Task Held requestor and a guru meditation. https://github.com/skeetor/amiga-uti...velop/VAsmOnly I debugged it in metascope and there it worked, and on the shell I also ran it and I had some times where it worked, but mostly it seems to crash, though I don't know why. Nay ideas whats wrong with this? |
15 December 2019, 22:44 | #2 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 828
|
@sparhawk
It is really not a good idea to store hardware registers when dma and/or ints are active. Because some int and/or copperlist can change them and you will stay with invalid values. Personally I think that is really good thing to check how others handle with system takeover, for example how StingRay takeover system in his MiniStartup. |
15 December 2019, 22:48 | #3 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Actually I was taking this from some sample code, expecting that it works, but I will look at this startup you mentioned.
|
17 December 2019, 01:00 | #4 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
For example: did you compile with register arguments enabled? ASMstrlen expects the pointer in a0, while the standard C-ABI for 68k is to pass all arguments on the stack. Quote:
|
|||
17 December 2019, 12:59 | #5 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Running on KS 1.3. And it was always Guru 4. Anyway, I will look at the ministartup and work from there.
The compilation is done via the CMake project, from that repository. Using bebbos gcc compiler suite as a base with MSYS2. But the guru only happens in the ASM project only, so there is no additional startup code involved. https://github.com/skeetor/amiga-uti...AsmOnly/main.s Actually I was a bit surprised about this code anyway, as I would expect to use Forbid()/Disable() pretty early. But I'm not sure what system functions can still be called after that. |
18 December 2019, 17:02 | #6 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
I would even try to build your VasmOnly-test myself, but as mentioned before there is too much information missing or hidden. How do you call vasm or the linker? Which options? Any libraries you are linking with? Does it also crash if you comment the calls to SystemSave/SystemRestore out? EDIT: Managed to assemble and link all your sources (main.s, strlen.s, SystemTakeover.s). The resulting executable is attached (516 Bytes). Tested on an emulated A500 with WB 1.3 in the shell. No problems. Code:
vasmm68k_mot -Fhunk -o main.o main.s vasmm68k_mot -Fhunk -o strlen.o strlen.s vasmm68k_mot -Fhunk -o SystemTakeover.o SystemTakeover.s vlink -bamigahunk -o VasmOnly.68k -s -x main.o strlen.o SystemTakeover.o Last edited by phx; 07 December 2020 at 11:49. |
|
18 December 2019, 19:34 | #7 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
I'm now converting the ministartup. I was not running it from WB, only from shell, and sometimes it worked, but I don't really know why.
|
18 December 2019, 22:08 | #8 | |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 828
|
Quote:
Perhaps you did some mistake(s). Its hard to guess without source. Please post the source. |
|
18 December 2019, 22:38 | #9 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
I have to convert it, because it doesn't assemble with vasm. Or maybe it needs some special options?
The current version can be found here, but it's not finished yet. https://github.com/skeetor/amiga-uti...AmigaUtils/src |
19 December 2019, 00:02 | #10 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
I converted this now, and it works now! Thanks for the help!
I still want to do some minor cosmetic changes, but at least I can now start to experiment with the stuff I wanted to. So next I want to get some Copper stuff working. The bars, Asman was mentioning, wil be next. |
19 December 2019, 09:44 | #11 | |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 828
|
Quote:
It is just black interleaved screen. |
|
19 December 2019, 21:44 | #12 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
I tested the startup code and it worked in the example where I use only assembler. I have another example project, where I use gcc interfacing with assembler, and strangely it did not work there, instead it just got stuck. So I debugged it and found the reason why this was the case.
In the original code, I had this: Code:
move.w #$7FFF,d0 bsr WaitRaster Code:
move.w #$7FFF,d0 jsr WaitRaster So any idea, why I didn't even get a warning or an error in that case? I'm not even sure where the problem may be. The assembler doesn't know the address of the symbol at compile time, so it probably can not warn me. Since this is in an library, it will not know it, until it is actually linked. So I would expect that I get an error at link time at latest, right? |
19 December 2019, 23:51 | #13 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Which linker is it and which command line options does it get? |
|
20 December 2019, 07:37 | #14 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Code:
m68k-amigaos-g++ --save-temps -Wall -pedantic -mcrt=nix13 -O3 -mregparm -O3 -DNDEBUG CMakeFiles/VASMGcc.dir/main.cpp.o CMakeFiles/VASMGcc.dir/strlen.cpp.o CMakeFiles/VASMGcc.dir/strlen.asm.o -o bin/VASMGcc.exe -Wl,--out-implib,bin/libVASMGcc.dll.a /opt/amiga/utils/lib/libAmigaUtils.a /opt/amiga/utils/lib/libAmigaGCCUtils.a Last edited by sparhawk; 20 December 2019 at 07:43. |
20 December 2019, 13:04 | #15 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 680
|
Quote:
Well, m68k-amigaos-ld inserts long jump tables and adjusts the word/short jumps to the next jump table (do you remember?) Maybe there's an error... |
|
20 December 2019, 13:30 | #16 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Is there an option? ALVs shouldn't be enabled by default, IMHO. |
||
20 December 2019, 19:01 | #17 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
I have fixed the issues when building with CMake under Linux, so this should work now. I built the executables under Linux as well, and tested them, and the same problem persists.
I also created a screenshot to illustrate it better, but I hope that you can now also build it, following the instructions on the repo. The left side shows that the "bsr" points to "somewhere" while the right side "jsr" correctly points to "_WaitRaster". |
20 December 2019, 22:10 | #18 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 680
|
Ok, I tracked it down
Consider this example code: Code:
_X: nop nop bsr foo rts vasm: Code:
0: 4e71 nop 2: 4e71 nop 4: 6100 0000 bsr.w 0x6 8: 4e75 rts Code:
0: 4e71 nop 2: 4e71 nop 4: 6100 fffa bsr.w 0x0 8: 4e75 rts You may call this a bug or feature - but vasm and as aren't compatible if a bsr is used to an extern symbol. |
20 December 2019, 22:19 | #19 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Can I easily convert the code to AS? As far as I understood it, AS is not really designed to be used for "human" assembly programming, as it is mostly designed to be used by gcc right? That's actually the reason why I was using vasm instead, assuming that it is a good choice for Amiga programming and compatible with gcc.
Since I'm still at the start, I could switch to AS if it is worth it, so I wonder if that should be the way to go. Such a bug is a bit frightening, if it compiles without warning whatsoever. Still, thanks for your analysis. And also for the feedback on my cmake build as I now have at least some feedback from some external source. "Works on my machine" never guarantees that the next guy can also use it. |
21 December 2019, 00:03 | #20 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
To calculate the addend of pc-relative relocs relative to the section-base is only done in a.out format. This is not how hunk-format works. Probably some old a.out code is lurking somewhere... |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
System takeover and multi floppy mess | ross | Coders. General | 8 | 15 September 2018 20:01 |
Converting a "system-takeover" game to OS friendly | alpine9000 | Coders. General | 13 | 01 January 2018 01:06 |
System takeover/shutdown | alpine9000 | Coders. Asm / Hardware | 5 | 07 June 2016 09:03 |
trackdisk.device after system takeover | alpine9000 | Coders. Asm / Hardware | 20 | 21 March 2016 09:17 |
startup/system takeover | sidewinder | Coders. General | 15 | 28 February 2016 16:33 |
|
|