home *** CD-ROM | disk | FTP | other *** search
- ; Toolbx.sub file for Absoft Fortran 2.3
- ; Jay Lieske JPL, 29 Jan '88.
- ;
- ; 'toolbx.sub' is provided and copyrighted by Absoft. This disassembly
- ; is an attempt to find out what the routine does so that erroneous trap
- ; parameters in the Absoft include files can be corrected and so that additional
- ; traps can be implemented (e.g. the Printer traps at $A8FD.
- ;
- * Decomposition of Absoft's Fortran toolbx.sub for Fortran 2.3 via Nosy.
- * My toolbx.sub is dated 10 August 1987. Be cautious with older toolbx.par files
- * since the 'control exception flag' (bit 29 of the trap descriptor) described in
- * some of the 'Absoft Extras' documentation is for an older version of Fortran.
- * The Bit 29 flag is NOT used in Version 2.3, but instead 'Arg1' is employed
- * to flag the 'exceptional traps' that require more than six arguments.
- * The comments given below are based on Absoft's documentation of their earlier
- * toolbx.sub formats as modified by this disassembly for Version 2.3
- * * * * * *
- * Notes: What's at $D08(A0) and environs?? Used to dispatch trap and exit glue
- * * * * * *
- ;**************************************************************************************
- ; The normal ToolBox and Operating System Traps ($Axxx) and their argument types
- ; are encoded into a 'trap descriptor' as follows:
- ;
- ; |- 0=> OS trap, 1 => ToolBox trap (Bits 20-31 are usually lower 3 nybbles of
- ; | the ToolBox trap )
- ; | |--< 1 => 'Funny' trap (not a trap at all, but an internal routine as 'PTR')
- ; _V__V__________________________________________________________________________
- ; |31 30 20 19 0|
- ; | Trap Field | Parameter Control Field |
- ; |_______________________________|_______________________________________________|
- ;
- ; The 'Funny trap' field (bit 30) is used for ToolBox 'traps' (bit 31 = 1) to
- ; indicate that it's not really a ToolBox trap but rather a toolbx.sub internal
- ; routine. Current ones are PTR ($C000 0000), GetGlobal ($C000 0001), and
- ; MemError ($C000 0002). See 'FunTrap' entry in the toolbx.sub routine below.
- ; The 'Trap Field' in general consists of the lower 3 nybbles (i.e. the lower
- ; three hex digits) of the Apple ToolBox 'trap word' so that the 'NewWindow' trap
- ; word of $A913 becomes Trap Field $913.
- ;
- ;**************************************************************************************
- ;
- ; The 'Operating System traps' consist of trap addresses of the form $Ayxx where
- ; 'y' is less than $8 (viz. bit 31 is clear). They are register-based traps and
- ; the Parameter Control Field contains encoded information concerning the arguments
- ; and through which registered they are to be passed.
- ; The 'Toolbox traps' where 'y' is greater than $8 (viz. bit 31 is set) are
- ; stack-based traps and the Parameter Control Field contains encoded information
- ; concerning the arguments and their sizes.
- ;
- ;**************************************************************************************
- ; The OS traps (where bit 31 is clear) are register-based and have a
- ; Parameter Control Field as follows:
- ; ____________________________________________________
- ; |19 17 16 14 13 11 10 8 7 6 5 4 3 2 1 0 |
- ; | Arg1 | Arg2 | Arg3 | Arg4 | Ret| Size| Save |x x |
- ; |___________________________________________________|
- ;
- ; The 'Argx' fields are 3 bits wide and contain
- ; ________________________
- ; Argx: | Register | Val/Var| Register: 2 bits with meaning in 'Reg' field
- ; |_______________|________| Val: 0 (Pass by value) Var: 1 (Pass by address)
- ;
- ; _____
- ; Reg: | 0 0 | Register D0
- ; | 0 1 | Register D1
- ; | 1 0 | Register A0
- ; | 1 1 | Register A1
- ; |_____|
- ;
- ; Ret: Return register. Encoded like 'Reg' field
- ; Size: Type of result given by
- ; _____
- ; | 0 1 | Word
- ; | 1 0 | Longword
- ; | 1 1 | Byte (boolean)
- ; |_____|
- ;
- ; Save: For MemError calls. Clear (01) or Save (10) reg D0 in MemError word
- ;
- ;**************************************************************************************
- ; The TB traps (where bit 31 is set) are stack-based and have a
- ; Parameter Control Field as follows:
- ;
- ; __________________________________________________
- ; |19 18 17 15 14 12 11 9 8 6 5 3 2 0 |
- ; | Fcn | Arg1 | Arg2 | Arg3 | Arg4 | Arg5 | Arg6 |
- ; |_________________________________________________|
- ; _____
- ; Fcn: | 0 0 | Procedure
- ; | 0 1 | Word
- ; | 1 0 | Longword
- ; | 1 1 | Byte (boolean)
- ; |_____|
- ; ________________________
- ; Argx: |Val/Var | Size | Val: 0 (Pass by value) Var: 1 (Pass by address)
- ; |________|_______________| Size: 2 bits with same meaning as 'Fcn' field
- ;
- ; The normal TB traps can have a maximum of six arguments. Up to ten arguments
- ; can be handled, however, by using the 'exceptional trap' mechanism given below.
- ; Note that this version employs a different method for these long argument lists
- ; than the earlier version of toolbx.sub which employed bit 29 in the Trap Field
- ; to flag the longer argument lists. This is perhaps why some of the parameter
- ; values for unusual traps like SFGetFile are messed up in some of the Absoft
- ; include files.
- ;
- ;**************************************************************************************
- ; In cases where there are more than six arguments to a toolbox trap the
- ; following method is implemented. An extra LongWord (called 'Xfields' here)
- ; is imbedded at the end of toolbx.sub (and unfortunately isn't visible
- ; unless you disassemble the routine). All toolbox traps that use this feature
- ; will have the Trap Field of the descriptor contain 1 in bit 31 and a 0 in
- ; bit 30. They will also have a $100 in arg1 (bits 17 to 15) of the
- ; descriptor field. The Fortran parameters will thus appear something like
- ;
- ; __>> 1 => ToolBox trap (rather than OStrap)
- ; |__>> 0 => a 'regular' trap rather than a 'funny' trap. xx is rest of trap word
- ; || __>> Fcn field of descriptor 00 => 'proc'
- ; || | __>> Val/Var field of Arg1: 1 => 'proc' type
- ; || | |__>> Size field of Arg1: 00 => proc (a 'VAR proc' is illegal)
- ; || | || __>> Xfield pointer (4 bits currently)
- ; || | || |
- ; VV V VV V
- ; 10xx xxxx xxxx 0010 0 ..... yyyy
- ;
- ; All 'exceptional traps' with more than six args will have an encoded Fortran
- ; parameter of the type abcd 2000 0000 000z
- ; where 'a' is > $8 since bit 31 must be set and 30 must be clear (actually,$8..$B)
- ; and where 'z' is a number between 0 and 3 currently. Apparently (see notes at
- ; end of the routine) the parameter lists are set up for only four 'exceptional traps'
- ; 0=> NewWindow trap, 1=> NewControl, 2=> NewDialog, 3=> SFGetFile argument lists.
- ; Any other trap that used these same type of fields could also use the canned
- ; parameter fields, since the Trap Field is external to toolbx.sub and only the
- ; 'Xfields' values are canned into the program.
- ;
- ; Encoded format for 'exceptional traps' embedded at end of toolbx.sub :
- ; Xfields:
- ; ____________________________________________________________________________
- ; |31 30 29 27 26 24 23 21 20 18 17 15 14 12 11 9 8 6 5 3 2 0|
- ; | Fcn | Arg1 | Arg2 | Arg3 | Arg4 | Arg5 | Arg6 | Arg7 | Arg8 | Arg9 | Arg10 |
- ; |____________________________________________________________________________|
- ;
- ; where Fcn and Argx have their usual meanings:
- ;**************************************************************************************
-
- 0: XDEF toolbx2
-
- 0: Include SysEqu.txt
- 0: Include Amacs
-
-
-
- 0: QUAL toolbx2 ; b# =1 s#1 =proc5
-
- ;-refs - toolbx2
-
- 0: 48E7 0082 'H...' toolbx2 MOVEM.L A0/A6,-(A7)
- 4: 4BFA FFFA 1000000 LEA toolbx2,A5 ; A5 is local stack
- 8: 9BFC 0000 0014 '......' SUBA.L #20,A5
- E: BBE8 002A '...*' CMPA.L 42(A0),A5 ; are we in heap?
- 12: 6606 100001A BNE.S lab_1 ; no
- 14: 337C 0001 FFF8 '3|....' MOVE #1,-8(A1) ; mark as permanent ??
- 1A: 2A68 FFFC '*h..' lab_1 MOVEA.L -4(A0),A5 ; save QuickDraw globals
- 1E: 2600 '&.' MOVE.L D0,D3 ; get # of args
- 20: E588 '..' LSL.L #2,D0 ; get offset to beginning
- 22: 49F7 0808 'I...' LEA 8(A7,D0.L),A4 ; address of first arg (parms)
- 26: 2654 '&T' MOVEA.L (A4),A3 ; get ptr to descriptor parm
- 28: 2013 ' .' MOVE.L (A3),D0 ; get value of descriptor
- 2A: 6A08 1000034 BPL.S OStrap ; b32=0 => OStrap, 1=>TBtrap
- 2C: 0800 001E '....' BTST #$1E,D0 ; b30=1 => 'Funny' trap
- 30: 6600 018A 10001BC BNE FunTrap ; not really a trap
- ;
- ; Operating System traps and Toolbox traps
- ;
- 34: 2200 '".' OStrap
- MOVE.L D0,D1 ; trap descriptor into D1
- 36: 343C 0014 '4<..' MOVE #20,D2 ; prepare bits 20-31
- 3A: E4A1 '..' ASR.L D2,D1 ; lower 3 nybbles of trap word
- 3C: 0241 0FFF '.A..' ANDI #$FFF,D1 ; mask it off
- 40: 0041 A000 '.A..' ORI #$A000,D1 ; complete trap address
- 44: 3141 0D08 '1A..' MOVE D1,$D08(A0) ; stash it where??
- 48: 317C 4ED3 0D0A '1|N...' MOVE #$4ED3,$D0A(A0) ; insert 'JMP (A3)' where??
- 4E: 4A80 'J.' TST.L D0 ; check for toolbox trap
- 50: 6B00 0090 10000E2 BMI TBtrap ; Hibit set => toolbox trap
- ;
- ; Operating System traps
- ;
- 54: 740C 't.' MOVEQ #12,D2 ; prepare to discard upper 12..
- 56: E5A0 '..' ASL.L D2,D0 ; ..bits of descriptor (trapnum)
- 58: 2800 '(.' MOVE.L D0,D4 ; D4 has parameter controls
- 5A: 2C00 ',.' MOVE.L D0,D6
- 5C: 2C4C ',L' MOVEA.L A4,A6 ; ptr to TB parm word
- 5E: 5383 'S.' doNextArg
- SUBQ.L #1,D3 ; bump to next arg control
- 60: 6728 100008A BEQ.S endParse ; done parsing
- 62: 2666 '&f' MOVEA.L -(A6),A3 ; point to first arg
- 64: 0806 001D '....' BTST #$1D,D6 ; test b17=29-12 of control
- 68: 6602 100006C BNE.S isVAL ; 0=>VAL
- 6A: 2653 '&S' MOVEA.L (A3),A3 ; b17=1 is VAR. Put value in A3
- 6C: E386 '..' isVAL ASL.L #1,D6 ; shift left arg1
- 6E: 640C 100007C BHS.S useDregs ; 1=> use D registers
- 70: E386 '..' ASL.L #1,D6 ; Aregs. shift again for regnum
- 72: 6504 1000078 BLO.S useA1 ; use A1 if 11
- 74: 204B ' K' MOVEA.L A3,A0 ; use A0 if 10
- 76: 600E 1000086 BRA.S gotReg
- 78: 224B '"K' useA1 MOVEA.L A3,A1 ; A1 contains input
- 7A: 600A 1000086 BRA.S gotReg
- 7C: E386 '..' useDregs
- ASL.L #1,D6 ; use D regs. Shift to find which
- 7E: 6504 1000084 BLO.S useD1 ; 01 => D1
- 80: 200B ' .' MOVE.L A3,D0 ; 00 => D0
- 82: 6002 1000086 BRA.S gotReg
- 84: 220B '".' useD1 MOVE.L A3,D1 ; we'll use D1 reg
- 86: E386 '..' gotReg
- ASL.L #1,D6
- 88: 60D4 100005E BRA doNextArg ; continue parsing
- ;
- 8A: 47FA 0008 1000094 endParse
- LEA afterTrap,A3 ; set up for after trap returns
- 8E: 2C57 ',W' MOVEA.L (A7),A6 ; stack frame
- 90: 4EEE 0D08 'N...' JMP $D08(A6) ; Where is this??
- ;
- ; After execution of trap things resume here
- ;
- afterTrap
- 94: 0804 0013 '....' BTST #$13,D4 ; check b7=19-12 of control
- 98: 670E 10000A8 BEQ.S retD0 ; 0=> return val in D reg
- 9A: 0804 0012 '....' BTST #$12,D4 ; ret in A reg. Check b6=18-12
- 9E: 6604 10000A4 BNE.S retA1 ; ret in A0 if 10, A1 if 11
- A0: 2008 ' .' MOVE.L A0,D0 ; use A0 for return
- A2: 600C 10000B0 BRA.S retD1
- A4: 2009 ' .' retA1 MOVE.L A1,D0 ; use A1 for return
- A6: 6008 10000B0 BRA.S retD1
- A8: 0804 0012 '....' retD0 BTST #$12,D4 ; check b6=18-12 of control
- AC: 6702 10000B0 BEQ.S retD1 ; 0=> D0
- AE: 2001 ' .' MOVE.L D1,D0 ; 00 is D0, 01 is D1
- B0: 2057 ' W' retD1 MOVEA.L (A7),A0
- B2: 45E8 0D06 'E...' LEA $D06(A0),A2 ; MemError word??
- B6: 0804 000E '....' BTST #$E,D4 ; check b2=14-12 =>'Save' flag
- BA: 6702 10000BE BEQ.S savMemErr ; set means save
- BC: 4252 'BR' CLR (A2)
- BE: 0804 000F '....' savMemErr
- BTST #$F,D4 ; check b3=15-12
- C2: 6702 10000C6 BEQ.S noSave ; clear means nosave
- C4: 3480 '4.' MOVE D0,(A2) ; stash status in MemError
- C6: E884 '..' noSave ASR.L #4,D4 ; shift control right by 4 bits
- C8: 0244 0003 '.D..' ANDI #3,D4
- CC: 0C44 0003 '.D..' CMPI #3,D4
- D0: 6604 10000D6 BNE.S boolVal
- D2: 4880 'H.' EXT D0 ; sign extend word
- D4: 6006 10000DC BRA.S longX
- D6: 0C44 0001 '.D..' boolVal
- CMPI #1,D4 ; is it boolean?
- DA: 6602 10000DE BNE.S goExit ; No.
- DC: 48C0 'H.' longX EXT.L D0 ; sign extend longword
- DE: 6000 00FA 10001DA goExit BRA exit
- ;
- ; Toolbox traps
- ;
- E2: 2200 '".' TBtrap MOVE.L D0,D1 ; trap descriptor into D1
- E4: 343C 000F '4<..' MOVE #15,D2 ; prepare to discard lower 15 bits
- E8: E4A9 '..' LSR.L D2,D1 ; discard lower 5 args, get first
- EA: 0241 0007 '.A..' ANDI #7,D1 ; mask off arg 1
- EE: 0C41 0004 '.A..' CMPI #4,D1 ; 100=> VAR proc (illegal)
- F2: 670A 10000FE BEQ.S Xception ; More than 6 args=>exception
- ;
- ; regular toolbox trap. Parse the rest of the descriptor field
- ;
- F4: 343C 000C '4<..' MOVE #12,D2 ; it's a regular trap
- F8: E5A0 '..' ASL.L D2,D0 ; shift out trap number
- FA: 2800 '(.' MOVE.L D0,D4 ; D4 has control shifted 12 bits
- FC: 600A 1000108 BRA.S ProcFunc
- ;
- ; 'Exception' traps have more than the usual max of 6 args
- ;
- FE: E580 '..' Xception
- ASL.L #2,D0 ; prepare to step by 4 bytes
- 100: 43FA 00DE 10001E0 LEA Xfields,A1 ; Exception codes
- ;
- ; The exception trap must have low word with max 14 bits info since it's
- ; left-shifted by 2 below. Currently only offsets 0..3 are employed.
- ; Exception traps must have xxxy000z where z < 7 to fit into 512 bytes for the subroutine
- ;
- 104: 2831 0000 '(1..' MOVE.L 0(A1,D0.W),D4 ; revise control in D4
- ;
- ; Here is the normal entry point for procs or funcs
- ;
- 108: 47FA 0086 1000190 ProcFunc
- LEA parsProc,A3 ; prepare for 'proc' service
- 10C: 2004 ' .' MOVE.L D4,D0 ; shifted control word
- 10E: 0280 C000 0000 '......' ANDI.L #$C0000000,D0 ; $11... is bool flag b19,18
- ; mask bits 19, 18 of original descriptor
- 114: 4A80 'J.' TST.L D0 ; check function/proc field
- 116: 671E 1000136 BEQ.S ArgParsed ; 00=> proc, 01=>word
- ; 10=> long, 11=> bool (byte)
- ; not a proc. Must be 01 (word), 10 (longword), 11 (boolean)
- 118: 47FA 0066 1000180 LEA LongRslt,A3 ; set up as 10 (longword)
- 11C: 598F 'Y.' SUBQ.L #4,A7 ; space for longword on stack
- 11E: 0800 001E '....' BTST #$1E,D0 ; check bit 18 = 30-12 of lo fn
- 122: 6712 1000136 BEQ.S ArgParsed ; x0 => proc or long function
- ; must be 01 (word) or 11 (boolean)
- 124: 548F 'T.' ADDQ.L #2,A7 ; adjust stack for Word instead
- 126: 47FA 005C 1000184 LEA WordRslt,A3 ; initialize for Word result
- 12A: 0800 001F '....' BTST #$1F,D0 ; check bit 19=31-12 hi fn field
- 12E: 6706 1000136 BEQ.S ArgParsed ; 0x => word
- ;
- ; Fall-thru result is one-byte value (treated as boolean)
- ;
- 130: 47FA 0056 1000188 LEA BoolRslt,A3 ; set up for bool (use 2 bytes)
- 134: 4E71 'Nq' NOP ; spacer for even address
- 136: 2004 ' .' ArgParsed
- MOVE.L D4,D0 ; get shifted descriptor (parms)
- 138: E588 '..' LSL.L #2,D0 ; shift out Func/Proc flags
- 13A: 2C4C ',L' MOVEA.L A4,A6 ; A4 has Fortran arg
- ;
- ; Have done function/procedure analysis. Now figure out the arguments.
- ;
- 13C: 4A80 'J.' parsArgs
- TST.L D0 ; Is parm field empty?
- 13E: 673C 100017C BEQ.S goTrap ; Yes. => no args
- ;
- ; Field has arguments. Parse them
- ;
- 140: 2266 '"f' MOVEA.L -(A6),A1 ; Fortran arg into A1
- 142: 0800 001F '....' BTST #$1F,D0 ; check bit 17 =31-14 arg1 val/var
- 146: 6716 100015E BEQ.S ValArg ; b17=0 => val, 1=> var
- 148: 2F09 '/.' PUSH.L A1 ; It's a VAR arg. Push address on stk
- 14A: 0800 001E '....' BTST #$1E,D0 ; check bit 16 =30-14 size hi field
- 14E: 6728 1000178 BEQ.S GetNextArg ; 0x => proc or word result
- ; It's 1x: 10=>LongWord, 11=>Boolean
- 150: 0800 001D '....' BTST #$1D,D0 ; check bit 15 =29-14 size lo
- 154: 6722 1000178 BEQ.S GetNextArg ; (1)0 => LongWord
- ; Fallthru is 11=> Boolean
- 156: 0291 0000 0001 '......' ANDI.L #1,(A1) ; mask out all but first bit
- 15C: 601A 1000178 BRA.S GetNextArg ; fallthru: boolean
- ;
- 15E: 2211 '".' ValArg MOVE.L (A1),D1 ; get contents of val into D1
- 160: 0800 001E '....' BTST #$1E,D0 ; check bit 16 =30-14 hi arg size
- 164: 670C 1000172 BEQ.S ValWord ; 0x => proc or word
- ; It's 1x: LongWord or Boolean
- 166: 0800 001D '....' BTST #$1D,D0 ; check bit 15 = 29-14 lo size
- 16A: 670A 1000176 BEQ.S ValLong ; 10=> Long
- ; Fallthru is Boolean
- 16C: 4841 'HA' SWAP D1 ; swap hi/lo words of val
- 16E: 0241 0100 '.A..' ANDI #$100,D1 ; make it single byte value
- ; by modding by 256
- ;
- 172: 3F01 '?.' ValWord PUSH D1 ; Word result. Push word
- 174: 6002 1000178 BRA.S GetNextArg
- ;
- 176: 2F01 '/.' ValLong PUSH.L D1 ; Longword result
- 178: E788 '..' GetNextArg
- LSL.L #3,D0 ; process next argument
- 17A: 60C0 100013C BRA parsArgs
- ;
- ; Execute the trap by jumping to place where we stored the trap dispatch
- ; Return will be via (A3)
- ;
- 17C: 4EE8 0D08 'N...' goTrap JMP $D08(A0) ; Dope it out sometime ??
- ;
- ; These are pointed to by A3 for returning the results to Fortran
- ;
- 180: 201F ' .' LongRslt POP.L D0 ; pop a LongWord
- 182: 600C 1000190 BRA.S parsProc
-
-
- 184: 301F '0.' WordRslt
- POP D0 ; process result as a 'word'
- 186: 6006 100018E BRA.S xtend
- ;
- ; Pascal boolean has 0=> False and 1=> True
- ; Fortran uses 0=> False and -1 => True ($FFFF....)
- ;
- 188: 7000 'p.' BoolRslt MOVEQ #0,D0 ; Result is boolean (one byte)
- 18A: 101F '..' POP.B D0
- 18C: 4440 'D@' NEG D0 ; Make Pascal 1 (true) into -1
- 18E: 48C0 'H.' xtend EXT.L D0 ; sign-extend since Fortran
- ; uses FFF... as true
- ;
- 190: 598C 'Y.' parsProc
- SUBQ.L #4,A4 ; bump arg pointer
- 192: 2604 '&.' MOVE.L D4,D3 ; D3 has shifted control word
- 194: E58B '..' LSL.L #2,D3 ; shift out the Func/Proc field
- 196: 4A83 'J.' PopArg TST.L D3 ; any arguments to return?
- 198: 6740 10001DA BEQ.S exit ; No. Exit
- ;
- 19A: 0803 001F '....' BTST #$1F,D3 ; check bit 17 = 31-14 val/var flag
- 19E: 6716 10001B6 BEQ.S PopNxtArg ; 0=>val (nothing to return)
- ;
- ; It's a VAR parameter, so we have to return something back to Fortran
- ;
- 1A0: 0803 001E '....' BTST #$1E,D3 ; check bit 16 = 30-14 fn hi flag
- 1A4: 6710 10001B6 BEQ.S PopNxtArg ; 0x => proc (00) or word(01)
- ;
- ; It's a LongWord (10) or Boolean (11) variable
- ;
- 1A6: 0803 001D '....' BTST #$1D,D3 ; check bit 15 = 29-14 fn lo flag
- 1AA: 670A 10001B6 BEQ.S PopNxtArg ; x0 => it's a LongWord (10)
- ;
- ; fallthru case is Boolean. Since Pascal uses 0 for False and 1 for True
- ; while Fortran uses 0 for False and -1 for True, we'll test for true and act on it.
- ; Note: If ToolBox ever returns a single-byte var other than Boolean, Fortran would
- ; have problems here because we force it to return 0 (false) or -1 (true) only.
- ;
- 1AC: 2654 '&T' MOVEA.L (A4),A3 ; get value of result..
- 1AE: 2213 '".' MOVE.L (A3),D1 ; ..into D1
- 1B0: 6702 10001B4 BEQ.S isFalse ; Pascal 0 means False. Just exit
- 1B2: 72FF 'r.' MOVEQ #-1,D1 ; It's True, so we make Fortran true
- 1B4: 2681 '&.' isFalse MOVE.L D1,(A3) ; put bool back into A3
-
- 1B6: E78B '..' PopNxtArg
- LSL.L #3,D3 ;Do next arg in control word
- 1B8: 598C 'Y.' SUBQ.L #4,A4 ; bump arg pointer
- 1BA: 60DA 1000196 BRA PopArg
- ;
- ; These 'Funny' traps aren't really traps. One sets b31=1 for 'toolbox'
- ; and sets b30=1 for 'funny'. The low word in descriptor then has a
- ; 'callnum' (0..2) that is used for PTR, GETGLOB, MEMERROR
- ;
- 1BC: 103B 0006 10001C4 FunTrap
- MOVE.B jTable(D0.W),D0 ; get offset byte from table
- 1C0: 4EFB 0002 10001C4 JMP jTable(D0.W) ; execute pseudo trap
-
- ; These appear to be special PTR, GETGLOB, MEMERROR toolbx calls
-
- 1C4: '.' jTable DC.B 4 ;sPTR-jTable offset to PTR
- 1C5: '.' DC.B $A ;sGetGl-jTable offset to GetGlobal
- 1C6: '.' DC.B $10 ;sMemEr-jTable offset to MemError
- 1C7: '.' DC.B 0 ; end of table pad, force even addr
- ; * * * * * * *
- ; Example:
- ;* FUNCTION PTR (ANYTYPE) : PTR;
- ;* INTEGER PTR
- ;* PARAMETER (PTR=Z'C0000000')
- ;
- ; * * * * * * *
- 1C8: 202F 000C ' /..' sPTR MOVE.L 12(A7),D0 ; get address of VAR into D0
- 1CC: 600C 10001DA BRA.S exit
- ; * * * * * * *
- ; Example:
- ;* FUNCTION GETGLOBAL : PTR;
- ;* INTEGER GETGLOBAL
- ;* PARAMETER (GETGLOBAL=Z'C0000001')
- ;
- ; * * * * * * *
- 1CE: 2028 FFFC ' (..' sGetGl MOVE.L -4(A0),D0 ; get address of globals
- 1D2: 6006 10001DA BRA.S exit
- ; * * * * * * *
- ; Example:
- ;* FUNCTION MEMERROR : OSERR; ; Returns last memory error.
- ;* INTEGER MEMERROR
- ;* PARAMETER (MEMERROR=Z'C0000002')
- ;
- ; * * * * * * *
- 1D4: 3028 0D06 '0(..' sMemEr MOVE $D06(A0),D0 ; ?? check this out
- 1D8: 48C0 'H.' EXT.L D0 ; sign-extend
- ;
- 1DA: 4CDF 4100 'L.A.' exit MOVEM.L (A7)+,A0/A6 ; restore regs and return
- 1DE: 4E75 'Nu' RTS
- ; * * * * * * *
- ;
- ; These are 'extended' parameter sets for calls that have more than 6 arguments.
- ;
- ; These exception codes begin at the 'FCN' field (usually bit19 in descriptor)
- ; but here extended up to b31. This enables us to have max of 10 arguments in
- ; a toolbx call. Note that the 'control exception' flag (bit 29) is NOT used in
- ; the implementation, even tho the earlier documentation on toolbx.sub said that
- ; it was used. Instead, 'exceptional traps' (viz. those that have more than six
- ; arguments always set the 'function' field (bits 18 and 19 of descriptor) to '00'
- ; and they always set the 'first arg' field (bits 17 to 15 of descriptor) to '100'
- ; which flags them as VAR procedures (illegal). The ACTUAL function descriptors
- ; are stored as a table in toolbx.sub as given below.
- ;
- ; Note that entries 0 and 4 are identical, as are 2 and 5. Suggestion is that only
- ; entries 0..3 are implemented??
- ;
- ;-refs - toolbx2
- 1E0: 96CC A680 $96CCA680 Xfields ; entry 0 NewWindow
- ADDRL com_3
- 1E4: 96CC 9250 $96CC9250 ADDRL com_2 ; entry 1 NewControl
- 1E8: 96CC A690 $96CCA690 ADDRL com_4 ; entry 2 NewDialog
- 1EC: 1645 2C40 $16452C40 ADDRL com_7 ; entry 3 SFGetFile
- 1F0: 96CC A680 $96CCA680 ADDRL com_3 ; entry 4 These not used ??
- 1F4: 96CC A690 $96CCA690 ADDRL com_4 ; entry 5
- 1F8: B645 36D9 $B64536D9 ADDRL com_5 ; entry 6
- 1FC: 0000 0000 0 ADDRL com_6 ; entry 7
-
- 1FE: END
- ;**************************************************************************************
- ; The above longword fields are encoded argument lists. Their structure is as
- ; follows:
- ; Encoded format for 'exceptional traps':
- ; ____________________________________________________________________________
- ; |31 30 29 27 26 24 23 21 20 18 17 15 14 12 11 9 8 6 5 3 2 0|
- ; | Fcn | Arg1 | Arg2 | Arg3 | Arg4 | Arg5 | Arg6 | Arg7 | Arg8 | Arg9 | Arg10 |
- ; |____________________________________________________________________________|
- ;
- ; where Fcn and Argx have their usual meanings:
- ; _____
- ; Fcn: | 0 0 | Procedure
- ; | 0 1 | Word
- ; | 1 0 | Longword
- ; | 1 1 | Byte (boolean)
- ; |_____|
- ; ________________________
- ; Argx: |Val/Var | Size | Val: 0 (Pass by value) Var: 1 (Pass by address)
- ; |________|_______________| Size: 2 bits with same meaning as 'Fcn' field
- ;
- ;**************************************************************************************
- ; Entry 0: ToolBox trap number $A913 (NewWindow ).
- ; Encoded descriptor is $9132 0000. Xfield is $96CC A680.
- ; Note the '2' in the fourth nybble of descriptor.
- ; It's the $100 in 'Arg1' fieldand and is the flag for the 'exceptional trap'
- ;
- ;* FUNCTION NewWindow (WStorage: Ptr; BoundsRect: Rect; Title: Str255;
- ;* Visible: Boolean; ProcID: Integer; Behind: WindowPtr;
- ;* GoAwayFlag: Boolean; RefCon: LongInt): WindowPtr;
- ; INTEGER NEWWINDOW
- ; PARAMETER (NEWWINDOW=Z'91320000')
- ;
- ; the Xfield of $96CC A680 decodes to
- ; Lfunc, Lval, Lvar, Lvar, Bval, Wval, Lval, Bval, Lval ( a Long Function with 8 args)
- ;
- ;******
- ; Entry 1: ToolBox trap number $A954 (NewControl).
- ; Encoded descriptor is $9542 0001. Xfield is $96CC 9250.
- ;
- ;* FUNCTION NewControl (TheWindow: windowPtr; BoundsRect: Rect; Title: Str255;
- ;* Visible: Boolean; Value: Integer; Min,Max: Integer;
- ;* ProcID: Integer; RefCon: LongInt): ControlHandle;
- ; INTEGER NEWCONTROL
- ; PARAMETER (NEWCONTROL=Z'95420001')
- ;
- ; the Xfield of $96CC 9250 decodes to
- ; Lfunc, Lval, Lvar, Lvar, Bval, Wval, Wval, Wval, Wval, Lval ( a Long Function with 9 args)
- ;
- ;*******
- ; Entry 2: ToolBox trap number $A97D (NewDialog).
- ; Encoded descriptor is $97D2 0002. Xfield is $96CC A690.
- ;
- ;* FUNCTION NewDialog (DStorage: Ptr; BoundsRect: Rect; Title: Str255;
- ;* Visible: Boolean; ProcID: Integer; Behind: WindowPtr;
- ;* GoAwayFlag: Boolean; RefCon: LongInt; Items: Handle):
- ;* DialogPtr;
- ; INTEGER NEWDIALOG
- ; PARAMETER (NEWDIALOG=Z'97D20002')
- ;
- ; the Xfield $96CC A690 decodes to
- ; Lfunc, Lval, Lvar, Lvar, Bval, Wval, Lval, Bval, Lval, Lval ( a Long Function with 9 args)
- ;
- ; ********
- ; Entry 3: ToolBox trap number $A9EA (Pack3).
- ; Encoded descriptor is $9EA2 0003. Xfield is $1645 2C40.
- ;
- ; NOTE that Absoft's toolbx.par file says 'selector' is the
- ; FIRST argument. It's not. It's the last. See also stdfil.for
- ;
- ;* PROCEDURE SFGetFile ( where: Point; prompt: Str25;
- ;* fileFilter: ProcPtr; numTypes: Integer;
- ;* typeList: SFListPtr; dlgHook: ProcPtr;
- ;* VAR reply: SFReply; selector: Integer;);
- ; INTEGER SFGETFILE |___<<< note
- ; PARAMETER (SFGETFILE=Z'9EA20003')
- ;
- ; the Xfield $1645 2C40 decodes to
- ; Proc, Lval, Lvar, Lval, Wval, Lval, Lval, Lvar, Wval ( a procedure with 8 args)
- ;
- ; Here's how it's called in stdfil.for. Note the last '2' is the 'selector'
- ; call toolbx(SFGETFILE,where,0,0,n,toolbx(PTR,types),
- ; + 0,reply,2)
- ;------->------->------->------>---->|____<<< note
- ;
- ;**************************************************************************************
-