Use AX paradigm for stack initalization.
This commit is contained in:
parent
d8c31cf1d3
commit
69fbcb30fd
4 changed files with 14 additions and 15 deletions
|
@ -27,9 +27,9 @@ start:
|
||||||
; Set up the stack.
|
; Set up the stack.
|
||||||
|
|
||||||
lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
||||||
|
ldx #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
||||||
sta sp
|
sta sp
|
||||||
lda #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
stx sp+1 ; Set argument stack ptr
|
||||||
sta sp+1 ; Set argument stack ptr
|
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ Start:
|
||||||
ldx #0
|
ldx #0
|
||||||
stx ZP_IRQ_CTRL ; disable calling cartridge IRQ/NMI handler
|
stx ZP_IRQ_CTRL ; disable calling cartridge IRQ/NMI handler
|
||||||
|
|
||||||
; Setup stack and memory mapping
|
; Set up stack and memory mapping
|
||||||
;ldx #$FF ; Stack top ($01FF)
|
;ldx #$FF ; Stack top ($01FF)
|
||||||
dex
|
dex
|
||||||
txs
|
txs
|
||||||
|
@ -31,7 +31,7 @@ Start:
|
||||||
; Copy the .data segment to RAM
|
; Copy the .data segment to RAM
|
||||||
jsr copydata
|
jsr copydata
|
||||||
|
|
||||||
; setup the stack
|
; Set up the stack
|
||||||
lda #<(__RAM_START__+__RAM_SIZE__)
|
lda #<(__RAM_START__+__RAM_SIZE__)
|
||||||
ldx #>(__RAM_START__+__RAM_SIZE__)
|
ldx #>(__RAM_START__+__RAM_SIZE__)
|
||||||
sta sp
|
sta sp
|
||||||
|
|
|
@ -100,9 +100,9 @@ start:
|
||||||
; Set up the stack.
|
; Set up the stack.
|
||||||
|
|
||||||
lda #<(__SRAM_START__ + __SRAM_SIZE__)
|
lda #<(__SRAM_START__ + __SRAM_SIZE__)
|
||||||
|
ldx #>(__SRAM_START__ + __SRAM_SIZE__)
|
||||||
sta sp
|
sta sp
|
||||||
lda #>(__SRAM_START__ + __SRAM_SIZE__)
|
stx sp+1 ; Set argument stack ptr
|
||||||
sta sp+1 ; Set argument stack ptr
|
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|
|
@ -39,22 +39,21 @@
|
||||||
|
|
||||||
start:
|
start:
|
||||||
|
|
||||||
; setup the CPU and System-IRQ
|
; Set up the CPU and System-IRQ
|
||||||
|
|
||||||
; Initialize CPU
|
; Initialize CPU
|
||||||
|
|
||||||
sei
|
sei
|
||||||
nop
|
nop
|
||||||
csh ; set high speed CPU mode
|
csh ; Set high speed CPU mode
|
||||||
nop
|
nop
|
||||||
cld
|
cld
|
||||||
nop
|
nop
|
||||||
|
|
||||||
; Setup stack and memory mapping
|
; Set up stack and memory mapping
|
||||||
ldx #$FF ; Stack top ($21FF)
|
ldx #$FF ; Stack top ($21FF)
|
||||||
txs
|
txs
|
||||||
|
|
||||||
; at startup all MPRs are set to 0, so init them
|
; At startup all MPRs are set to 0, so init them
|
||||||
lda #$ff
|
lda #$ff
|
||||||
tam #%00000001 ; 0000-1FFF = Hardware page
|
tam #%00000001 ; 0000-1FFF = Hardware page
|
||||||
lda #$F8
|
lda #$F8
|
||||||
|
@ -98,11 +97,11 @@ start:
|
||||||
; Copy the .data segment to RAM
|
; Copy the .data segment to RAM
|
||||||
tii __DATA_LOAD__, __DATA_RUN__, __DATA_SIZE__
|
tii __DATA_LOAD__, __DATA_RUN__, __DATA_SIZE__
|
||||||
|
|
||||||
; setup the stack
|
; Set up the stack
|
||||||
lda #<(__RAM_START__+__RAM_SIZE__)
|
lda #<(__RAM_START__+__RAM_SIZE__)
|
||||||
|
ldx #>(__RAM_START__+__RAM_SIZE__)
|
||||||
sta sp
|
sta sp
|
||||||
lda #>(__RAM_START__+__RAM_SIZE__)
|
stx sp + 1
|
||||||
sta sp + 1
|
|
||||||
|
|
||||||
; Call module constructors
|
; Call module constructors
|
||||||
jsr initlib
|
jsr initlib
|
||||||
|
@ -114,7 +113,7 @@ start:
|
||||||
jsr push0 ; argv
|
jsr push0 ; argv
|
||||||
|
|
||||||
ldy #4 ; Argument size
|
ldy #4 ; Argument size
|
||||||
jsr _main ; call the users code
|
jsr _main ; Call the users code
|
||||||
|
|
||||||
; Call module destructors. This is also the _exit entry.
|
; Call module destructors. This is also the _exit entry.
|
||||||
_exit:
|
_exit:
|
||||||
|
|
Loading…
Add table
Reference in a new issue