6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 29, 2024 8:29 am

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: PET kernel ROM
PostPosted: Sun Feb 16, 2014 12:09 am 
Offline

Joined: Sat Aug 21, 2010 7:52 am
Posts: 231
Location: Arlington VA
BigEd wrote:
Ah, thanks, I see. Having successful avoiding reusing &10, the problem is that one of the IRQ handlers detects STOP on the keyboard directly, and jumps into BASIC. Although the IRQ is vectored through RAM, that RAM pointer is updated in the tape-handling routines. So the puzzle is to repair the vector or avoid setting it... without duplicating too much of the ROM code.

Exactly! I can't be the first guy ever to attempt using the Commodore tape I/O from a new language.

The $10 issue is resolved. Zero page usage for now still has SWEET16's registers overlapping Forth registers, followed by the split stack. The first z.p. used by the kernel is TI at $8d, like so:
Code:
; SWEET16 registers
R0 - R15   $00 - $1f

; PETTIL registers and stack
TOS        $02 - $03    ; top of stack
UP         $04 - $05    ; user pointer for user variables
I          $06 - $07    ; counter of innermost DO loop
ILIMIT     $08 - $09    ; limit of innermost DO loop
N          $0A - $11    ; 8 bytes of scratch area for primitives
STACKL     $20 - $52    ; low order half of stack
STACKH     $53 - $85    ; high order half of stack
STOREX     $ff          ; temp storage for the stack pointer / scratch area

; NEXT routine (15 clocks!)
; secondaries that straddle page boundaries run a word at $xxFD or $xxFE to bump IP+1
; avoiding the JMP ($xxFF) CPU bug
IP         $8b - $8c
0086 NEXT         INC IP
0088              INC IP
008a NEXTO        JMP (IP)

; the rest of zero page is used by the kernel
TIME       $8d - $8f
...

So when the IRQ handler at $e455 poops on $10, which occurs only when the user presses STOP, it only messes up N+6 or R8L, There is never any guarantee of either of these being safe across Forth word executiion, so not a problem.


Top
 Profile  
Reply with quote  
 Post subject: Re: PET kernel ROM
PostPosted: Sun Feb 16, 2014 6:48 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10939
Location: England
Take as an example the problem code at FC99 "Write tape leader" - if you copy the code from FC99 to FCAF (22 bytes) to your own "Write tape leader" you can then jump to the CLI at FCB0. Does that work for you? You don't need to copy the subroutines used or the code after the interrupt vector write.


Top
 Profile  
Reply with quote  
 Post subject: Re: PET kernel ROM
PostPosted: Sun Feb 16, 2014 7:10 am 
Offline

Joined: Sat Aug 21, 2010 7:52 am
Posts: 231
Location: Arlington VA
I've got OPEN and CLOSE working, added a picture https://github.com/chitselb/pettil/blob ... 2basic.png of the problem when the tape is reading along and it encounters an end-of-tape marker (block ID = 5) and done a push to github. To reproduce my results, just clone the git repo, have a working vice installation, and do these three things from a bash prompt.

$ . ./pettil.sh
$ xap
$ xpetp


Top
 Profile  
Reply with quote  
 Post subject: Re: PET kernel ROM
PostPosted: Mon Mar 24, 2014 3:21 am 
Offline

Joined: Sat Aug 21, 2010 7:52 am
Posts: 231
Location: Arlington VA
I found a FIG Forth for the PET from that era and decompiled it. The approach taken by FIG Forth was to copy the PET zeropage from $0f...$8c to upper memory at startup, and then restore everything to BASIC's liking immediately prior to doing something BASIC-ey, including tape i/o. If for some reason the tape operation leaves the user at a BASIC prompt, typing RUN will start Forth back up again. It's a little crufty, to be sure, but well within the scope of PETTIL's primary design goal, which is to present every available resource of the Commodore PET to the programmer. It may be useful later if when I implement floating point math via the BASIC ROM.

In the immortal words of Steve Watson on Monster House, "done stamp!"


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: