; Macro Definitions for CP/M 2.2 BIOS Data Structures. ; ; dtbl - drive table ; ; dpb label - disk parameter block ; sectors_per_track, ; block_size, ; disk_size, ; number_dir_entries, ; checked_dir_entries, ; track_offset, ; ; dph disk_parameter_block - disk parameter header ; ; endef - generate the ram data areas ; ; ; These macros do not support sector skew, ; and assume that the first sector is allways 0. ; ; ; Example, where only drive A: and E: are defined, both with ; the avrcpm disk definition (standard ss/sd floppy but without skew): ; ; dphtab: dtbl ; dpb dpb243, 26, 1024, 243, 64, 64, 2 ; dpha: dph dpb243 ; dphe: dph dpb243 ; endef ; ; Drive Table. Contains 16 one word entries. dtbl macro ?list local ?n,?i ?n set 0 irp ?drv, ifnb dw ?drv else dw 0 endif ?n set ?n+1 endm if ?n gt 16 .' Too many drives. Max 16 allowed' exitm endif if ?n lt 16 rept (16-?n) dw 0 endm endif ?dn set 0 endm ddb macro data,messag ;; define a db statement db data messag endm ddw macro data,messag ;; define a dw statement dw data messag endm dpb macro pbn,nsec,bls,dks,dir,cks,ofs ;; generate the set statements for later tables als&pbn set (dks)/8 ;;size of allocation vector if ((dks) mod 8) ne 0 als&pbn set als&pbn+1 endif css&pbn set (cks+3)/4 ;;number of checksum elements ;; generate the block shift value blkval set bls/128 ;;number of sectors/block blkshf set 0 ;;counts right 0's in blkval blkmsk set 0 ;;fills with 1's from right rept 16 ;;once for each bit position if blkval eq 1 exitm endif ;; otherwise, high order 1 not found yet blkshf set blkshf+1 blkmsk set (blkmsk shl 1) or 1 blkval set blkval/2 endm ;; generate the extent mask byte blkval set bls/1024 ;;number of kilobytes/block extmsk set 0 ;;fill from right with 1's rept 16 if blkval eq 1 exitm endif ;; otherwise more to shift extmsk set (extmsk shl 1) or 1 blkval set blkval/2 endm ;; may be double byte allocation if (dks) gt 256 extmsk set (extmsk shr 1) endif ;; now generate directory reservation bit vector dirrem set dir ;;# remaining to process dirbks set bls/32 ;;number of entries per block dirblk set 0 ;;fill with 1's on each loop rept 16 if dirrem eq 0 exitm endif ;; not complete, iterate once again ;; shift right and add 1 high order bit dirblk set (dirblk shr 1) or 8000h if dirrem gt dirbks dirrem set dirrem-dirbks else dirrem set 0 endif endm pbn: ddw %nsec,<;sec per track> ddb %blkshf,<;block shift> ddb %blkmsk,<;block mask> ddb %extmsk,<;extnt mask> ddw %(dks)-1,<;disk size-1> ddw %(dir)-1,<;directory max> ddb %dirblk shr 8,<;alloc0> ddb %dirblk and 0ffh,<;alloc1> ddw %(cks+3)/4,<;check size> ddw %ofs,<;offset> endm lset macro lb,dn,val lb&dn set val endm ldw macro lb,dn dw lb&dn endm dph macro pbn dw 0000h,0000h ;no translate table dw 0000h,0000h ;scratch area dw dirbuf,pbn ;dir buff,parm block ; dw csv&?dn,alv&?dn ;check, alloc vectors ldw csv,%?dn ldw alv,%?dn lset css,%?dn,css&pbn lset als,%?dn,als&pbn ?dn set ?dn+1 endm lds macro lb,dn,val lb&dn: ds val&dn endm endef macro begdat equ $ dirbuf: ds 128 ;directory access buffer ?n set 0 rept ?dn lds alv,%?n,als lds csv,%?n,css ?n set ?n+1 endm enddat equ $ datsiz equ $-begdat endm