PET kernal routines

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PET kernal routines

Paul Schmidt

Hello all; I am new to this forum and this is my first post.

 

I am one of the very early PET buyers/users, but ‘got out of’ the Commodore world in 1985 when I sold my PETs, VIC-20 and C-64. Only more recently did I decide to relive some of my past by acquiring a PET model 2001-32B to do demonstrations of early computers (along with my Altair 8800, COSMAC “ELF”, etc), but so far I have only demonstrated BASIC. I wanted to add a little machine language to the demo, and planned to use the “Upgrade ROM” integral Tiny Machine Language Monitor (TIM or MLM). I found a scan of the manual for the TIM, but it is the version that came with a cassette, presumably to be loaded into computers that did not already have it in the ROMs. As far as I know, only the later PET ROMs had the TIM, while the VIC-20 & C-64 did not have it. I don’t know if the TIM manual I downloaded is for a version intended for the early PETs, or for the later VIC & C-64 machines.

 

Anyway, there is a short (18 byte) piece of ML code in the manual that simply writes a bunch of characters to the screen. It is supposed to use two of the TIM’s internal routines, called as subroutines; “CRLF” which I believe simply does a ‘carriage return/line feed’ to move the cursor position (screen pointer) away from the text already on the screen, and this is supposed to be at $04F2, and “WRT” at $FFD2 which writes the ASCII code currently in the 6502’s accumulator to the screen at the position of the current screen pointer. The rest of the little program is basically just a loop to increment the contents of the accumulator so that a different ASCII character is written in each screen position.

 

My problem is that the program sends the PET into oblivion, apparently because the first part of the program is a JSR to $04F2, to use the “CRLF” routine, and I don’t think the routine (or ANYTHING) is actually at that location. Nothing there to send control back to my program. The Upgrade ROM version of the PET memory map shows that area of memory being unused and available for RAM expansion. And it seems odd that for a ‘tiny’ monitor program, two of its internal routines would be so widely spaced in memory at $04F2 and $FFD2.

 

I NOP-ed the first three bytes of the program, eliminating the JSR to $04F2, and the rest of the program works fine.

 

But I have had no success in finding any references to show where the correct “CRLF” routine address is. I wonder if any of you might know of a resource that would have this information. Ideally, a full list of the kernel subroutines, especially those that are ostensibly part of the TIM, or at a minimum the location of the “CRLF” routine.

 

Reference – here is the program in question. It resides in the second cassette buffer at $033A.

 

033A      20 F2 04                JSR $04F2 (“CRLF” routine)  *** clearly “CRLF” is not at $04F2, but WHERE is it? ***

033D      A2 20                     LDX $20 (load $20 into X)

033F       8A                           TXA (copy value from X to A so subroutine can use it)

0340       20 D2 FF               JSR $FFD2 (“WRT” or “CHROUT” subroutine, prints ASCII character from A onto screen at current screen pointer location)

0343       E8                           INX (increment X)

0344       E0 60                      CPX $60 (compare X with immediate value $60, to see if screen writing should stop)

0346       D0 F7                     BNE $F7 (if X does not equal $60, do relative branch back to start of loop at $033F)

0348       00                           BRK (if X does equal $60, exit loop and return to TIM/MLM)

0349       4C 3A 03               JMP $033A (if ‘go’ command is again typed on TIM/MLM, program control returns to here, so jump to start of program)

 

Thanks for any help with this

 

End

 

 

Paul R Schmidt

****  Engineer, PS Recording  ****  Publisher, Heavy Metal Music ****

Free-Lance Tuba, Euphonium, Bass Trumpet, Serpent, Ophicleide, Recorder

Editor, The Serpent Newsletter  ****  Webmaster, Serpent Website www.serpentwebsite.com

Illinois State Captain, The Wheelmen, www.thewheelmen.org

Assistant Curator, Heritage Military Music Foundation Collection of Civil War Band Instruments

www.1stbrigadeband.org

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PET kernal routines

