Skip to content

Commit e9d4626

Browse files
committed
Refine DOS 3.3 and AppleSingle examples
- Remove note requiring alignment to $0803 or $xx00 - Replace confusingly used ORIGIN label with PGM_START - Minor cleanup & make samples consistent with each other
1 parent 9d12461 commit e9d4626

2 files changed

Lines changed: 65 additions & 51 deletions

File tree

presets/apple2/applesinglebin.a

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
; --------------------------------------------------
2+
; Example showing how to create an AppleSingle binary
3+
; header and program that is automatically loaded
4+
; into the desired PGM_START memory address.
5+
; --------------------------------------------------
16

2-
processor 6502
7+
processor 6502
8+
9+
; --------------------------------------------------
10+
; Set PGM_START to desired start of program execution
11+
; - PGM_START must be less than $C000
12+
; - PGM_START + SIZE must be less than $13000
13+
; --------------------------------------------------
14+
PGM_START equ $2000
15+
PGM_LENGTH equ PGM_END - PGM_START
316

417
seg
5-
org $4000
18+
org PGM_START - 58 ; Subtract 58 bytes for header
619

720
; --------------------------------------------------
821
; AppleSingle version 2 file header
@@ -22,97 +35,95 @@ __HEADER_BEGIN
2235
.byte 0, 2 ; Number of entries
2336
.byte 0, 0, 0, 1 ; Entry ID 1 - Data Fork
2437
.byte 0, 0, >__DATA_OFFSET, <__DATA_OFFSET ; Offset
25-
.byte 0, 0, >__DATA_LENGTH, <__DATA_LENGTH ; Length
38+
.byte 0, 0, >PGM_LENGTH, <PGM_LENGTH ; Length
2639

2740
.byte 0, 0, 0, 11 ; Entry ID 11 - ProDOS File Info
2841
.byte 0, 0, >__PRODOS_OFFSET, <__PRODOS_OFFSET ; Offset
2942
.byte 0, 0, >__PRODOS_LENGTH, <__PRODOS_LENGTH ; Length
3043
__PRODOS_INFO
3144
.byte 0, %11000011 ; Access - Destroy, Rename, Write, Read
32-
.byte >__FILETYPE__, <__FILETYPE__ ; File Type
45+
.byte 0, 6 ; File Type - BIN
3346
.byte 0, 0 ; Auxiliary Type high
34-
.byte >__PROGRAM_BEGIN, <__PROGRAM_BEGIN ; Auxiliary Type low
47+
.byte >PGM_START, <PGM_START ; Auxiliary Type low
3548
__HEADER_END:
3649

