Re: BASIC loaders for machine language (Re: FORTH in ROM for CBM 8032?)

From: Marko Mäkelä (marko.makela_at_hut.fi)
Date: 2005-01-05 13:17:08

Greg,

> That macro can be shorter:
> 
> #mac basicline
>   org {1}
>   word 0$  ; link to next line
>   word {2} ; line number
>   byte $9E ; SYS token
> ;   SYS digits
>   if (* + 8) / 10000
>     byte $30 + (* + 8) / 10000
>   endif
>   if (* + 7) / 1000
>     byte $30 + (* + 7) /  1000 % 10
>   endif
>     byte $30 + (* + 6) /   100 % 10
>     byte $30 + (* + 5) /    10 % 10
>     byte $30 + (* + 4) /     1 % 10
>   byte 0   ; end of BASIC line
> 0$:
>   word 0   ; end of BASIC program
> #endm

That would lead to an unoptimal solution on the PET II series a.k.a.
CBM Model B, where the BASIC text starts at address 3.  If you want
a short macro, you can generate a five-digit SYS code; it should work
equally well.

On the other hand, that approach wouldn't work on the PET II as such,
because SYS will jump to BANK 15.  You'd have to copy some machine code
first from the BASIC text bank to BANK 15.  The cbmlink BASIC loader for
the PET II series does this.  (Not with DATA and READ statements, but
BANK, PEEK and POKE, to save space and to make the code generation
simpler.)

BTW, some cruncher writes SYS pi*656 in the BASIC header.  It's actually
one byte longer than writing a four-digit address, but I guess they wanted
it to look cooler. :-)  Some tools also terminate the BASIC code with
00 xx 00 instead of 00 00 00, so that they can embed e.g., an ldy #0 in
the BASIC header.

	Marko

       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.