From: Adam Wozniak (adam_at_cuddlepuddle.org)
Date: 2002-03-23 00:51:16
I'm trying to target a new machine and I'm having a little trouble with my crt0.s I think I need a better understanding of how the cc65 parameter stack relates to the 6502 call/return stack. Are these the same beast? Do they overlap? Or ar they completely separate? I've only got 128 bytes of real ram to work with, mapped at 0x80->0xFF I've got some other areas (0x00->0x3F and 0x280->0x29F) which are memory mapped devices. My ROM is 0xF000->0xFFFF. Where should the 6502 stack go? The parameter stack? --Adam MEMORY { RAM: start = $80, size=$80, file="trash.bin"; ROM: start = $F000, size=$1000, file="rom.bin"; TIA: start = $00, size=$40, file="trash.bin"; RIOT: start = $280, size=$20, file="trash.bin"; } SEGMENTS { CODE: load=ROM, type=wprot, define=yes; RODATA: load=ROM, type=wprot; DATA: load=ROM, run=RAM, type=rw, define=yes; BSS: load=ROM, run=RAM, type=bss, define=yes; VECTORS: load=ROM, type=ro, start=$FFFA; ZEROPAGE: load=RAM, type=zp; TIA: load=TIA, type=rw; RIOT: load=RIOT, type=rw; } SYMBOLS { __STACKSIZE__ = $80; } .autoimport on .import _main .import _irq .import _nmi .import __copy_data .import __zero_bss .export _exit .export start .exportzp sp, sreg, regsave .exportzp ptr1, ptr2, ptr3, ptr4 .exportzp tmp1, tmp2, tmp3, tmp4 .exportzp regbank, zpspace TOPMEM = $df .zeropage zpstart = * sp: .res 2 ; Stack pointer sreg: .res 2 ; Secondary register/high 16 bit for longs regsave: .res 2 ; slot to save/restore (E)AX into ptr1: .res 2 ptr2: .res 2 ptr3: .res 2 ptr4: .res 2 tmp1: .res 1 tmp2: .res 1 tmp3: .res 1 tmp4: .res 1 regbank: .res 6 ; 6 byte register bank zpspace = * - zpstart ; Zero page space allocated .segment "CODE" .proc start ; disable interrupts sei ; clear decimal bit cld ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;; Is any of this right??? ; set the 6502 stack pointer to FF ldx #$ff txs ; set up the cc65 parameter stack tsx stx spsave lda #<TOPMEM sta sp lda #>TOPMEM sta sp+1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; clear out the registers ldx #0 ldy #0 lda #0 ; copy the DATA segment into RAM jsr __copy_data ; zero out the bss RAM jsr __zero_bss ; argument size jsr push0 jsr push0 ldy #4 jsr _main jmp start .endproc .segment "CODE" .proc _exit ; disable interrupts sei jmp start .endproc .segment "CODE" .proc irq jsr _irq rti .endproc .segment "CODE" .proc nmi jsr _nmi rti .endproc .segment "DATA" zpsave: .res zpspace .segment "BSS" spsave: .res 1 .segment "VECTORS" .addr nmi .addr start .addr irq -- adam_at_cuddlepuddle.org http://cuddlepuddle.org/~adam/pgp.txt ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2002-03-23 00:02:05 CET