File tree Expand file tree Collapse file tree 2 files changed +79
-40
lines changed Expand file tree Collapse file tree 2 files changed +79
-40
lines changed Original file line number Diff line number Diff line change
1
+ ;
2
+ ; Ullrich von Bassewitz, 2003-03-07
3
+ ;
4
+ ; Push arguments and call main()
5
+ ;
6
+
7
+
8
+ .export callmain , _exit
9
+ .export __argc , __argv
10
+
11
+ .import _main , pushax , done , donelib
12
+ .import zpsave , rvsave , reset
13
+
14
+ .include "zeropage.inc"
15
+ .include "apple2.inc"
16
+
17
+
18
+ ;---------------------------------------------------------------------------
19
+ ; Setup the stack for main(), then jump to it
20
+
21
+ callmain:
22
+ lda __argc
23
+ ldx __argc + 1
24
+ jsr pushax ; Push argc
25
+
26
+ lda __argv
27
+ ldx __argv + 1
28
+ jsr pushax ; Push argv
29
+
30
+ ldy # 4 ; Argument size
31
+ jsr _main
32
+
33
+ ; Avoid a re-entrance of donelib. This is also the exit() entry.
34
+ _exit: ldx #<exit
35
+ lda #>exit
36
+ jsr reset ; Setup RESET vector
37
+
38
+ ; Switch in LC bank 2 for R/O in case it was switched out by a RESET.
39
+ bit $ C080
40
+
41
+ ; Call the module destructors.
42
+ jsr donelib
43
+
44
+ ; Switch in ROM.
45
+ bit $ C082
46
+
47
+ ; Restore the original RESET vector.
48
+ exit: ldx # $ 02
49
+ : lda rvsave , x
50
+ sta SOFTEV , x
51
+ dex
52
+ bpl : -
53
+
54
+ ; Copy back the zero-page stuff.
55
+ ldx #zpspace - 1
56
+ : lda zpsave , x
57
+ sta sp , x
58
+ dex
59
+ bpl : -
60
+
61
+ ; ProDOS TechRefMan, chapter 5.2.1:
62
+ ; "System programs should set the stack pointer to $FF at the
63
+ ; warm-start entry point."
64
+ ldx # $ FF
65
+ txs ; Re-init stack pointer
66
+
67
+ ; We're done
68
+ jmp done
69
+
70
+ ;---------------------------------------------------------------------------
71
+ ; Data
72
+
73
+ .data
74
+ __argc: .word 0
75
+ __argv: .addr 0
Original file line number Diff line number Diff line change 4
4
; Startup code for cc65 (Apple2 version)
5
5
;
6
6
7
- .export _exit, done, return
7
+ .export done , return
8
+ .export zpsave , rvsave , reset
8
9
.export __STARTUP__ : absolute = 1 ; Mark as startup
9
10
10
- .import initlib, donelib
11
+ .import initlib , _exit
11
12
.import zerobss , callmain
12
13
.import __ONCE_LOAD__ , __ONCE_SIZE__ ; Linker generated
13
14
.import __LC_START__ , __LC_LAST__ ; Linker generated
33
34
jsr zerobss
34
35
35
36
; Push the command-line arguments; and, call main().
36
- jsr callmain
37
-
38
- ; Avoid a re-entrance of donelib. This is also the exit() entry.
39
- _exit: ldx #<exit
40
- lda #>exit
41
- jsr reset ; Setup RESET vector
42
-
43
- ; Switch in LC bank 2 for R/O in case it was switched out by a RESET.
44
- bit $C080
45
-
46
- ; Call the module destructors.
47
- jsr donelib
48
-
49
- ; Switch in ROM.
50
- bit $C082
51
-
52
- ; Restore the original RESET vector.
53
- exit: ldx #$02
54
- : lda rvsave,x
55
- sta SOFTEV,x
56
- dex
57
- bpl :-
58
-
59
- ; Copy back the zero-page stuff.
60
- ldx #zpspace-1
61
- : lda zpsave,x
62
- sta sp ,x
63
- dex
64
- bpl :-
65
-
66
- ; ProDOS TechRefMan, chapter 5.2.1:
67
- ; "System programs should set the stack pointer to $FF at the
68
- ; warm-start entry point."
69
- ldx #$FF
70
- txs ; Re-init stack pointer
71
-
72
- ; We're done
73
- jmp done
37
+ jmp callmain
74
38
75
39
; ------------------------------------------------------------------------
76
40
You can’t perform that action at this time.
0 commit comments