<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 16 Mar 2006 09:31:27 -0000
From   : "David Harper" <dl.harper@...>
Subject: Re: TSX/TXS (Was: 1MHZ SCSI/ATA board)

Fragula wrote:

> ...
> I'm trying to wrap my head around this source, tidy it up and comment it
> out to do a "GPL" release, TSX/TXS are used a handfull of times. In a
> "register + stack display" bit of debug code that is normally switched
> off, and also here.
>
> SCP="Service Code Parser" (bad name i agree, but kinda does what it
> says on the box, and I coulnd't be arsed getting a thesaurus.
>
> SJT="Service Jump Table"
>
> JVEC="Jump Vector"
>
> Code was last breathed on in maybe 1993/1994 at latestSo memory is
> perhaps a /tadge/ rusty.
> ;
> ; The Service Code Parser - but I can't quite remember how it works...
> ; ... so bear with my if my comments are crap.
> ;
> SCP           PHP ; We need to preserve regs.
>              PHA ; as we pass the codes on
>              TXA ; if we don't have a use
>              PHA ; for them ourselves.
>              TYA ; Watch the pointer.
>              PHA ; SP=+4

No. Original SP-4 - see below.

>              TSX ; Transfer Stack pointer into X?
>              LDA &103,X ; WTF, exactly, is at &103? Its ; the
> stack, but? Ahhh...

This is the original value of A which was pushed onto the stack a few 
instructions ago

The 6502 stack is Page 1 (as you know). The stack pointer (S) points to the 
first free byte in this page, and it counts down from the top. So if the 
stack is empty, S=&FF. Pushing an item onto the stack stores it at (&100+S) 
and then decrements S by 1.

This code has pushed (in order) P, A, X, Y so at this point:
    (&101+S) = Original Y
    (&102+S) = Original X
    (&103+S) = Original A
    (&104+S) = Original P
and the next free byte on the stack is at &100+S

>              AND #&F ; We are getting a code off ; the stack,
> limiting it, then
>              ASL A ; multiplying it by two and ; putting it in X,
>              TAX ; because we are using it to ; index a
> 16-bitx 16 jump ; table pointing at service
>              LDA SJT,X ; routintes. Maybe.

Certainly. Code value has been passed in A, so double it (because you are 
using a two-byte vector table, transfer it into X and use it as an index.

>              STA Jvec ;
>              LDA SJT+1,X ;
>              STA Jvec+1 ;
>              JMP (Jvec) ;
>
> Each of the routines pointed to by the service jump table entries have
> one of two possible outcomes. "Serviced" or "Not Serviced", and jump to
> one of two exit routines which "clean up" in one of two appropriate 
> manners.

Looks fine to me.

David H 
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>