Posted By
Harry Potter on 2022-06-21 14:05:41
| Plus4Cart issue w/ printf(): lock-up at start-up
Hi! I got my Plus4/cc65 cartridge libraries to work, but now, there is a problem: I added my own version of printf() to the test program. Now, the program locks up at start-up. I disabled the line in the crt0.s file that calls initlib, and the program locks up at the call to printf(). I looked at the source for a reference to the init routines and didn't find anything. What in printf() would be called from initlib? Or do I need to check out the initlib function? Following is the crt0.s file:
-------------------- startup: ;Thi sei ldx #$ff txs lda $fb pha ;ldx #$02 ; cartrige 1 lo, kernal sta $FDD2 jsr $FF84 ; Initialize I/O devices jsr $FF87 ; RAM Test pla sta $FB jsr $FF8A ; Restore vectors to initial values jsr $FF81 ; Initialize screen editor cli
; Switch to second charset
lda #14 jsr $FFD2
; Clear the BSS data
jsr zerobss
;lda #<(__RAM_START__ + __RAM_SIZE__) lda #$00 sta sp ;lda #>(__RAM_START__ + __RAM_SIZE__) lda #$80 sta sp+1 ; Set argument stack ptr
lda #$03 sta $FF0C lda #$FF sta $FF0D
; If we have IRQ functions, chain our stub into the IRQ vector
; lda #<__INTERRUPTOR_COUNT__ ; beq NoIRQ1 ; lda IRQVec ; ldx IRQVec+1 ; sta IRQInd+1 ; stx IRQInd+2 ; lda #; ldx #>IRQStub ; sei ; sta IRQVec ; stx IRQVec+1 ; cli
; Call module constructors
NoIRQ1: lda #<__DATA_RUN__ ldx #>__DATA_RUN__ jsr pushax lda #<__DATA_LOAD__ ldx #>__DATA_LOAD__ jsr pushax lda #<__DATA_SIZE__ ldx #>__DATA_SIZE__ jsr _memcpy
jsr initlib
; Push arguments and call main ;ra: ; inc $D021 ; jmp ra
jsr _main
; Back from main (This is also the _exit entry). Run module destructors
_exit: jsr donelib
; Reset the IRQ vector if we chained it.
; ;pha ; Save the return code on stack ; lda #<__INTERRUPTOR_COUNT__ ; beq NoIRQ2 ; lda IRQInd+1 ; ldx IRQInd+2 ; sei ; sta IRQVec ; stx IRQVec+1 ; cli
NoIRQ2: jmp startup
--------------------
If you want, I can post my version of printf().
|