37-
__FILETYPE__ = $0006 ; BIN (Auxiliary type is the binary file's loading address)
38-
__DATA_LENGTH equ __PROGRAM_END - __PROGRAM_BEGIN
3950
__DATA_OFFSET equ __HEADER_END - __HEADER_BEGIN
4051
__PRODOS_LENGTH equ __HEADER_END - __PRODOS_INFO
4152
__PRODOS_OFFSET equ __PRODOS_INFO - __HEADER_BEGIN
4253

54+
PGM_LENGTH equ PGM_END - PGM_START
55+
4356

4457
; --------------------------------------------------
4558
; ROM routines
4659
; --------------------------------------------------
4760
HOME equ $FC58
4861

4962

50-
5163
; --------------------------------------------------
5264
; Start of program
5365
; --------------------------------------------------
54-
__PROGRAM_BEGIN
66+
PGM_START
5567

56-
start
5768
; --------------------------------------------------
5869
; Clear screen
5970
; --------------------------------------------------
6071
jsr HOME
6172

6273
; --------------------------------------------------
63-
; Print "START $" (7 chars) to $0400..$0406
74+
; Print "PGM_START $" (11 chars) to $0400..$040a
6475
; --------------------------------------------------
6576
ldx #0
6677
pfx_loop
6778
lda prefix,x
6879
ora #$80
6980
sta $0400,x
7081
inx
71-
cpx #7
82+
cpx #11
7283
bne pfx_loop
7384

7485

7586
; --------------------------------------------------
76-
; Print origin in hex to $0407 - $040A
87+
; Print origin in hex to $040b - $040e
7788
; --------------------------------------------------
7889

7990
; High byte high nibble
80-
lda #>start
91+
lda #>PGM_START
8192
lsr
8293
lsr
8394
lsr
8495
lsr
8596
tax
8697
lda hexchar,x
8798
ora #$80
88-
sta $0407
99+
sta $040b
89100

90101
; High byte low nibble
91-
lda #>start
102+
lda #>PGM_START
92103
and #$0F
93104
tax
94105
lda hexchar,x
95106
ora #$80
96-
sta $0408
107+
sta $040c
97108

98109
; Low byte high nibble
99-
lda #<start
110+
lda #<PGM_START
100111
lsr
101112
lsr
102113
lsr
103114
lsr
104115
tax
105116
lda hexchar,x
106117
ora #$80
107-
sta $0409
118+
sta $040d
108119

109120
; Low byte low nibble
110-
lda #<start
121+
lda #<PGM_START
111122
and #$0F
112123
tax
113124
lda hexchar,x
114125
ora #$80
115-
sta $040A
126+
sta $040e
116127

117128
; --------------------------------------------------
118129
; Endless loop (text stays on screen)
@@ -124,12 +135,12 @@ done jmp done
124135
; Data
125136
; --------------------------------------------------
126137
prefix
127-
.byte "START $"
138+
.byte "PGM_START $"
128139

129140
hexchar
130141
.byte "0123456789ABCDEF"
131142

132143

133144

134-
__PROGRAM_END
145+
PGM_END
135146
; Don't add instructions after this line

presets/apple2/dos33bin.a

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,98 @@
11
; --------------------------------------------------
22
; Example showing how to create a DOS 3.3 binary
33
; header and program that is automatically loaded
4-
; into the desired ORIGIN memory address.
4+
; into the desired PGM_START memory address.
55
; --------------------------------------------------
66

77
processor 6502
88

99
; --------------------------------------------------
10-
; Desired origin
11-
; - Origin must be less than $C000
12-
; - Origin + size must be less than $13000
13-
; - Origin must be $0803 or aligned to $xx00
10+
; Set PGM_START to desired start of program execution
11+
; - PGM_START must be less than $C000
12+
; - PGM_START + SIZE must be less than $13000
1413
; --------------------------------------------------
15-
ORIGIN equ $2000
16-
SIZE equ END_OF_PRORGAM-ORIGIN
14+
PGM_START equ $2000
15+
PGM_LENGTH equ PGM_END - PGM_START
16+
17+
seg
18+
org PGM_START - 4 ; Subtract 4 bytes for header
1719

1820
; --------------------------------------------------
1921
; DOS 3.3 binary header (4 bytes)
2022
; --------------------------------------------------
21-
org ORIGIN - 4 ; Subtract 4 ensures correct memory locations
22-
word ORIGIN ; Origin (2 bytes)
23-
word SIZE ; Size (2 bytes), must be length - 4
23+
word PGM_START ; Program start address in memory (2 bytes)
24+
word PGM_LENGTH ; Program length (2 bytes), must be file size - 4
2425

2526
; --------------------------------------------------
2627
; ROM routines
2728
; --------------------------------------------------
2829
HOME equ $FC58
2930

31+
3032
; --------------------------------------------------
31-
; Origin and start of program
33+
; Start of program
3234
; --------------------------------------------------
33-
org ORIGIN ; Starting address
34-
35+
PGM_START
3536

36-
start
3737
; --------------------------------------------------
3838
; Clear screen
3939
; --------------------------------------------------
4040
jsr HOME
4141

4242
; --------------------------------------------------
43-
; Print "START $" (7 chars) to $0400..$0406
43+
; Print "PGM_START $" (11 chars) to $0400..$040a
4444
; --------------------------------------------------
4545
ldx #0
4646
pfx_loop
4747
lda prefix,x
4848
ora #$80
4949
sta $0400,x
5050
inx
51-
cpx #7
51+
cpx #11
5252
bne pfx_loop
5353

5454

5555
; --------------------------------------------------
56-
; Print origin in hex to $0407 - $040A
56+
; Print origin in hex to $040b - $040e
5757
; --------------------------------------------------
5858

5959
; High byte high nibble
60-
lda #>start
60+
lda #>PGM_START
6161
lsr
6262
lsr
6363
lsr
6464
lsr
6565
tax
6666
lda hexchar,x
6767
ora #$80
68-
sta $0407
68+
sta $040b
6969

7070
; High byte low nibble
71-
lda #>start
71+
lda #>PGM_START
7272
and #$0F
7373
tax
7474
lda hexchar,x
7575
ora #$80
76-
sta $0408
76+
sta $040c
7777

7878
; Low byte high nibble
79-
lda #<start
79+
lda #<PGM_START
8080
lsr
8181
lsr
8282
lsr
8383
lsr
8484
tax
8585
lda hexchar,x
8686
ora #$80
87-
sta $0409
87+
sta $040d
8888

8989
; Low byte low nibble
90-
lda #<start
90+
lda #<PGM_START
9191
and #$0F
9292
tax
9393
lda hexchar,x
9494
ora #$80
95-
sta $040A
95+
sta $040e
9696

9797
; --------------------------------------------------
9898
; Endless loop (text stays on screen)
@@ -104,9 +104,12 @@ done jmp done
104104
; Data
105105
; --------------------------------------------------
106106
prefix
107-
byte "START $"
107+
.byte "PGM_START $"
108108

109109
hexchar
110-
byte "0123456789ABCDEF"
110+
.byte "0123456789ABCDEF"
111+
112+
111113

112-
END_OF_PRORGAM ; Don't add instructions after this line
114+
PGM_END
115+
; Don't add instructions after this line

0 commit comments

Comments
 (0)