]>
Commit | Line | Data |
---|---|---|
1 | ; Macro Definitions for CP/M 2.2 BIOS Data Structures.\r | |
2 | ;\r | |
3 | ; dtbl <dph0,dph1,...> - drive table\r | |
4 | ;\r | |
5 | ; dpb label - disk parameter block\r | |
6 | ; sectors_per_track,\r | |
7 | ; block_size,\r | |
8 | ; disk_size,\r | |
9 | ; number_dir_entries,\r | |
10 | ; checked_dir_entries,\r | |
11 | ; track_offset,\r | |
12 | ;\r | |
13 | ; dph disk_parameter_block - disk parameter header\r | |
14 | ;\r | |
15 | ; endef - generate the ram data areas\r | |
16 | ; \r | |
17 | ;\r | |
18 | ; These macros do not support sector skew, \r | |
19 | ; and assume that the first sector is allways 0.\r | |
20 | ;\r | |
21 | ;\r | |
22 | ; Example, where only drive A: and E: are defined, both with \r | |
23 | ; the avrcpm disk definition (standard ss/sd floppy but without skew):\r | |
24 | ;\r | |
25 | ; dphtab: dtbl <dpha, 0, 0, 0, dphe>\r | |
26 | ; dpb dpb243, 26, 1024, 243, 64, 64, 2\r | |
27 | ; dpha: dph dpb243\r | |
28 | ; dphe: dph dpb243\r | |
29 | ; endef\r | |
30 | ;\r | |
31 | \r | |
32 | ; Drive Table. Contains 16 one word entries.\r | |
33 | \r | |
34 | dtbl macro ?list\r | |
35 | local ?n,?i\r | |
36 | ?n set 0\r | |
37 | irp ?drv,<?list>\r | |
38 | ifnb <?drv>\r | |
39 | dw ?drv\r | |
40 | else\r | |
41 | dw 0\r | |
42 | endif\r | |
43 | ?n set ?n+1\r | |
44 | endm\r | |
45 | \r | |
46 | if ?n gt 16\r | |
47 | .' Too many drives. Max 16 allowed'\r | |
48 | exitm\r | |
49 | endif\r | |
50 | \r | |
51 | if ?n lt 16\r | |
52 | rept (16-?n)\r | |
53 | dw 0\r | |
54 | endm\r | |
55 | endif\r | |
56 | ?dn set 0\r | |
57 | endm\r | |
58 | \r | |
59 | ddb macro data,messag\r | |
60 | ;; define a db statement\r | |
61 | db data messag\r | |
62 | endm\r | |
63 | ddw macro data,messag\r | |
64 | ;; define a dw statement\r | |
65 | dw data messag\r | |
66 | endm\r | |
67 | \r | |
68 | dpb macro pbn,nsec,bls,dks,dir,cks,ofs\r | |
69 | ;; generate the set statements for later tables\r | |
70 | als&pbn set (dks)/8 ;;size of allocation vector\r | |
71 | if ((dks) mod 8) ne 0\r | |
72 | als&pbn set als&pbn+1\r | |
73 | endif\r | |
74 | css&pbn set (cks+3)/4 ;;number of checksum elements\r | |
75 | ;; generate the block shift value\r | |
76 | blkval set bls/128 ;;number of sectors/block\r | |
77 | blkshf set 0 ;;counts right 0's in blkval\r | |
78 | blkmsk set 0 ;;fills with 1's from right\r | |
79 | rept 16 ;;once for each bit position\r | |
80 | if blkval eq 1\r | |
81 | exitm\r | |
82 | endif\r | |
83 | ;; otherwise, high order 1 not found yet\r | |
84 | blkshf set blkshf+1\r | |
85 | blkmsk set (blkmsk shl 1) or 1\r | |
86 | blkval set blkval/2\r | |
87 | endm\r | |
88 | ;; generate the extent mask byte\r | |
89 | blkval set bls/1024 ;;number of kilobytes/block\r | |
90 | extmsk set 0 ;;fill from right with 1's\r | |
91 | rept 16\r | |
92 | if blkval eq 1\r | |
93 | exitm\r | |
94 | endif\r | |
95 | ;; otherwise more to shift\r | |
96 | extmsk set (extmsk shl 1) or 1\r | |
97 | blkval set blkval/2\r | |
98 | endm\r | |
99 | ;; may be double byte allocation\r | |
100 | if (dks) gt 256\r | |
101 | extmsk set (extmsk shr 1)\r | |
102 | endif\r | |
103 | ;; now generate directory reservation bit vector\r | |
104 | dirrem set dir ;;# remaining to process\r | |
105 | dirbks set bls/32 ;;number of entries per block\r | |
106 | dirblk set 0 ;;fill with 1's on each loop\r | |
107 | rept 16\r | |
108 | if dirrem eq 0\r | |
109 | exitm\r | |
110 | endif\r | |
111 | ;; not complete, iterate once again\r | |
112 | ;; shift right and add 1 high order bit\r | |
113 | dirblk set (dirblk shr 1) or 8000h\r | |
114 | if dirrem gt dirbks\r | |
115 | dirrem set dirrem-dirbks\r | |
116 | else\r | |
117 | dirrem set 0\r | |
118 | endif\r | |
119 | endm\r | |
120 | pbn: ddw %nsec,<;sec per track>\r | |
121 | ddb %blkshf,<;block shift>\r | |
122 | ddb %blkmsk,<;block mask>\r | |
123 | ddb %extmsk,<;extnt mask>\r | |
124 | ddw %(dks)-1,<;disk size-1>\r | |
125 | ddw %(dir)-1,<;directory max>\r | |
126 | ddb %dirblk shr 8,<;alloc0>\r | |
127 | ddb %dirblk and 0ffh,<;alloc1>\r | |
128 | ddw %(cks+3)/4,<;check size>\r | |
129 | ddw %ofs,<;offset>\r | |
130 | endm\r | |
131 | \r | |
132 | \r | |
133 | lset macro lb,dn,val\r | |
134 | lb&dn set val\r | |
135 | endm\r | |
136 | ldw macro lb,dn\r | |
137 | dw lb&dn\r | |
138 | endm\r | |
139 | \r | |
140 | dph macro pbn\r | |
141 | dw 0000h,0000h ;no translate table\r | |
142 | dw 0000h,0000h ;scratch area\r | |
143 | dw dirbuf,pbn ;dir buff,parm block\r | |
144 | ; dw csv&?dn,alv&?dn ;check, alloc vectors\r | |
145 | ldw csv,%?dn\r | |
146 | ldw alv,%?dn\r | |
147 | lset css,%?dn,css&pbn\r | |
148 | lset als,%?dn,als&pbn\r | |
149 | ?dn set ?dn+1\r | |
150 | endm\r | |
151 | \r | |
152 | \r | |
153 | lds macro lb,dn,val\r | |
154 | lb&dn: ds val&dn\r | |
155 | endm\r | |
156 | \r | |
157 | \r | |
158 | endef macro\r | |
159 | begdat equ $\r | |
160 | \r | |
161 | dirbuf: ds 128 ;directory access buffer\r | |
162 | ?n set 0\r | |
163 | rept ?dn\r | |
164 | lds alv,%?n,als\r | |
165 | lds csv,%?n,css\r | |
166 | ?n set ?n+1\r | |
167 | endm\r | |
168 | enddat equ $\r | |
169 | datsiz equ $-begdat\r | |
170 | endm\r | |
171 | \r |