4 Register allocator allocated variable to iy, which is needed for stack access when accessing local variables unreachable by the frame pointer.
12 * Raw directory item (32 bytes).
17 unsigned char fname
[16];
18 unsigned char str_terminator
; // 0x0d
19 unsigned char unused1
[2];
23 unsigned char unused2
[4];
29 * Raw directory sektor.
31 * Has 8 directory items (256 bytes).
39 * Elementary file descriptor
44 unsigned char fname
[17];
53 * Directory handler with cache for 8 file descriptors.
57 unsigned char position
;
58 FS_MZ_FHEADER fheader
[8];
62 #pragma disable_warning 85 // Unreferenced function arguments in fd_read_sector(), my_strncpy().
63 extern char fd_read_sector ( unsigned int block
, void* dma
)
66 FS_MZ_BLDIR
*bl_dir
= dma
;
68 for(i
= 0; i
< 8; i
++)
70 bl_dir
->ditem
[i
].ftype
= i
+ 0;
71 bl_dir
->ditem
[i
].fsize
= i
+ 1;
72 bl_dir
->ditem
[i
].fstrt
= i
+ 2;
73 bl_dir
->ditem
[i
].fexec
= i
+ 3;
74 bl_dir
->ditem
[i
].block
= i
+ 4;
80 char* my_strncpy ( char *dst
, const char *src
, size_t n
, char terminator
)
85 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
88 * Read raw directory data and transform into FS_MZDIR *dir.
91 char fs_read_directory_block ( FS_MZDIR
*dir
, unsigned int block
)
94 #if defined(__SDCC_mcs51) || defined (__SDCC_STACK_AUTO)
95 static __xdata FS_MZ_BLDIR bl_dir
;
99 FS_MZ_DITEM
*dir_item
;
100 FS_MZ_FHEADER
*fil_header
;
103 res
= fd_read_sector ( block
, &bl_dir
);
104 if ( res
) return ( res
);
106 for ( i
= 0; i
< 8; i
++ ) {
108 dir_item
= &bl_dir
.ditem
[i
];
109 fil_header
= &dir
->fheader
[i
];
111 fil_header
->ftype
= dir_item
->ftype
;
112 fil_header
->fsize
= dir_item
->fsize
;
113 fil_header
->fstrt
= dir_item
->fstrt
;
114 fil_header
->fexec
= dir_item
->fexec
;
115 fil_header
->block
= dir_item
->block
;
117 my_strncpy ( fil_header
->fname
, dir_item
->fname
, sizeof ( fil_header
->fname
), 0x0d );
123 __xdata FS_MZDIR dir
;
128 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
131 fs_read_directory_block(&dir
, 0);
133 for(i
= 0; i
< 8; i
++)
135 ASSERT(dir
.fheader
[i
].ftype
== i
+ 0);
136 ASSERT(dir
.fheader
[i
].fsize
== i
+ 1);
137 ASSERT(dir
.fheader
[i
].fstrt
== i
+ 2);
138 ASSERT(dir
.fheader
[i
].fexec
== i
+ 3);
139 ASSERT(dir
.fheader
[i
].block
== i
+ 4);