home *** CD-ROM | disk | FTP | other *** search
- | baserelativer Startup_code für Gcc V2.3.3
- | (c) by Gerhard Müller Fri Jun 4 23:39:41 1993
- | No real bugs known
- |
- | rearly bases on the original startup-Code provided by m.wild.
- |
- | Important: don't use any DOS-funktion here ! (First get WBStartup_Msg!)
- |
- | Thu Jun 24 18:37:43 1993 bases on the resident startup-code
- | all code not needed is marked with | at the start of the line
- |
- | Sun Dec 12 16:35:56 1993 GM: Bug fix: don't use tstl ax, as these command
- | doesn't exist on a 68000 !
-
- .text
-
- | retten der Register a0/d0
-
- movel 4:W,a6
- movel d0,d7
- movel a0,a5
-
- |******** new ******* not resident ************
- lea ___a4_init,a4
-
- |
- | | wieviel Data+BSS ? merken in D5
- |
- | movel #___data_size,d0
- | addl #___bss_size,d0
- | movel d0,d5
- |
- | | dafür Speicher holen (Länge: d0)
- |
- | moveq #0,d1
- | jsr a6@(-0xc6) |AllocMem
- |
- | | Kein Speicher ? -> ENDE ! (20)
- |
- | movel d0,d6
- | jeq err_exit
- |
- | | Speicher umkopieren via CopyMem
- |
- | lea ___a4_init,a0
- | subl #0x7ffe,a0
- | movel d6,a1
- | movel d5,d0
- | jsr a6@(-0x270)
- |
- | | Nun die Relocs korrigieren.... Source siehe Original-File
- |
- | | d2=a4=origmem, d3= databbs_size a2=new mem
- | lea ___a4_init,a0
- | subl #0x7ffe,a0
- | movel a0,d2
- | movel d5,d3
- | movel d6,a2
- |
- | movel #___datadata_relocs,a0
- | tstl a0@ | if relocs[0] > 0
- | jle Relocs_Ende
- | movel a0@+,d1 | num_rel = relocs[0], relocs++
- | moveq #0,d0 | for(i=0;
- | cmpl d0,d1 | i < num_rel
- | jle Relocs_Ende
- | subl a2,d2 | origmem - mem
- |Reloc_Schleife:
- | movel a0@+,a1 | ... relocs++
- | subl d2,a1@(a2:l) | *(long *)(mem + *relocs) -= origmem - mem;
- | addql #1,d0 | i++
- | cmpl d0,d1
- | jgt Reloc_Schleife
- |Relocs_Ende:
- |
- | | und a4 endgültig setzen
- |
- | movel d6,d0
- | addl #0x7ffe,d0
- | movel d0,a4
- |
- | | SysBase und StackPtr initialisieren
-
- movel 4,a4@(_SysBase:W)
- movel a7,a4@(StackPtr_for_exit:W)
-
- | # Variablen retten
- |
- | movel d5,a4@(MemLen:W)
- | movel d6,a4@(MemAdr:W)
-
- # dos.library öffnen
-
- moveq #0,d0
- lea DOSName,a1
- jsr a6@(-0x228)
- movel d0,a4@(_DOSBase:W)
-
- movel d0,a6
- jsr a6@(-0x36) | Input()
- movel d0,a4@(_stdin:W)
- jsr a6@(-0x3c) | Output()
- movel d0,a4@(_stdout:W)
-
- # __main aufrufen
-
- movel d7,sp@-
- movel a5,sp@-
- jsr __main
- movel d0,sp@-
- jsr _exit | kehrt niemals zurück ! Nur wichtig für Stack.
-
- .globl __exit
- __exit:
- | dos.library schließen
-
- movel 4,a6
-
- movel a4@(_DOSBase:W),d0
- beq __exit4
- movel d0,a1
- jsr a6@(-0x19e) | CloseLibrary(a1)
-
- __exit4:
- | Speicher-Handling: Alles in Register holen
-
- | movel a4@(MemLen:W),d6
- | movel a4@(MemAdr:W),a3
-
- movel a4@(StackPtr_for_exit:W),a2
-
- | WB-Message ?
-
- movel a4@(_WBenchMsg:W),a5
-
- | | nun aber erst Speicher freigeben
- |
- | movel a3,a1
- | movel d6,d0
- | jsr a6@(-0xd2) | FreeMem
-
- | Weiter mit WB-Msg. Gibt es sie ?
-
- movel a5,d0
- tstl d0
- jeq __exit2
-
- __exit5:
- jsr a6@(-0x84) | Forbid
- movel a5,a1
- jsr a6@(-0x17a) | ReplyMsg
- __exit2:
- movel sp@(4),d0
- __exit3:
- movel a2,a7
- rts
-
-
- err_exit:
- | handles WB-Startup if necessary
-
- movel 4:W,a3 | ExecBase
- movel a3@(276),a2 | SysBase->ThisTask
- tstl a2@(172) | if (! me->pr_CLI)
- jne err_exit_no_wb
-
-
- | WaitPort (& me->pr_MsgPort);
-
- addw #92,a2
- movel a3,a6
- movel a2,a0
- jsr a6@(-0x180)
-
-
- | WBenchMsg = (struct WBStartup *) GetMsg (& me->pr_MsgPort);
-
- movel a2,a0
- jsr a6@(-0x174)
- movel d0,a5
-
- jsr a6@(-0x84) | Forbid
- movel a5,a1
- jsr a6@(-0x17a) | ReplyMsg
- rts
-
-
- err_exit_no_wb:
- moveq #20,d0
- rts
-
- |******** new ******* not resident ************
- .globl _geta4
- _geta4:
- lea ___a4_init,a4
- rts
-
- DOSName: .ascii "dos.library\0"
- .even
-
- .data
- .even
- StackPtr_for_exit: .long 0
- |MemAdr: .long 0
- |MemLen: .long 0
- .globl _SysBase
- _SysBase: .long 0
- .globl _WBenchMsg
- _WBenchMsg:
- .long 0
-
- |.globl __exit_dummy_ref
- |.data
- | .even
- |__exit_dummy_ref:
- | .long __exit_dummy_decl
- |.comm __exit_dummy_decl,4
-
- .comm _DOSBase,4
- .comm _stdin,4
- .comm _stdout,4
-