peter
> Hello all; I am new to this forum and this is my first post.
>
>
>
> I am one of the very early PET buyers/users, but 'got out of' the
> Commodore
> world in 1985 when I sold my PETs, VIC-20 and C-64. Only more recently did
> I
> decide to relive some of my past by acquiring a PET model 2001-32B to do
> demonstrations of early computers (along with my Altair 8800, COSMAC
> "ELF",
> etc), but so far I have only demonstrated BASIC. I wanted to add a little
> machine language to the demo, and planned to use the "Upgrade ROM"
> integral
> Tiny Machine Language Monitor (TIM or MLM). I found a scan of the manual
> for
> the TIM, but it is the version that came with a cassette, presumably to be
> loaded into computers that did not already have it in the ROMs. As far as
> I
> know, only the later PET ROMs had the TIM, while the VIC-20 & C-64 did not
> have it. I don't know if the TIM manual I downloaded is for a version
> intended for the early PETs, or for the later VIC & C-64 machines.
>
>
>
> Anyway, there is a short (18 byte) piece of ML code in the manual that
> simply writes a bunch of characters to the screen. It is supposed to use
> two
> of the TIM's internal routines, called as subroutines; "CRLF" which I
> believe simply does a 'carriage return/line feed' to move the cursor
> position (screen pointer) away from the text already on the screen, and
> this
> is supposed to be at $04F2, and "WRT" at $FFD2 which writes the ASCII code
> currently in the 6502's accumulator to the screen at the position of the
> current screen pointer. The rest of the little program is basically just a
> loop to increment the contents of the accumulator so that a different
> ASCII
> character is written in each screen position.
>
>
>
> My problem is that the program sends the PET into oblivion, apparently
> because the first part of the program is a JSR to $04F2, to use the "CRLF"
> routine, and I don't think the routine (or ANYTHING) is actually at that
> location. Nothing there to send control back to my program. The Upgrade
> ROM
> version of the PET memory map shows that area of memory being unused and
> available for RAM expansion. And it seems odd that for a 'tiny' monitor
> program, two of its internal routines would be so widely spaced in memory
> at
> $04F2 and $FFD2.
>
>
>
> I NOP-ed the first three bytes of the program, eliminating the JSR to
> $04F2,
> and the rest of the program works fine.
>
>
>
> But I have had no success in finding any references to show where the
> correct "CRLF" routine address is. I wonder if any of you might know of a
> resource that would have this information. Ideally, a full list of the
> kernel subroutines, especially those that are ostensibly part of the TIM,
> or
> at a minimum the location of the "CRLF" routine.
>
>
>
> Reference - here is the program in question. It resides in the second
> cassette buffer at $033A.
>
>
>
> 033A      20 F2 04                JSR $04F2 ("CRLF" routine)  *** clearly
> "CRLF" is not at $04F2, but WHERE is it? ***
>
> 033D      A2 20                     LDX $20 (load $20 into X)
>
> 033F       8A                           TXA (copy value from X to A so
> subroutine can use it)
>
> 0340       20 D2 FF               JSR $FFD2 ("WRT" or "CHROUT" subroutine,
> prints ASCII character from A onto screen at current screen pointer
> location)
>
> 0343       E8                           INX (increment X)
>
> 0344       E0 60                      CPX $60 (compare X with immediate
> value $60, to see if screen writing should stop)
>
> 0346       D0 F7                     BNE $F7 (if X does not equal $60, do
> relative branch back to start of loop at $033F)
>
> 0348       00                           BRK (if X does equal $60, exit
> loop
> and return to TIM/MLM)
>
> 0349       4C 3A 03               JMP $033A (if 'go' command is again
> typed
> on TIM/MLM, program control returns to here, so jump to start of program)
>
>
>
> Thanks for any help with this


Hi Paul,

Well, 04F2 is in the middle of the beginning of RAM normally used by
BASIC, so that would be very wrong for a KERNAL routine. I would grab an
accurate KERNAL reference manual and memory map for the PET.

Here is a good starting point:
http://www.zimmers.net/cbmpics/cbm/PETx/petmem.txt

-Pete Rittwage


       Message was sent through the cbm-hackers mailing list
smf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PET kernal routines

smf
In reply to this post by Paul Schmidt
It looks like 04F2 is part of the cassette loaded TIM, while FFD2 is in
the kernal rom.

If you don't have the routine in the version of TIM you have then
something like this might do it:

04F2:
LDA #$0d
JSR $FFD2
RTS

You could of course put it wherever you want. You might need to call
FFD2 with $0a as well, but I have a feeling that $0d was enough.

On 13/04/2017 14:04, Paul Schmidt wrote:
> ogram. The Upgrade ROM
> version of the PET memory map shows that area of memory being unused and
> available for RAM expansion. And it seems odd that for a 'tiny' monitor
> program, two of its internal routines would be so widely spaced in memory at
> $04F2 and $FFD2.


       Message was sent through the cbm-hackers mailing list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PET kernal routines

Paul Schmidt
In reply to this post by Paul Schmidt
Thanks 'smf'

Good idea. If the TIM's "CRLF" routine was simply to send a 'Return' then I don't see why it would not work as you describe. I will give it a check later on today.





-----Original Message-----

