Re: BASIC listing..

From: silverdr_at_wfmh.org.pl
Date: Mon, 10 Jun 2013 17:19:12 +0200
Message-Id: <12A5894D-75A9-4AB0-B354-05480ED812EB@wfmh.org.pl>
On 2013-06-07, at 19:53, Spiro Trikaliotis wrote:

>> Perhaps it checks only the high byte of the start address?
> 
> Correct. See $A7C4 in the C64 ROM and you will see that it tests the
> high byte only.

I see that $A7C4 is part of NEWSTT, which can be executed when preparing to do the LIST but after digging the disassembly I think the reason lies actually inside the LIST routine itself:

A708   B1 5F      LDA ($5F),Y	; LO of next line pointer
A70A   AA         TAX		; copy LO of next line pointer to X
A70B   C8         INY		; point to HI of next line pointer
A70C   B1 5F      LDA ($5F),Y	; HI of next line pointer
A70E   86 5F      STX $5F	; put LO of next line pointer
A710   85 60      STA $60	; put HI of next line pointer
A712   D0 B5      BNE $A6C9	; if HI (only) of next line pointer is not \0 - rinse and repeat with next line
A714   4C 86 E3   JMP $E386	; LDX #$80 : JMP (IERROR) : Print READY.

In any case though both Imre and you are right - it seems that only HI byte has a meaning for the machine, both when doing NEWSTT and LIST. Therefore the trick to steal two additional bytes and still have LIST behave correctly may work only if the second byte is \0 in such case (LDA #$00, LDY #$00, ...), which leads me to another potential trick (of course I am not the first one to think of it but I think it could be implemented e. g. in the cc65 basic stub), which should IMHO be the default behaviour (actually I'd imagine different implementation but still not wasting two healthy mem locations):

instead of pointing to 0x0000 _after_ the last EOL, why not point to the last byte of the last line? Then the EOL mark is used as HI byte of the pointer and it will always be \0, so that the following two bytes can be actually anything? After analysing all this, I think this method has been used with some crunchers but don't recall exactly which.

-- 
SD!
       Message was sent through the cbm-hackers mailing list
Received on 2013-06-10 16:00:09

Archive generated by hypermail 2.2.0.