978
|
1 * F$DatMod
|
|
2 *
|
|
3 * Entry:
|
|
4 * A = Type/Language
|
|
5 * B = Attr/Rev
|
|
6 * X = address of name
|
|
7 * Y = size
|
|
8 *
|
|
9 * Exit:
|
|
10 * X = address of last byte of name + 1
|
|
11 * Y = module entry point address
|
|
12 * U = module header address
|
|
13
|
|
14 Level equ 1
|
|
15
|
|
16 ifp1
|
|
17 use defsfile
|
|
18 endc
|
|
19
|
|
20 Type set Prgrm+Objct
|
|
21 Revs set ReEnt+1
|
|
22 edition set $01
|
|
23
|
|
24 mod eom,name,Type,Revs,start,256
|
|
25
|
|
26 name fcs "DatMod"
|
|
27 fcb $01
|
|
28
|
|
29 * routine cold
|
|
30 start clra
|
|
31 leax name,pcr
|
|
32 os9 F$Link
|
|
33 bcs error
|
|
34 leay SvcTbl,pcr
|
|
35 os9 F$SSvc
|
|
36 clrb
|
|
37 error os9 F$Exit
|
|
38
|
|
39 F$DatMod equ $25
|
|
40
|
|
41 SvcTbl equ *
|
|
42 fcb F$DatMod
|
|
43 fdb DatMod-*-2
|
|
44 fcb $80
|
|
45
|
|
46 s.namlen equ 0
|
|
47 s.nextnm equ 2
|
|
48 s.modptr equ 6
|
|
49 s.size equ 8
|
|
50
|
|
51 DatMod
|
|
52 leas -s.size,s
|
|
53
|
|
54 * First, parse the name
|
|
55 ldx R$X,u get the name of the module
|
|
56 os9 F$PrsNam parse it: TODO /x/x crashes machine!
|
|
57 lbcs DatModEr
|
|
58 sty s.nextnm,s save updated name pointer
|
|
59 tfr y,d get ptr to last char + 1 into D
|
|
60 subd R$X,u get length of name in D
|
|
61 std s.namlen,s save name length for later
|
|
62 addd R$Y,u add name length to caller's specified size
|
|
63 addd #M$IDSize+3 add module header size and CRC
|
|
64 pshs u
|
|
65 os9 F$SRqMem ask system for this memory
|
|
66 stu s.modptr+2,s else save pointer to module
|
|
67 puls u
|
|
68 lbcs DatModEr branch if error
|
|
69 ldy s.modptr,s get module pointer into Y
|
|
70
|
|
71 * We have the memory for the Data Module, now populate it
|
|
72 std M$Size,y save size in module
|
|
73 ldd #M$ID12 get module ID bytes
|
|
74 std M$ID,y save in module
|
|
75 ldd R$D,u get passed type/lang and attr/rev
|
|
76 bita #TypeMask is type zero?
|
|
77 bne StoreIt branch if not...
|
|
78 anda #Data else force type to be data
|
|
79 StoreIt std M$Type,y and save in module
|
|
80 ldd M$Size,y get module ptr's size
|
|
81 subd s.namlen,s subtract name's length from size
|
|
82 subd #3 and CRC
|
|
83 std M$Name,y and save pointer to it in module header
|
|
84
|
|
85 * Compute header parity
|
|
86 pshs d save D (holds offset to name from within module)
|
|
87
|
|
88 ldd #M$IDSize-1
|
|
89 pshs b
|
|
90 clrb
|
|
91 EorLoop eora b,y
|
|
92 incb
|
|
93 cmpb ,s
|
|
94 bne EorLoop
|
|
95 puls b
|
|
96 coma
|
|
97 sta M$Parity,y save parity byte
|
|
98
|
|
99 * Copy name from caller's X to data module
|
|
100 ldx R$X,u point to caller's passed name
|
|
101 puls d get name ptr in module into D
|
|
102 addd s.modptr,s add absolute address of module
|
|
103 tfr d,y and put in Y
|
|
104 ldb s.namlen+1,s get length of name
|
|
105 CpyLoop lda ,x+ get char
|
|
106 sta ,y+ put char
|
|
107 decb decrement counter
|
|
108 bne CpyLoop
|
|
109 ora #$80 set high bit of last character we got
|
|
110 sta -1,y and put it back in module
|
|
111
|
|
112 * Initialize CRC with constant $FFFFFF
|
|
113 ldd #$FFFF get CRC initializer
|
|
114 std ,y and store
|
|
115 sta 2,y
|
|
116
|
|
117 * Compute CRC and validate Module
|
|
118 pshs u
|
|
119 tfr y,u U now holds pointer to CRC
|
|
120 ldx s.modptr+2,s get pointer to module
|
|
121 ldy M$Size,x get module size
|
|
122 leay -3,y subtract CRC length
|
|
123 os9 F$CRC update CRC
|
|
124 ldd ,u get 1st two bytes of CRC
|
|
125 coma complement them
|
|
126 comb
|
|
127 std ,u save them back
|
|
128 lda 2,u get third byte of CRC
|
|
129 coma complement them
|
|
130 sta 2,u save it back
|
|
131 os9 F$VModul and validate module
|
|
132 puls u
|
|
133 bcc DatModOk branch if all ok
|
|
134 pshs cc,b preserve error info
|
|
135 ldd M$Size,s get module size alloced from stack
|
|
136 tfr x,u put module ptr from X to U
|
|
137 os9 F$SRtMem return memory
|
|
138 puls b,cc get error info
|
|
139 bra DatModEr and exit
|
|
140
|
|
141 * Put return info in caller's regs
|
|
142 DatModOk ldx s.nextnm,s get pointer to char after name
|
|
143 stx R$X,u save it in caller's X
|
|
144 ldx s.modptr,s get module pointer
|
|
145 stx R$U,u save it in caller's U
|
|
146 leax M$IDSize,x get entry point
|
|
147 stx R$Y,u save it in caller's Y
|
|
148
|
|
149 DatModEr leas s.size,s
|
|
150 rts
|
|
151
|
|
152 emod
|
|
153 eom equ *
|
|
154 end
|