diff --git a/cfg/kernal-x16.cfgtpl b/cfg/kernal-x16.cfgtpl index b9594ee1..b4cde1e2 100644 --- a/cfg/kernal-x16.cfgtpl +++ b/cfg/kernal-x16.cfgtpl @@ -36,6 +36,7 @@ SEGMENTS { SERIAL: load = KERNAL, type = ro; LZSA: load = KERNAL, type = ro; CHANNEL: load = KERNAL, type = ro; + UTIL: load = KERNAL, type = ro; C816_UTIL: load = KERNAL, type = ro; C816_ABORT_NATIVE: load = KERNAL, type = ro, start = $E44C; # low byte: JMP abs, high byte equals low byte of C816_CLALL_THUNK JOYSTICK: load = KERNAL, type = ro; @@ -61,7 +62,6 @@ SEGMENTS { MEMDRV: load = KERNAL, type = ro; NMI: load = KERNAL, type = ro; IRQ: load = KERNAL, type = ro; - UTIL: load = KERNAL, type = ro; GRAPH: load = KERNAL, type = ro; CONSOLE: load = KERNAL, type = ro; SPRITES: load = KERNAL, type = ro; diff --git a/kernal/cbm/util.s b/kernal/cbm/util.s index c49d7d68..e0a59c94 100644 --- a/kernal/cbm/util.s +++ b/kernal/cbm/util.s @@ -6,6 +6,7 @@ .feature labels_without_colons +.include "65c816.inc" .include "banks.inc" bsout = $ffd2 @@ -20,31 +21,70 @@ bsout = $ffd2 ; terminated by a $00. the immediate string must not be longer ; than 255 characters including the terminator. -primm +.proc primm pha ;save registers - txa - pha - tya - pha + phx + phy ldy #0 -@1 tsx ;increment return address on stack - inc $104,x ;and make imparm = return address - bne @2 - inc $105,x -@2 lda $104,x + set_carry_if_65c816 + bcs is_65c816 + + tsx + lda $0104,x sta imparm - lda $105,x + lda $0105,x sta imparm+1 - lda (imparm),y ;fetch character to print (*** always system bank ***) - beq @3 ;null= eol - jsr bsout ;print the character +@1 iny + lda (imparm),y ;fetch character to print (*** always system bank ***) + beq @2 ;null= eol + jsr bsout ;print the character bcc @1 -@3 pla ;restore registers - tay +@2 phy ;increment return address on stack + tsx + lda imparm + clc + adc $0101,x + sta $0105,x + bcc @3 + lda imparm+1 + adc #$00 + sta $0106,x +@3 ply ;pop counter + ply ;restore registers + plx pla - tax + rts + +is_65c816: +.pushcpu +.setcpu "65816" + lda $04,S + sta imparm + lda $05,S + sta imparm+1 + +@1 iny + lda (imparm),y ;fetch character to print (*** always system bank ***) + beq @2 ;null= eol + jsr bsout ;print the character + bcc @1 + +@2 phy ;increment return address on stack + lda imparm + clc + adc $01,S + sta $05,S + bcc @3 + lda imparm+1 + adc #$00 + sta $06,S +@3 ply ;pop counter + ply ;restore registers + plx pla - rts ;return + rts +.popcpu +.endproc