1345
|
1 **************************************************
|
|
2 * System Call: F$FModul
|
|
3 *
|
|
4 * Function: Find module directory entry
|
|
5 *
|
|
6 * Input: A = Module type
|
|
7 * X = Module name string pointer
|
|
8 * Y = Name string DAT image pointer
|
|
9 *
|
|
10 * Output: A = Module type
|
|
11 * B = Module revision
|
|
12 * X = Updated past name string
|
|
13 * U = Module directory entry pointer
|
|
14 *
|
|
15 * Error: CC = C bit set; B = error code
|
|
16 *
|
1145
|
17 FFModul pshs u preserve register stack pointer
|
|
18 lda R$A,u get module type
|
|
19 ldx R$X,u get pointer to name
|
|
20 ldy R$Y,u get pointer to DAT image of name (from caller)
|
|
21 bsr L068D go find it
|
|
22 puls y restore register stack pointer
|
|
23 std R$D,y save type & revision
|
|
24 stx R$X,y save updated name pointer
|
|
25 stu R$U,y save pointer to directory entry
|
|
26 rts return
|
|
27
|
|
28 * Find module in module directory
|
|
29 * Entry: A=Module type
|
|
30 * X=Pointer to module name
|
|
31 * Y=DAT image pointer for module name
|
|
32 L068D equ *
|
|
33 IFNE H6309
|
|
34 tfr 0,u init directory pointer to nothing
|
|
35 ELSE
|
|
36 ldu #$0000
|
|
37 ENDC
|
|
38 pshs d,u preserve (Why B?)
|
|
39 bsr L0712 Go find 1st char of module name requested
|
|
40 cmpa #PDELIM Is it a '/'?
|
|
41 beq L070B yes, exit with error
|
1451
|
42 lbsr ParseNam parse the name to find the end & length
|
1145
|
43 bcs L070E error (illegal name), exit
|
|
44 ldu <D.ModEnd get module directory end pointer
|
|
45 bra L0700 start looking for it
|
|
46
|
|
47 * Main module directory search
|
|
48 * Entry: A=Module type
|
|
49 * B=Module name length
|
|
50 * X=Logical address of name in Caller's 64k space
|
|
51 * Y=DAT image of caller (for module name)
|
|
52 * U=Module directory Entry ptr (current module being checked)
|
|
53 L06A1 pshs d,x,y Preserve Mod type/nm len, Log. Addr, DAT Img ptr
|
|
54 pshs x,y Preserve Log. addr & DAT Img ptr
|
|
55 ldy MD$MPDAT,u Does the module have a DAT Image ptr?
|
|
56 beq L06F6 no, skip module
|
|
57 ldx MD$MPtr,u get module pointer
|
|
58 pshs x,y Save module ptr & DAT Img ptr of module
|
|
59 ldd #M$Name # bytes to go in to get module name ptr
|
|
60 lbsr L0B02 Go get the module name ptr
|
|
61 IFNE H6309
|
|
62 addr d,x add it to module start
|
|
63 ELSE
|
|
64 leax d,x
|
|
65 ENDC
|
|
66 pshs x,y preserve module name ptr & DAT pointer
|
|
67 leax 8,s Point to addr of name we are searching for
|
|
68 ldb 13,s get name length
|
|
69 leay ,s point to module name name ptr within module DAT
|
|
70 * Stack:
|
|
71 * 0-1,s = Ptr to module name within Module DAT Img
|
|
72 * 2-3,s = Ptr to module's DAT Img
|
|
73 * 4-5,s = Ptr to module start
|
|
74 * 6-7,s = Ptr to module's DAT Img
|
|
75 * 8-9,s = Ptr to name we are looking for in caller's 64K space
|
|
76 * A-B,s = Ptr to caller's DAT Img
|
|
77 * C,s = Module type we are looking for (0=don't care)
|
|
78 * D,s = Length of module name
|
|
79 * E-F,s = Ptr to name we are looking for in caller's 64K space
|
|
80 * 10-11,s = Ptr to caller's DAT Img
|
|
81 * 12,s = Module type looking for
|
|
82 * 13,s = ??? (B from entry)
|
|
83 * 14-15,s = Module directory ptr (inited to 0)
|
|
84 lbsr L07DE compare the names
|
|
85 leas 4,s purge stack
|
|
86 puls y,x restore module pointer & DAT image
|
|
87 leas 4,s purge stack
|
|
88 bcs L06FE name didn't match, skip ahead
|
|
89 ldd #M$Type
|
|
90 lbsr L0B02
|
|
91 sta ,s
|
|
92 stb $07,s
|
|
93 lda $06,s
|
|
94 beq L06ED
|
|
95 anda #TypeMask
|
|
96 beq L06E1
|
|
97 eora ,s
|
|
98 anda #TypeMask
|
|
99 bne L06FE
|
|
100 L06E1 lda $06,s
|
|
101 anda #LangMask
|
|
102 beq L06ED
|
|
103 eora ,s
|
|
104 anda #LangMask
|
|
105 bne L06FE
|
|
106 L06ED puls y,x,d
|
|
107 abx
|
|
108 clrb
|
|
109 ldb 1,s
|
|
110 leas 4,s
|
|
111 rts
|
|
112
|
|
113 L06F6 leas 4,s purge stack
|
|
114 ldd 8,s do we have a directory pointer?
|
|
115 bne L06FE yes, skip ahead
|
|
116 stu 8,s save directory entry pointer
|
|
117 L06FE puls d,x,y restore pointers
|
|
118 L0700 leau -MD$ESize,u move back 1 entry in module table
|
|
119 cmpu <D.ModDir at the beginning?
|
|
120 bhs L06A1 no, check entry
|
|
121 ldb #E$MNF get error code (module not found)
|
|
122 fcb $8C skip 2 bytes
|
|
123
|
|
124 L070B ldb #E$BNam get error code
|
|
125 coma set carry for error
|
|
126 L070E stb 1,s save error code for caller
|
|
127 puls d,u,pc return
|
|
128
|
|
129 * Skip spaces in name string & return first character of name
|
|
130 * Entry: X=Pointer to name
|
|
131 * Y=DAT image pointer
|
|
132 * Exit : A=First character of name
|
|
133 * B=DAT image block offset
|
|
134 * X=Logical address of name
|
|
135 L0712 pshs y preserve DAT image pointer
|
|
136 L0714 lbsr AdjBlk0 adjust pointer to offset for mapping in
|
|
137 lbsr L0AC8 map in block
|
|
138 leax 1,x
|
|
139 cmpa #C$SPAC space?
|
|
140 beq L0714 yes, eat it
|
|
141 leax -1,x move back to first character
|
|
142 L0720 pshs d,cc preserve char
|
|
143 tfr y,d copy DAT pointer to D
|
|
144 subd 3,s calculate DAT image offset
|
|
145 asrb divide it by 2
|
|
146 lbsr CmpLBlk convert X to logical address in 64k map
|
|
147 puls cc,d,y,pc restore & return
|