>From: smf <[hidden email]>
>Sent: Apr 13, 2017 1:49 PM
>To: [hidden email]
>Subject: Re: PET kernal routines
>
>It looks like 04F2 is part of the cassette loaded TIM, while FFD2 is in
>the kernal rom.
>
>If you don't have the routine in the version of TIM you have then
>something like this might do it:
>
>04F2:
>LDA #$0d
>JSR $FFD2
>RTS
>
>You could of course put it wherever you want. You might need to call
>FFD2 with $0a as well, but I have a feeling that $0d was enough.
>
>On 13/04/2017 14:04, Paul Schmidt wrote:
>> ogram. The Upgrade ROM
>> version of the PET memory map shows that area of memory being unused and
>> available for RAM expansion. And it seems odd that for a 'tiny' monitor
>> program, two of its internal routines would be so widely spaced in memory at
>> $04F2 and $FFD2.
>
>
>       Message was sent through the cbm-hackers mailing list

       Message was sent through the cbm-hackers mailing list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PET kernal routines

Paul Schmidt
In reply to this post by Paul Schmidt
Thanks. I have already communicated with Bo Z about this, and looked at this same memory map. It is pretty detailed, but does not show any details for the kernel. I will keep looking.

But I might ultimately decide to just alter the program so it contains its own CRLF and does not need the one in the TIM routine.




-----Original Message-----

>From: Pete Rittwage <[hidden email]>
>Sent: Apr 13, 2017 1:35 PM
>To: [hidden email]
>Subject: Re: PET kernal routines
>
>> Hello all; I am new to this forum and this is my first post.
>>
>>
>>
>> I am one of the very early PET buyers/users, but 'got out of' the
>> Commodore
>> world in 1985 when I sold my PETs, VIC-20 and C-64. Only more recently did
>> I
>> decide to relive some of my past by acquiring a PET model 2001-32B to do
>> demonstrations of early computers (along with my Altair 8800, COSMAC
>> "ELF",
>> etc), but so far I have only demonstrated BASIC. I wanted to add a little
>> machine language to the demo, and planned to use the "Upgrade ROM"
>> integral
>> Tiny Machine Language Monitor (TIM or MLM). I found a scan of the manual
>> for
>> the TIM, but it is the version that came with a cassette, presumably to be
>> loaded into computers that did not already have it in the ROMs. As far as
>> I
>> know, only the later PET ROMs had the TIM, while the VIC-20 & C-64 did not
>> have it. I don't know if the TIM manual I downloaded is for a version
>> intended for the early PETs, or for the later VIC & C-64 machines.
>>
>>
>>
>> Anyway, there is a short (18 byte) piece of ML code in the manual that
>> simply writes a bunch of characters to the screen. It is supposed to use
>> two
>> of the TIM's internal routines, called as subroutines; "CRLF" which I
>> believe simply does a 'carriage return/line feed' to move the cursor
>> position (screen pointer) away from the text already on the screen, and
>> this
>> is supposed to be at $04F2, and "WRT" at $FFD2 which writes the ASCII code
>> currently in the 6502's accumulator to the screen at the position of the
>> current screen pointer. The rest of the little program is basically just a
>> loop to increment the contents of the accumulator so that a different
>> ASCII
>> character is written in each screen position.
>>
>>
>>
>> My problem is that the program sends the PET into oblivion, apparently
>> because the first part of the program is a JSR to $04F2, to use the "CRLF"
>> routine, and I don't think the routine (or ANYTHING) is actually at that
>> location. Nothing there to send control back to my program. The Upgrade
>> ROM
>> version of the PET memory map shows that area of memory being unused and
>> available for RAM expansion. And it seems odd that for a 'tiny' monitor
>> program, two of its internal routines would be so widely spaced in memory
>> at
>> $04F2 and $FFD2.
>>
>>
>>
>> I NOP-ed the first three bytes of the program, eliminating the JSR to
>> $04F2,
>> and the rest of the program works fine.
>>
>>
>>
>> But I have had no success in finding any references to show where the
>> correct "CRLF" routine address is. I wonder if any of you might know of a
>> resource that would have this information. Ideally, a full list of the
>> kernel subroutines, especially those that are ostensibly part of the TIM,
>> or
>> at a minimum the location of the "CRLF" routine.
>>
>>
>>
>> Reference - here is the program in question. It resides in the second
>> cassette buffer at $033A.
>>
>>
>>
>> 033A      20 F2 04                JSR $04F2 ("CRLF" routine)  *** clearly
>> "CRLF" is not at $04F2, but WHERE is it? ***
>>
>> 033D      A2 20                     LDX $20 (load $20 into X)
>>
>> 033F       8A                           TXA (copy value from X to A so
>> subroutine can use it)
>>
>> 0340       20 D2 FF               JSR $FFD2 ("WRT" or "CHROUT" subroutine,
>> prints ASCII character from A onto screen at current screen pointer
>> location)
>>
>> 0343       E8                           INX (increment X)
>>
>> 0344       E0 60                      CPX $60 (compare X with immediate
>> value $60, to see if screen writing should stop)
>>
>> 0346       D0 F7                     BNE $F7 (if X does not equal $60, do
>> relative branch back to start of loop at $033F)
>>
>> 0348       00                           BRK (if X does equal $60, exit
>> loop
>> and return to TIM/MLM)
>>
>> 0349       4C 3A 03               JMP $033A (if 'go' command is again
>> typed
>> on TIM/MLM, program control returns to here, so jump to start of program)
>>
>>
>>
>> Thanks for any help with this
>
>
>Hi Paul,
>
>Well, 04F2 is in the middle of the beginning of RAM normally used by
>BASIC, so that would be very wrong for a KERNAL routine. I would grab an
>accurate KERNAL reference manual and memory map for the PET.
>
>Here is a good starting point:
>http://www.zimmers.net/cbmpics/cbm/PETx/petmem.txt
>
>-Pete Rittwage
>
>
>       Message was sent through the cbm-hackers mailing list

       Message was sent through the cbm-hackers mailing list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: PET kernal routines

