[futurebasic] Re: selectors & traps

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 1998 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Sun, 29 Mar 1998 17:37:42 -0600
Larry wrote:
> I have seen assembly versions of trap calls in FutureBasic that require
> selectors, where the selector has been declared inline before the trap number:
> 
> '   DC.W   selector
> '   DC.W   trap
> 
> and where the selector has been put into DO before the trap is declared
> inline:
> 
> '   move.w   #selector,d0
> '   dc.w         trap
> 
> Experiments seem to show that it works either way. Is this correct? Is there a
> preferred (Apple approved) way?

I'm skeptical whether the "DC.W  selector" line in the first case is
really what it seems.  If the selector were, say, $47, and you did this:

    `   DC.W  $47
    `   DC.W  trap

my guess is that you'd get a system error as soon as the computer
encountered that first line.  More likely, the correct line would be
something like this:

    `   DC.W  $303C, $0047
    `   DC.W  trap

But the reason that works is that the hex codes $303C, $0047 translate
exactly into the machine-language instruction "move.w #$47,d0".  In
other words, the selector is still being put into register D0.  The two
different "methods" are really just two different variations in assembly
syntax--they both assemble to identical machine language instructions.

- Rick