27 March 2019, 17:14 | #1 |
Oldtimer
Join Date: Nov 2010
Location: VXO / Sweden
Posts: 153
|
Run different executables by Kickstart Version
Hi,
I've tried for a couple of years now to get a licens to include som Shell executables to be able to make a disk (ADF) distribution that uses SetPatch. But now I have given up! The Startup-Sequence starts like this: Code:
Version >NIL: 36 20 IF WARN Echo " Running on Kickstart 1.x..." C:SetPatch_1x >NIL: Else and so on... All Kickstarts before 36.20 should use SetPatch_1x command and all newer SetPatch_2x+ (SetPatch licens enables free distribution AFAIK). Is this a good solution? Code:
; exec.library OldOpenLibrary = -$198 CloseLibrary = -$19e LIB_VERSION = $14 LIB_REVISION = $16 ; dos.library LoadSeg = -$96 UnLoadSeg = -$9c CreateProc = -$8a Start: movem.l d1-d7/a0-a6,-(sp) move.l 4.w,a6 lea setpatch2x(pc),a2 cmp.w #36,LIB_VERSION(a6) bhi continue bcs pre2 cmp.w #20,LIB_REVISION(a6) bhi continue pre2: lea setpatch1x(pc),a2 continue: move.l #dosname,a1 jsr OldOpenLibrary(a6) ; a1=libName move.l d0,a6 move.l a2,d1 jsr LoadSeg(a6) ; d0=seglist = LoadSeg( d1=name ) move.l d0,d3 beq closeandexit move.l a2,d1 move.l #0,d2 move.l #4096,d4 jsr CreateProc(a6) ; d0=process = CreateProc( d1=name, d2=pri, d3=seglist, d4=stackSize ) move.l d3,d1 jsr UnLoadSeg(a6) ; d0=success = UnLoadSeg( d1=seglist ) closeandexit: move.l a6,a1 move.l 4.w,a6 jsr CloseLibrary(a6) exit: movem.l (sp)+,d1-d7/a0-a6 moveq.l #0,d0 rts dosname: dc.b "dos.library",0 setpatch1x: dc.b "C:SetPatch_1x",0 setpatch2x: dc.b "C:SetPatch_2x+",0 Is there a better way to solve this and be compatible with "all" kickstarts? Thanks /Geijer |
02 June 2019, 20:57 | #2 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,215
|
No, it is not a good solution, because... you just said it. The segment is in use, so you cannot just release it. Why do you make things complicated? The dos.library v34 already included Execute(), which does everything you need. Just pass it the setpatch name as first argument, and 0 both for input and output.
|
03 June 2019, 07:35 | #3 |
Oldtimer
Join Date: Nov 2010
Location: VXO / Sweden
Posts: 153
|
|
26 June 2019, 23:43 | #4 | |
Oldtimer
Join Date: Nov 2010
Location: VXO / Sweden
Posts: 153
|
Quote:
|
|
27 June 2019, 12:13 | #5 |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 43
Posts: 922
|
There is no free run replacement?
|
27 June 2019, 12:24 | #6 |
Oldtimer
Join Date: Nov 2010
Location: VXO / Sweden
Posts: 153
|
I have given up and will continue without running SetPatch on pre 36 kickstarts.
|
27 June 2019, 12:58 | #7 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Instead of calling CreateProc, you can try calling the loaded code directly. After all, the bcpl return value of LoadSeg is a disguised pointer to the seglist.
So you can multiply it by 4 to get the seglist, do +4 to go to the start of the code, then simply call it. Something like this : Code:
jsr LoadSeg(a6) tst.l d0 beq closeandexit move.l d0,-(a7) lsl.l #2,d0 addq.l #4,d0 move.l d0,a0 jsr (a0) move.l (a7)+,d1 jsr UnLoadSeg(a6) |
27 June 2019, 14:10 | #8 |
Oldtimer
Join Date: Nov 2010
Location: VXO / Sweden
Posts: 153
|
Interesting, thanks.
|
27 June 2019, 14:33 | #9 | |
Oldtimer
Join Date: Nov 2010
Location: VXO / Sweden
Posts: 153
|
Quote:
|
|
27 June 2019, 15:31 | #10 |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 43
Posts: 922
|
It might be that SetPatch uses the arguments sent to first function in an exe - d0 (doscmdlen) and a0 (doscmdbuf, should be the argument string which ends with \n\0).
Also it probably doesn’t hurt to save all non-scratch-registers (d2-d7,a2-a6) before calling and restoring afterwards before you call anything more, I am not sure the first exe function is required to save and restore all non-scratch-registers. |
27 June 2019, 15:50 | #11 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Well, at least i forgot a6 in the code. Better should be :
Code:
jsr LoadSeg(a6) tst.l d0 beq closeandexit movem.l d0/a6,-(a7) lsl.l #2,d0 addq.l #4,d0 move.l d0,a0 jsr (a0) movem.l (a7)+,d1/a6 jsr UnLoadSeg(a6) |
27 June 2019, 15:51 | #12 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
For my productions I've made a Setpatch1.38+FastMemFirst replacement for KS1.x.
Tiny (1084 bytes), 588 resident memory bytes used, fully compatible with the original. rossPatch hunk0\trampoline (acrx2): 516 bytes rossPatch hunk1\resident_module (acrx2): 588 bytes Harmless on KS2.0+. So a simple solution can be to launch in s-s rossPatch and SetPatch_43.6b in sequence and all systems are patched. |
29 June 2019, 19:04 | #13 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,215
|
Setpatch uses, same as most other executables, ReadArgs() to parse its command line. It does not use arguments fro *a0 and d0. The ReadArgs() parameters are in the (buffered) input stream of process->pr_CIS. It is not so easy to clone a suitable execution environment for ReadArgs(). dos.library RunCommand() does that for you. But then again, System() or Execute() is a much simpler solution. It loads the program and runs it. Execute() already works for kickstart 1.3, though there needs C:Run to be available (at least until SetPatch v34 run).
|
29 June 2019, 19:15 | #14 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,215
|
It would be hard to write one as Run depends on some internals on how to start a shell, and the details changed from 1.x to 2.x. In 1.x, Run is a BCPL program that looks for the shell in the system seglist, then builds a startup-message for the shell and launches (the BCPL) shell through createtask, a function only available on the globvec.
From 2.x up, Run goes through System() (as it should), and let System() do the magic of creating a startup message. Unfortunately, the way how the startup message for the shell needs to look like differs between the systems. The Manx C compiler had an (albeit somewhat buggy) fexec() command which let you execute a binary without requiring Run, dos V37 and up has RunCommand(), which is also used by the shell to execute a program in its own context. I should have an assembler version of fexec() somewhere, but beware, I do not even know whether this works under 2.x as it is mostly not maintained anymore, and it also depends on some deep system knowledge that may no longer be up to date. |
30 June 2019, 00:17 | #15 |
Oldtimer
Join Date: Nov 2010
Location: VXO / Sweden
Posts: 153
|
Thank you so much for your commitment to the issue, I have now solved it as @ross and @thomas suggested. Starts by always running SetPatch 1.38 and then Execute() SetPatch for 2.0+ if Kickstart is 36+.
Have tested it in several configurations and it seems to work as expected. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Kickstart 1.3 (v34) Execute without c:run | matburton | Coders. System | 15 | 30 April 2018 10:58 |
A500 Kickstart 2.04 won't run any disk | drfresh | support.Hardware | 3 | 29 December 2016 10:45 |
How to get Dungeon Master II to run as fast as the PC version? | dex | support.WinUAE | 9 | 08 September 2016 21:03 |
run executables as df0: | jbl007 | support.WinUAE | 6 | 10 March 2015 20:39 |
What is the best Windows version to run WinUAE ? | Torkio | support.WinUAE | 2 | 08 May 2013 15:30 |
|
|