Paul Schmidt
In reply to this post by smf
OK, a couple small improvements: I finally found my old copy of "PET/CBM
Personal Computer Guide (2nd Ed)" by Osborne. It has a kernel listing, which
confirmed that $FFD2 is in fact correct for the "WRT" subroutine, but it
listed nothing for a "CRLF" type kernel routine; so I agree with the comment
that the other routine at $04F2 most have been part of the TIM which could
have been loaded in in that range of addresses (the same book lists this as
'user memory').

The suggestion to re-create the CRLF by using the kernal's $FFD2 subroutine
to send a $0D (Return) to the screen was a good one, and my tests proved
that it works just fine.

So I rewrote the little program to replace the JSR to $04F2 with the
just-tested 'manual' method and it now works as expected.

Thanks to all who responded.


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of smf
Sent: Thursday, April 13, 2017 1:49 PM
To: [hidden email]
Subject: Re: PET kernal routines

It looks like 04F2 is part of the cassette loaded TIM, while FFD2 is in the
kernal rom.

If you don't have the routine in the version of TIM you have then something
like this might do it:

04F2:
LDA #$0d
JSR $FFD2
RTS

You could of course put it wherever you want. You might need to call
FFD2 with $0a as well, but I have a feeling that $0d was enough.

On 13/04/2017 14:04, Paul Schmidt wrote:
> ogram. The Upgrade ROM
> version of the PET memory map shows that area of memory being unused
> and available for RAM expansion. And it seems odd that for a 'tiny'
> monitor program, two of its internal routines would be so widely
> spaced in memory at
> $04F2 and $FFD2.


       Message was sent through the cbm-hackers mailing list


       Message was sent through the cbm-hackers mailing list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PET kernal routines

Mike Stein
There's also a pretty good memory/ROM map/cross-reference in Raeto West's 'Programming The PET CBM'; chapter 15, starting at p. 391.

http://www.bombjack.org/kim-pet/books-kim-pet.htm

m

----- Original Message -----
From: "Paul Schmidt" <[hidden email]>
To: <[hidden email]>
Sent: Thursday, April 13, 2017 7:27 PM
Subject: RE: PET kernal routines


> OK, a couple small improvements: I finally found my old copy of "PET/CBM
> Personal Computer Guide (2nd Ed)" by Osborne. It has a kernel listing, which
> confirmed that $FFD2 is in fact correct for the "WRT" subroutine, but it
> listed nothing for a "CRLF" type kernel routine; so I agree with the comment
> that the other routine at $04F2 most have been part of the TIM which could
> have been loaded in in that range of addresses (the same book lists this as
> 'user memory').
>
> The suggestion to re-create the CRLF by using the kernal's $FFD2 subroutine
> to send a $0D (Return) to the screen was a good one, and my tests proved
> that it works just fine.
>
> So I rewrote the little program to replace the JSR to $04F2 with the
> just-tested 'manual' method and it now works as expected.
>
> Thanks to all who responded.
>
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of smf
> Sent: Thursday, April 13, 2017 1:49 PM
> To: [hidden email]
> Subject: Re: PET kernal routines
>
> It looks like 04F2 is part of the cassette loaded TIM, while FFD2 is in the
> kernal rom.
>
> If you don't have the routine in the version of TIM you have then something
> like this might do it:
>
> 04F2:
> LDA #$0d
> JSR $FFD2
> RTS
>
> You could of course put it wherever you want. You might need to call
> FFD2 with $0a as well, but I have a feeling that $0d was enough.
>
> On 13/04/2017 14:04, Paul Schmidt wrote:
>> ogram. The Upgrade ROM
>> version of the PET memory map shows that area of memory being unused
>> and available for RAM expansion. And it seems odd that for a 'tiny'
>> monitor program, two of its internal routines would be so widely
>> spaced in memory at
>> $04F2 and $FFD2.
>
>
>       Message was sent through the cbm-hackers mailing list
>
>
>       Message was sent through the cbm-hackers mailing list

       Message was sent through the cbm-hackers mailing list
Loading...