mirror of
https://github.com/cc65/cc65.git
synced 2025-08-07 00:25:45 +00:00
Use structs
git-svn-id: svn://svn.cc65.org/cc65/trunk@2711 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -38,21 +38,22 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
; Offsets into the o65 header structure (6502 format)
|
; The o65 header structure (6502 format)
|
||||||
O65_HDR_MARKER = 0 ; Non-C64 marker
|
.struct O65_HDR
|
||||||
O65_HDR_MAGIC = 2 ; o65 magic
|
MARKER .byte 2 ; Non-C64 marker: $01 $00
|
||||||
O65_HDR_VERSION = 5 ; Version number
|
MAGIC .byte 3 ; o65 magic: "o65"
|
||||||
O65_HDR_MODE = 6 ; Mode word
|
VERSION .byte 1 ; Version number
|
||||||
O65_HDR_TBASE = 8 ; Original text (code) segment address
|
MODE .word ; Mode word
|
||||||
O65_HDR_TLEN = 10 ; Size of text (code) segment
|
TBASE .word ; Original text (code) segment address
|
||||||
O65_HDR_DBASE = 12 ; Original data segment address
|
TLEN .word ; Size of text (code) segment
|
||||||
O65_HDR_DLEN = 14 ; Size of data segment
|
DBASE .word ; Original data segment address
|
||||||
O65_HDR_BBASE = 16 ; Original bss segment address
|
DLEN .word ; Size of data segment
|
||||||
O65_HDR_BLEN = 18 ; Size of bss segment
|
BBASE .word ; Original bss segment address
|
||||||
O65_HDR_ZBASE = 20 ; Original zp segment address
|
BLEN .word ; Size of bss segment
|
||||||
O65_HDR_ZLEN = 22 ; Size of zp segment
|
ZBASE .word ; Original zp segment address
|
||||||
O65_HDR_STACK = 24 ; Stacksize needed
|
ZLEN .word ; Size of zp segment
|
||||||
O65_HDR_SIZE = 26 ; Size of header structure
|
STACK .word ; Stacksize needed
|
||||||
|
.endstruct
|
||||||
|
|
||||||
; Marker, magic and version number
|
; Marker, magic and version number
|
||||||
O65_MARKER_0 = $01
|
O65_MARKER_0 = $01
|
||||||
|
@@ -63,7 +63,7 @@ RegBankSave: .res 6 ; Save area for register bank
|
|||||||
; The header of the o65 file. Since we don't need the first 8 bytes any
|
; The header of the o65 file. Since we don't need the first 8 bytes any
|
||||||
; longer, once we've checked them, we will overlay them with other data to
|
; longer, once we've checked them, we will overlay them with other data to
|
||||||
; save a few bytes.
|
; save a few bytes.
|
||||||
Header: .res O65_HDR_SIZE ; The o65 header
|
Header: .tag O65_HDR ; The o65 header
|
||||||
|
|
||||||
; Input
|
; Input
|
||||||
InputByte = Header ; Byte read from input
|
InputByte = Header ; Byte read from input
|
||||||
@@ -349,7 +349,7 @@ _mod_load:
|
|||||||
lda #<Header
|
lda #<Header
|
||||||
ldx #>Header
|
ldx #>Header
|
||||||
jsr pushax
|
jsr pushax
|
||||||
lda #O65_HDR_SIZE
|
lda #.sizeof(O65_HDR)
|
||||||
ldx #0 ; Always less than 256
|
ldx #0 ; Always less than 256
|
||||||
jsr ReadAndCheckError ; Bails out in case of errors
|
jsr ReadAndCheckError ; Bails out in case of errors
|
||||||
|
|
||||||
@@ -439,19 +439,19 @@ HeaderError:
|
|||||||
; caller
|
; caller
|
||||||
|
|
||||||
CalcSizes:
|
CalcSizes:
|
||||||
lda Header + O65_HDR_TLEN
|
lda Header + O65_HDR::TLEN
|
||||||
add Header + O65_HDR_DLEN
|
add Header + O65_HDR::DLEN
|
||||||
sta TPtr
|
sta TPtr
|
||||||
lda Header + O65_HDR_TLEN + 1
|
lda Header + O65_HDR::TLEN + 1
|
||||||
adc Header + O65_HDR_DLEN + 1
|
adc Header + O65_HDR::DLEN + 1
|
||||||
sta TPtr+1
|
sta TPtr+1
|
||||||
lda TPtr
|
lda TPtr
|
||||||
add Header + O65_HDR_BLEN
|
add Header + O65_HDR::BLEN
|
||||||
pha ; Save low byte of total size
|
pha ; Save low byte of total size
|
||||||
ldy #MOD_CTRL::MODULE_SIZE
|
ldy #MOD_CTRL::MODULE_SIZE
|
||||||
sta (Ctrl),y
|
sta (Ctrl),y
|
||||||
lda TPtr+1
|
lda TPtr+1
|
||||||
adc Header + O65_HDR_BLEN + 1
|
adc Header + O65_HDR::BLEN + 1
|
||||||
iny
|
iny
|
||||||
sta (Ctrl),y
|
sta (Ctrl),y
|
||||||
tax
|
tax
|
||||||
@@ -489,8 +489,8 @@ GotMem: lda Module
|
|||||||
tax
|
tax
|
||||||
pla
|
pla
|
||||||
jsr pushax
|
jsr pushax
|
||||||
lda Header + O65_HDR_BLEN
|
lda Header + O65_HDR::BLEN
|
||||||
ldx Header + O65_HDR_BLEN+1
|
ldx Header + O65_HDR::BLEN+1
|
||||||
jsr _bzero ; bzero (bss, bss_size);
|
jsr _bzero ; bzero (bss, bss_size);
|
||||||
|
|
||||||
; Load code and data segment into memory. The sum of the sizes of
|
; Load code and data segment into memory. The sum of the sizes of
|
||||||
@@ -525,10 +525,10 @@ Reloc: lda Module
|
|||||||
; Relocate the data segment
|
; Relocate the data segment
|
||||||
|
|
||||||
lda Module
|
lda Module
|
||||||
add Header + O65_HDR_TLEN
|
add Header + O65_HDR::TLEN
|
||||||
pha
|
pha
|
||||||
lda Module + 1
|
lda Module + 1
|
||||||
adc Header + O65_HDR_TLEN + 1
|
adc Header + O65_HDR::TLEN + 1
|
||||||
tax
|
tax
|
||||||
pla ; Data segment address in a/x
|
pla ; Data segment address in a/x
|
||||||
jsr RelocSeg
|
jsr RelocSeg
|
||||||
|
Reference in New Issue
Block a user