diff --git a/build.sh b/build.sh index 24ccd26..6ef7f99 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -bcc -S main.c implementation/lsfs.c +bcc -S main.c -o main.s echo -e "push bp mov bp,sp push 10[bp] diff --git a/disk.out b/disk.out index 76fcdc5..c4415f7 100644 Binary files a/disk.out and b/disk.out differ diff --git a/driver/disk.h b/driver/disk.h index 0ad4fa4..a6054c7 100644 --- a/driver/disk.h +++ b/driver/disk.h @@ -2,30 +2,36 @@ int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment) -long* index; +long index; long number_sectors; void* data_buffer; -int data_buffer_segment; +unsigned int data_buffer_segment; { #asm #define index 4[bp]; // Note that this is a 32-bit argument. #define number_sectors 8[bp]; - #define data_buffer 10[bp]; - #define data_buffer_segment 12[bp]; + #define data_buffer 12[bp]; + #define data_buffer_segment 14[bp]; push bp mov bp,sp pusha - lsfs_load_data: mov ax, index + call 0x0000:0x7C2A mov WORD [DAPACK.lba_addr_dw_low], ax mov bx, number_sectors + mov ax, bx + call 0x0000:0x7C2A mov WORD [DAPACK.blkcnt], bx mov cx, data_buffer_segment + mov ax, cx + call 0x0000:0x7C2A mov WORD [DAPACK.db_addr_segment], cx mov dx, data_buffer; + mov ax, dx + call 0x0000:0x7C2A mov WORD [DAPACK.db_addr_offset], dx mov si, #DAPACK ; address of mov ah, #0x42 ; READ diff --git a/implementation/lsfs.c b/implementation/lsfs.c index 9e807f4..0d26cc1 100644 --- a/implementation/lsfs.c +++ b/implementation/lsfs.c @@ -1,26 +1,81 @@ #include "lsfs.h" -#include "../main.h" - -struct lsfs_file { - long file_id[2]; - long table_entry_pointer[2]; - Table_Entry_Kind entry_kind; - char* filename; - long owner_id; - long size[2]; - long creation_date[2]; - long access_time[2]; - long modification_time[2]; - long number_sector; - long table_entry_sector_index[2]; - long data_pointer[NUM_DATA_POINTERS * 2]; -}; - -int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry) +/* #include "../std_singos/string.h" */ +extern FSCI fsci; + +int lsfs_disk_getattr(find_file, path) +lsfs_file* find_file; +char* path; +{ + int i; + String_Array *split_path = string_split_c(path, '/', false); + Length_String *filename = split_path->strings[split_path->length-1]; + + /* Start from the master table*/ + Directory_Table *dir_table = lsfs_find_directory(path, true); + + for (i = 0; i < DEFAULT_TABLE_SIZE; ++i) + { + if(strcmp( filename->chars, dir_table->entries[i].filename ) == 0) { + find_file->file_id[0] = dir_table->entries[i].file_id; + find_file->entry_kind = dir_table->entries[i].entry_kind; + find_file->table_entry_pointer[0] = i; + find_file->filename = dir_table->entries[i].filename; + find_file->table_entry_sector_index[0] = dir_table->entries[i].table_entry_sector_index; + find_file->owner_id = 1; + find_file->size[0] = dir_table->entries[i].file_size; /* dir_table->entries[i].data_pointer[0]; ;*/ + find_file->creation_date[0] = 0; + find_file->access_time[0] = 0; + find_file->modification_time[0] = 0; + memcpy(find_file->data_pointer, dir_table->entries[i].data_pointer, NUM_DATA_POINTERS * 8); + find_file->number_sector = 1; /* TODO: should be loaded from disk.*/ + return 1; + } + } + return 0; +} + +Directory_Table* lsfs_find_directory(path, drop_filename) +char *path; +short drop_filename; +{ + int number_of_traversal; + int i, j; + String_Array *split_path; + Directory_Table *dir_table = calloc(1, sizeof(Directory_Table)); + /* printf("Table index: %lu \n",fsci.master_table_index ); */ + disk_service_read_data_from_disk(fsci.master_table_index[0], DEFAULT_TABLE_SIZE, dir_table, 0x7e0); + split_path = string_split_c(path, '/', false); + + number_of_traversal = split_path->length; + + if (drop_filename) + { + number_of_traversal -= 1; + } + + /* Start from the master table */ + for (i = 0; i < number_of_traversal; ++i) + { + for (j = 0; j < DEFAULT_TABLE_SIZE; ++j) + { + if (strcmp(dir_table->entries[j].filename, split_path->strings[i]->chars) == 0) + { + int index_sector = dir_table->entries[j].data_pointer[0]; + /* printf("Table index: %lu \n",index_sector ); */ + disk_service_read_data_from_disk(index_sector, DEFAULT_TABLE_SIZE, dir_table); + break; + } + } + } + return dir_table; +} + +int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry, data_segment) lsfs_file *file; int buffer_size; char *data; long offset_to_next_entry; +unsigned int data_segment; { int integer_file_size = file->size; int integer_offset = offset_to_next_entry; @@ -36,6 +91,7 @@ long offset_to_next_entry; int data_pointer_index = 0; /* start at first data pointer. */ + dump_ax(file->size); if (data_length > buffer_size) { data_length = buffer_size; @@ -63,11 +119,14 @@ long offset_to_next_entry; { break; } - disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], DEFAULT_DATA_POINTER_SIZE, tmp_buffer); - memcpy((data + amount_read), tmp_buffer, amount_to_read); + disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], DEFAULT_DATA_POINTER_SIZE, tmp_buffer, 0x7e0); + print_newline(); + dump_ax(file->data_pointer[data_pointer_index]); + print_newline(); + memcpy((data + amount_read), data_segment, tmp_buffer, 0x7e0, amount_to_read); data_length -= amount_to_read; amount_read += amount_to_read; - data_pointer_index++; + data_pointer_index = data_pointer_index + 2; /* Rember that we only use 32-bit, and thats why we jump to at a time*/ /* free(tmp_buffer); */ } else if (remaining_offset < (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE)) @@ -84,14 +143,14 @@ long offset_to_next_entry; amount_to_read = ((DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE) - remaining_offset); } - disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], DEFAULT_DATA_POINTER_SIZE, tmp_buffer); + disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], DEFAULT_DATA_POINTER_SIZE, tmp_buffer, 0x7e0); - memcpy(data, (tmp_buffer + remaining_offset), amount_to_read); + memcpy(data, data_segment, (tmp_buffer + remaining_offset), 0x7e0, amount_to_read); data_length -= amount_to_read; amount_read += amount_to_read; remaining_offset -= amount_to_read; - data_pointer_index++; + data_pointer_index = data_pointer_index + 2; /* Rember that we only use 32-bit, and thats why we jump to at a time*/ /* free(tmp_buffer); */ } else diff --git a/implementation/lsfs.h b/implementation/lsfs.h index 24701a1..df17d89 100644 --- a/implementation/lsfs.h +++ b/implementation/lsfs.h @@ -1,6 +1,280 @@ #ifndef LSFS_H #define LSFS_H +#include "../main.h" + typedef struct lsfs_file lsfs_file; +typedef struct Directory_Table Directory_Table; +typedef struct Table_Entry Table_Entry; + +int lsfs_disk_getattr(find_file, path, fsci); +int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry); +Directory_Table* lsfs_find_directory(path, drop_filename, fsci); + +typedef enum Table_Entry_Kind +{ + /* These are specific values since, is has to corrospond to the implementation in assembly*/ + ENTRY_EMPTY = 0, + ENTRY_FILE = 1, + ENTRY_DIRECTORY = 2, +} Table_Entry_Kind; + +struct Table_Entry +{ + char filename[256]; + unsigned long file_id[2]; + unsigned long file_size[2]; + void* ext_file_data_low; + void* ext_file_data_high; + long number_sector_s; /* <- Just try to remove the last undercore and compile . */ + short entry_kind; + short extra_control_bits1; + short extra_control_bits2; + short extra_control_bits3; + long table_entry_sector_index[2]; + long data_pointer[NUM_DATA_POINTERS * 2]; /* if it is a directory, the first pointer will be to the next table. */ +}; + +struct lsfs_file { + unsigned long file_id[2]; + long table_entry_pointer[2]; + Table_Entry_Kind entry_kind; + char* filename; + long owner_id; + unsigned long size[2]; + long creation_date[2]; + long access_time[2]; + long modification_time[2]; + long number_sector; + long table_entry_sector_index[2]; + long data_pointer[NUM_DATA_POINTERS * 2]; +}; + +struct Directory_Table +{ + Table_Entry entries[DEFAULT_TABLE_SIZE]; + +}; + +/*typedef struct File_System_Control_Information +{ + char filesystem_information[256]; + long master_table_index[2]; + long this_partition_offset_on_disk[2]; + long next_free_sector[2]; + long next_uniqe_id[2]; /* both files and directories gets this. + long next_sector_reuse_pointer[2]; + long last_sector_index_on_partition[2]; + long maximum_sectors_on_disk[2]; + long sector_size_on_disk[2]; + long not_used[48]; + +} FSCI; +*/ + +int lsfs_disk_getattr(find_file, path, fsci) +lsfs_file* find_file; +char *path; +FSCI *fsci; +{ + int i; + String_Array *split_path = string_split_c(path, '/', false); + Length_String *filename = split_path->strings[split_path->length-1]; + + /* Start from the master table*/ + Directory_Table *dir_table = lsfs_find_directory(path, true, fsci); + + for (i = 0; i < DEFAULT_TABLE_SIZE; i++) + { + int j; + print(dir_table->entries[i].filename); + print(filename->chars); + print_newline(); + print_newline(); + print("Size of table_entry: "); + dump_ax(sizeof(Table_Entry)); + print_newline(); + print_newline(); + if(strcmp( filename->chars, dir_table->entries[i].filename ) == 0) { + find_file->file_id[0] = dir_table->entries[i].file_id[0]; + find_file->entry_kind = dir_table->entries[i].entry_kind; + find_file->table_entry_pointer[0] = i; + find_file->filename = dir_table->entries[i].filename; + find_file->table_entry_sector_index[0] = dir_table->entries[i].table_entry_sector_index; + find_file->owner_id = 1; + find_file->size[0] = dir_table->entries[i].file_size[0]; /* dir_table->entries[i].data_pointer[0]; ;*/ + find_file->creation_date[0] = 0; + find_file->access_time[0] = 0; + find_file->modification_time[0] = 0; + dump_ax(dir_table->entries[i].data_pointer[0]); + /* memcpy(find_file->data_pointer, dir_table->entries[i].data_pointer, NUM_DATA_POINTERS * 8); */ + for (j = 0; j < NUM_DATA_POINTERS; j = j + 2) + { + find_file->data_pointer[j] = dir_table->entries[i].data_pointer[j]; + dump_ax(find_file->data_pointer[j]); + } + + + find_file->number_sector = 1; /* TODO: should be loaded from disk.*/ + return 1; + } + } + return 0; +} + +Directory_Table* lsfs_find_directory(path, drop_filename, fsci) +char *path; +short drop_filename; +FSCI *fsci; +{ + int number_of_traversal; + int i, j; + String_Array *split_path; + Directory_Table *dir_table = calloc(1, sizeof(Directory_Table)); + /* printf("Table index: %lu \n",fsci->master_table_index ); */ + dump_ax(fsci->master_table_index[0]); + disk_service_read_data_from_disk(fsci->master_table_index[0], (long) DEFAULT_TABLE_SIZE, dir_table, 0x7e0); + print(dir_table->entries[0].filename); + split_path = string_split_c(path, '/', false); + + number_of_traversal = split_path->length; + + + if (drop_filename) + { + number_of_traversal -= 1; + } + + /* Start from the master table */ + for (i = 0; i < number_of_traversal; ++i) + { + for (j = 0; j < DEFAULT_TABLE_SIZE; ++j) + { + print_newline(); + print("New: "); + print(dir_table->entries[j].filename); + print("vs "); + print(split_path->strings[i]->chars); + print_newline(); + if (strcmp(dir_table->entries[j].filename, split_path->strings[i]->chars) == 0) + { + long index_sector = dir_table->entries[j].data_pointer[0]; + /* printf("Table index: %lu \n",index_sector ); */ + /* print(dir_table->entries[j].filename); */ + dump_ax(index_sector); + disk_service_read_data_from_disk(index_sector, (long) DEFAULT_TABLE_SIZE, dir_table, 0x7e0); + break; + } + } + } + return dir_table; +} + +int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry, data_segment) +lsfs_file *file; +unsigned int buffer_size; +char *data; +long offset_to_next_entry; +unsigned int data_segment; +{ + unsigned int integer_file_size = file->size[0]; + unsigned int integer_offset = offset_to_next_entry; + unsigned int integer_datapointer = 0; + unsigned int data_length = integer_file_size - integer_offset; + unsigned int amount_read = 0; + unsigned int amount_to_read = 0; + unsigned int remaining_offset = offset_to_next_entry; + void *next_data; + /* printf("READ: buffer_size: %d\n", buffer_size); */ + /* printf("READ: Data length: %d\n", data_length); */ + /* printf("READ: Offset length: %d\n", offset_to_next_entry); */ + + + int data_pointer_index = 0; /* start at first data pointer. */ + + + + if (data_length > buffer_size) + { + data_length = buffer_size; + } + + while(data_length > 0) /* We have more to write */ + { + /* printf("READ: Remaing Data length: %d\n", data_length); */ + if (remaining_offset == 0) + { + char *tmp_buffer = calloc(DEFAULT_DATA_POINTER_SIZE, SECTOR_SIZE); + /* assert(tmp_buffer); */ + + if (data_length < (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE)) + { + amount_to_read = data_length; + } + else + { + amount_to_read = (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE); + } + /* disk_service_read_data_from_disk(lsfs_sector_offset index, uint32_t number_sector, void* data_buffer) */ + integer_datapointer = file->data_pointer[data_pointer_index]; + if (integer_datapointer == 0) + { + break; + } + print_newline(); + dump_ax(file->data_pointer[data_pointer_index]); + print_newline(); + next_data = data + amount_read; + dump_ax(next_data); + print_newline(); + disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], (long) DEFAULT_DATA_POINTER_SIZE, next_data, data_segment); + + /* memcpy((data + amount_read), data_segment, tmp_buffer, 0x7e0, amount_to_read); */ + + data_length -= amount_to_read; + amount_read += amount_to_read; + data_pointer_index = data_pointer_index + 2; /* Rember that we only use 32-bit, and thats why we jump to at a time*/ + /* free(tmp_buffer); */ + } + else if (remaining_offset < (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE)) + { + char *tmp_buffer = calloc(1, (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE)); + /* assert(tmp_buffer); */ + + if (data_length < ((DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE) - remaining_offset) ) + { + amount_to_read = data_length; + } + else + { + amount_to_read = ((DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE) - remaining_offset); + } + + disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], (long) DEFAULT_DATA_POINTER_SIZE, tmp_buffer, 0x7e0); + + memcpy(data, data_segment, (tmp_buffer + remaining_offset), 0x7e0, amount_to_read); + data_length -= amount_to_read; + amount_read += amount_to_read; + remaining_offset -= amount_to_read; + + data_pointer_index = data_pointer_index + 2; /* Rember that we only use 32-bit, and thats why we jump to at a time*/ + /* free(tmp_buffer); */ + } + else + { + /* We have to skip a whole data pointer: */ + remaining_offset -= (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE); + data_pointer_index = data_pointer_index + 2; + } + + } + /* + time_t current_time; + time ( ¤t_time ); + file->access_time = current_time; + */ + return amount_read; + +} #endif \ No newline at end of file diff --git a/implementation/lsfs.s b/implementation/lsfs.s index 232ee80..06f7ad1 100644 --- a/implementation/lsfs.s +++ b/implementation/lsfs.s @@ -1,9 +1,6 @@ ! 1 ! 1 # 1 "implementation/lsfs.c" -! 1 # 4 "implementation/lsfs.h" -! 4 typedef struct lsfs_file lsfs_file; -!BCC_EOS -! 5 # 1 "implementation/../std_singos/stdio.h" +! 1 # 1 "implementation/../std_singos/stdio.h" ! 1 void print(string); !BCC_EOS ! 2 void* dump_ax_return(input); @@ -345,8 +342,7 @@ mov [_global_heap_next],ax mov ax,6[bp] mov [_global_heap_end],ax !BCC_EOS -! 55 re -! 55 turn 0; +! 55 return 0; xor ax,ax pop si pop di @@ -359,20 +355,21 @@ ret ! 59 { export _get_heap_next _get_heap_next: -! 60 return global_heap_next; +! 60 return global_heap_n push bp mov bp,sp push di push si +! 60 ext; mov ax,[_global_heap_next] pop si pop di pop bp ret !BCC_EOS -! 61 # 16 "implementation/../main.h" -! 16 } -! 17 # 2 "implementation/../std_singos/string.h" +! 61 # 19 "implementation/../main.h" +! 19 } +! 20 # 2 "implementation/../std_singos/string.h" ! 2 typedef struct Length_String { ! 3 short dynamic; !BCC_EOS @@ -583,17 +580,124 @@ _memcpy.destination_segment set 4 ! 166 } ret ! 167 -! 168 String_Array *string_split_c(string, delim, keep_delim) -! 169 char *string; +! 168 int strcmp(source_1, source_2) +! 169 char* source_1; +export _strcmp +_strcmp: +!BCC_EOS +! 170 char* source_2; +!BCC_EOS +! 171 { +! 172 int i; +!BCC_EOS +! 173 int count; +!BCC_EOS +! 174 +! 175 count = strlen(source_1); +push bp +mov bp,sp +push di +push si +add sp,*-4 +! Debug: list * char source_1 = [S+$A+2] (used reg = ) +push 4[bp] +! Debug: func () int = strlen+0 (used reg = ) +call _strlen +inc sp +inc sp +! Debug: eq int = ax+0 to int count = [S+$A-$A] (used reg = ) +mov -8[bp],ax +!BCC_EOS +! 176 if (count != strlen(source_2)) +! Debug: list * char source_2 = [S+$A+4] (used reg = ) +push 6[bp] +! Debug: func () int = strlen+0 (used reg = ) +call _strlen +inc sp +inc sp +! Debug: ne int = ax+0 to int count = [S+$A-$A] (used reg = ) +! Debug: expression subtree swapping +cmp ax,-8[bp] +je .A +.B: +! 177 { +! 178 +! 179 } +! 180 +! 181 +! 182 for (i = 0; i < count; ++i) +.A: +! Debug: eq int = const 0 to int i = [S+$A-8] (used reg = ) +xor ax,ax +mov -6[bp],ax +!BCC_EOS +!BCC_EOS +! 183 { +jmp .E +.F: +! 184 if(source_1[i] != source_2[i]) +! Debug: ptradd int i = [S+$A-8] to * char source_2 = [S+$A+4] (used reg = ) +mov ax,-6[bp] +add ax,6[bp] +mov bx,ax +! Debug: ptradd int i = [S+$A-8] to * char source_1 = [S+$A+2] (used reg = bx) +mov ax,-6[bp] +add ax,4[bp] +mov si,ax +! Debug: ne char = [bx+0] to char = [si+0] (used reg = ) +mov al,[si] +cmp al,[bx] +je .10 +.11: +! 185 { +! 186 return -1; +mov ax,*-1 +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 187 } +! 188 } +.10: +! 189 +! 190 return 0; +.D: +! Debug: preinc int i = [S+$A-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +.E: +! Debug: lt int count = [S+$A-$A] to int i = [S+$A-8] (used reg = ) +mov ax,-6[bp] +cmp ax,-8[bp] +jl .F +.12: +.C: +xor ax,ax +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 191 # 223 +! 223 +! 224 } +! 225 +! 226 String_Array *string_split_c(string, delim, keep_delim) +! Register BX SI used in function strcmp +! 227 char *string; export _string_split_c _string_split_c: !BCC_EOS -! 170 char delim; +! 228 char delim; !BCC_EOS -! 171 short keep_delim; +! 229 short keep_delim; !BCC_EOS -! 172 { -! 173 return length_string_split(make_length_string_c(string), delim, keep_delim); +! 230 { +! 231 return length_string_split(make_length_string_c(string), delim, keep_delim); push bp mov bp,sp push di @@ -621,15 +725,15 @@ pop di pop bp ret !BCC_EOS -! 174 } -! 175 -! 176 Length_String *make_length_string_c(cstring) -! 177 char *cstring; +! 232 } +! 233 +! 234 Length_String *make_length_string_c(cstring) +! 235 char *cstring; export _make_length_string_c _make_length_string_c: !BCC_EOS -! 178 { -! 179 return make_length_string(strlen(cstring, 0x7e0), cstring); +! 236 { +! 237 return make_length_string(strlen(cstring, 0x7e0), cstring); push bp mov bp,sp push di @@ -655,18 +759,19 @@ pop di pop bp ret !BCC_EOS -! 180 } -! 181 -! 182 Length_String *make_length_string(length, chars) -! 183 unsigned int length; +! 238 } +! 239 +! 240 Length_String *make_length_string(length, chars) +! 241 unsigned int length; export _make_length_string _make_length_string: !BCC_EOS -! 184 char *chars; +! 242 char *chars; !BCC_EOS -! 185 { -! 186 -! 187 Length_String *legth_string = malloc(sizeof(Length_String)); +! 243 { +! 244 +! 245 Length_String *legth_string = malloc +! 245 (sizeof(Length_String)); push bp mov bp,sp push di @@ -683,7 +788,7 @@ inc sp ! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = ) mov -6[bp],ax !BCC_EOS -! 188 char *copy = malloc(length + 1); +! 246 char *copy = malloc(length + 1); dec sp dec sp ! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = ) @@ -698,7 +803,7 @@ inc sp ! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = ) mov -8[bp],ax !BCC_EOS -! 189 memcpy(copy, 0x7e0, chars, 0x7e0, length); +! 247 memcpy(copy, 0x7e0, chars, 0x7e0, length); ! Debug: list unsigned int length = [S+$A+2] (used reg = ) push 4[bp] ! Debug: list int = const $7E0 (used reg = ) @@ -715,7 +820,7 @@ push -8[bp] call _memcpy add sp,*$A !BCC_EOS -! 190 copy[length] = '\0'; +! 248 copy[length] = '\0'; ! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = ) mov ax,4[bp] add ax,-8[bp] @@ -724,28 +829,27 @@ mov bx,ax xor al,al mov [bx],al !BCC_EOS -! 191 -! 192 legth_string->dynamic = 0; +! 249 +! 250 legth_string->dynamic = 0; mov bx,-6[bp] ! Debug: eq int = const 0 to short = [bx+0] (used reg = ) xor ax,ax mov [bx],ax !BCC_EOS -! 193 legth_string->length = length; +! 251 legth_string->length = length; mov bx,-6[bp] ! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = ) mov ax,4[bp] mov 2[bx],ax !BCC_EOS -! 194 legth_string->chars = (char *)chars; +! 252 legth_string->chars = (char *)chars; mov bx,-6[bp] ! Debug: eq * char chars = [S+$A+4] to * char = [bx+4] (used reg = ) mov si,6[bp] mov 4[bx],si !BCC_EOS -! 195 -! 196 return legth_string -! 196 ; +! 253 +! 254 return legth_string; mov ax,-6[bp] add sp,*4 pop si @@ -753,25 +857,25 @@ pop di pop bp ret !BCC_EOS -! 197 } -! 198 -! 199 String_Array *length_string_split(string, delim, keep_delim) +! 255 } +! 256 +! 257 String_Array *length_string_split(string, delim, keep_delim) ! Register BX SI used in function make_length_string -! 200 Length_String *string; +! 258 Length_String *string; export _length_string_split _length_string_split: !BCC_EOS -! 201 char delim; +! 259 char delim; !BCC_EOS -! 202 short keep_delim; +! 260 short keep_delim; !BCC_EOS -! 203 { -! 204 unsigned int i; +! 261 { +! 262 unsigned int i; !BCC_EOS -! 205 unsigned int last; +! 263 unsigned int last; !BCC_EOS -! 206 -! 207 unsigned int count = 0; +! 264 +! 265 unsigned int count = 0; push bp mov bp,sp push di @@ -781,33 +885,33 @@ add sp,*-6 xor ax,ax mov -$A[bp],ax !BCC_EOS -! 208 unsigned int insert_index = 0; +! 266 unsigned int insert_index = 0; dec sp dec sp ! Debug: eq int = const 0 to unsigned int insert_index = [S+$E-$E] (used reg = ) xor ax,ax mov -$C[bp],ax !BCC_EOS -! 209 String_Array *result; +! 267 String_Array *result; !BCC_EOS -! 210 int k; +! 268 int k; !BCC_EOS -! 211 -! 212 i = 0; +! 269 +! 270 i = 0; add sp,*-4 ! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = ) xor ax,ax mov -6[bp],ax !BCC_EOS -! 213 last = 0; +! 271 last = 0; ! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = ) xor ax,ax mov -8[bp],ax !BCC_EOS -! 214 while(i < string->length) { -jmp .B -.C: -! 215 if (string->chars[i] == delim) { +! 272 while(i < string->length) { +jmp .14 +.15: +! 273 if (string->chars[i] == delim) { mov bx,4[bp] ! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = ) mov ax,-6[bp] @@ -816,64 +920,64 @@ mov bx,ax ! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = ) mov al,[bx] cmp al,6[bp] -jne .D -.E: -! 216 if (i > last+1) { +jne .16 +.17: +! 274 if (i > last+1) { ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) inc ax cmp ax,-6[bp] -jae .F -.10: -! 217 ++count; +jae .18 +.19: +! 275 ++count; ! Debug: preinc unsigned int count = [S+$12-$C] (used reg = ) mov ax,-$A[bp] inc ax mov -$A[bp],ax !BCC_EOS -! 218 } -! 219 last = i; -.F: +! 276 } +! 277 last = i; +.18: ! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-6[bp] mov -8[bp],ax !BCC_EOS -! 220 } -! 221 ++i; -.D: +! 278 } +! 279 ++i; +.16: ! Debug: preinc unsigned int i = [S+$12-8] (used reg = ) mov ax,-6[bp] inc ax mov -6[bp],ax !BCC_EOS -! 222 } -! 223 if (i > last+1) { -.B: +! 280 } +! 281 if (i > last+1) { +.14: mov bx,4[bp] ! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = ) mov ax,-6[bp] cmp ax,2[bx] -jb .C -.11: -.A: +jb .15 +.1A: +.13: ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) inc ax cmp ax,-6[bp] -jae .12 -.13: -! 224 ++count; +jae .1B +.1C: +! 282 ++count; ! Debug: preinc unsigned int count = [S+$12-$C] (used reg = ) mov ax,-$A[bp] inc ax mov -$A[bp],ax !BCC_EOS -! 225 } -! 226 -! 227 result = create_length_string_array(count); -.12: +! 283 } +! 284 +! 285 result = create_length_string_array(count); +.1B: ! Debug: list unsigned int count = [S+$12-$C] (used reg = ) push -$A[bp] ! Debug: func () * struct String_Array = create_length_string_array+0 (used reg = ) @@ -883,45 +987,45 @@ inc sp ! Debug: eq * struct String_Array = ax+0 to * struct String_Array result = [S+$12-$10] (used reg = ) mov -$E[bp],ax !BCC_EOS -! 228 -! 229 if (keep_delim) +! 286 +! 287 if (keep_delim) mov ax,8[bp] test ax,ax -je .14 -.15: -! 230 { -! 231 k = 0; +je .1D +.1E: +! 288 { +! 289 k = 0; ! Debug: eq int = const 0 to int k = [S+$12-$12] (used reg = ) xor ax,ax mov -$10[bp],ax !BCC_EOS -! 232 } -! 233 else -! 234 { -jmp .16 -.14: -! 235 k = 1; +! 290 } +! 291 else +! 292 { +jmp .1F +.1D: +! 293 k = 1; ! Debug: eq int = const 1 to int k = [S+$12-$12] (used reg = ) mov ax,*1 mov -$10[bp],ax !BCC_EOS -! 236 } -! 237 -! 238 i = 0; -.16: +! 294 } +! 295 +! 296 i = 0; +.1F: ! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = ) xor ax,ax mov -6[bp],ax !BCC_EOS -! 239 last = 0; +! 297 last = 0; ! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = ) xor ax,ax mov -8[bp],ax !BCC_EOS -! 240 while(i < string->length) { -jmp .18 -.19: -! 241 if (string->chars[i] == delim) { +! 298 while(i < string->length) { +jmp .21 +.22: +! 299 if (string->chars[i] == delim) { mov bx,4[bp] ! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = ) mov ax,-6[bp] @@ -930,17 +1034,17 @@ mov bx,ax ! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = ) mov al,[bx] cmp al,6[bp] -jne .1A -.1B: -! 242 if (i > last+1) { +jne .23 +.24: +! 300 if (i > last+1) { ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) inc ax cmp ax,-6[bp] -jae .1C -.1D: -! 243 result->strings[insert_index++] = create_length_string(i-(last+k), string->chars+(last+k)); +jae .25 +.26: +! 301 result->strings[insert_index++] = create_length_string(i-(last+k), string->chars+(last+k)); ! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] add ax,-$10[bp] @@ -980,39 +1084,39 @@ mov [bx],si inc sp inc sp !BCC_EOS -! 244 } -! 245 last = i; -.1C: +! 302 } +! 303 last = i; +.25: ! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-6[bp] mov -8[bp],ax !BCC_EOS -! 246 } -! 247 ++i; -.1A: +! 304 } +! 305 ++i; +.23: ! Debug: preinc unsigned int i = [S+$12-8] (used reg = ) mov ax,-6[bp] inc ax mov -6[bp],ax !BCC_EOS -! 248 } -! 249 if (i > last+1) { -.18: +! 306 } +! 307 if (i > last+1) { +.21: mov bx,4[bp] ! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = ) mov ax,-6[bp] cmp ax,2[bx] -jb .19 -.1E: -.17: +jb .22 +.27: +.20: ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) inc ax cmp ax,-6[bp] -jae .1F -.20: -! 250 result->strings[insert_index++] = create_length_string(i-(last+k), ((string->chars)+(last+k))); +jae .28 +.29: +! 308 result->strings[insert_index++] = create_length_string(i-(last+k), ((string->chars)+(last+k))); ! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] add ax,-$10[bp] @@ -1052,10 +1156,10 @@ mov [bx],si inc sp inc sp !BCC_EOS -! 251 } -! 252 -! 253 return result; -.1F: +! 309 } +! 310 +! 311 return result; +.28: mov ax,-$E[bp] add sp,*$C pop si @@ -1063,17 +1167,17 @@ pop di pop bp ret !BCC_EOS -! 254 -! 255 } -! 256 -! 257 String_Array *create_length_string_array(array_size) +! 312 +! 313 } +! 314 +! 315 String_Array *create_length_string_array(array_size) ! Register BX SI used in function length_string_split -! 258 int array_size; +! 316 int array_size; export _create_length_string_array _create_length_string_array: !BCC_EOS -! 259 { -! 260 String_Array *result = malloc(sizeof(String_Array)); +! 317 { +! 318 String_Array *result = malloc(sizeof(String_Array)); push bp mov bp,sp push di @@ -1090,13 +1194,13 @@ inc sp ! Debug: eq * void = ax+0 to * struct String_Array result = [S+8-8] (used reg = ) mov -6[bp],ax !BCC_EOS -! 261 result->length = array_size; +! 319 result->length = array_size; mov bx,-6[bp] ! Debug: eq int array_size = [S+8+2] to unsigned int = [bx+0] (used reg = ) mov ax,4[bp] mov [bx],ax !BCC_EOS -! 262 result->strings = malloc(array_size * sizeof(Length_String)); +! 320 result->strings = malloc(array_size * sizeof(Length_String)); ! Debug: mul int = const 6 to int array_size = [S+8+2] (used reg = ) mov ax,4[bp] mov dx,ax @@ -1113,7 +1217,7 @@ mov bx,-6[bp] ! Debug: eq * void = ax+0 to * * struct Length_String = [bx+2] (used reg = ) mov 2[bx],ax !BCC_EOS -! 263 return result; +! 321 return result; mov ax,-6[bp] inc sp inc sp @@ -1122,20 +1226,20 @@ pop di pop bp ret !BCC_EOS -! 264 } -! 265 -! 266 -! 267 Length_String *create_length_string(length, chars) +! 322 } +! 323 +! 324 +! 325 Length_String *create_length_string(length, chars) ! Register BX used in function create_length_string_array -! 268 unsigned int length; +! 326 unsigned int length; export _create_length_string _create_length_string: !BCC_EOS -! 269 char *chars; +! 327 char *chars; !BCC_EOS -! 270 { -! 271 -! 272 Length_String *legth_string = malloc(sizeof(Length_String)); +! 328 { +! 329 +! 330 Length_String *legth_string = malloc(sizeof(Length_String)); push bp mov bp,sp push di @@ -1152,7 +1256,7 @@ inc sp ! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = ) mov -6[bp],ax !BCC_EOS -! 273 char *copy = malloc(length + 1); +! 331 char *copy = malloc(length + 1); dec sp dec sp ! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = ) @@ -1167,7 +1271,7 @@ inc sp ! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = ) mov -8[bp],ax !BCC_EOS -! 274 memcpy(copy, 0x7e0, chars, 0x7e0, length); +! 332 memcpy(copy, 0x7e0, chars, 0x7e0, length); ! Debug: list unsigned int length = [S+$A+2] (used reg = ) push 4[bp] ! Debug: list int = const $7E0 (used reg = ) @@ -1184,7 +1288,7 @@ push -8[bp] call _memcpy add sp,*$A !BCC_EOS -! 275 copy[length] = '\0'; +! 333 copy[length] = '\0'; ! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = ) mov ax,4[bp] add ax,-8[bp] @@ -1193,27 +1297,27 @@ mov bx,ax xor al,al mov [bx],al !BCC_EOS -! 276 -! 277 legth_string->dynamic = 1; +! 334 +! 335 legth_string->dynamic = 1; mov bx,-6[bp] ! Debug: eq int = const 1 to short = [bx+0] (used reg = ) mov ax,*1 mov [bx],ax !BCC_EOS -! 278 legth_string->length = length; +! 336 legth_string->length = length; mov bx,-6[bp] ! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = ) mov ax,4[bp] mov 2[bx],ax !BCC_EOS -! 279 legth_string->chars = copy; +! 337 legth_string->chars = copy; mov bx,-6[bp] ! Debug: eq * char copy = [S+$A-$A] to * char = [bx+4] (used reg = ) mov si,-8[bp] mov 4[bx],si !BCC_EOS -! 280 -! 281 return legth_string; +! 338 +! 339 return legth_string; mov ax,-6[bp] add sp,*4 pop si @@ -1221,17 +1325,17 @@ pop di pop bp ret !BCC_EOS -! 282 # 18 "implementation/../main.h" -! 18 } -! 19 # 1 "implementation/../driver/disk.h" +! 340 # 21 +! 20 "implementation/../main.h" +! 21 } +! 22 # 1 "implementation/../driver/disk.h" ! 1 int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); ! Register BX SI used in function create_length_string !BCC_EOS ! 2 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); !BCC_EOS ! 3 -! 4 int disk_service_read_data_ -! 4 from_disk(index, number_sectors, data_buffer, data_buffer_segment) +! 4 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment) ! 5 long* index; export _disk_service_read_data_from_disk _disk_service_read_data_from_disk: @@ -1293,174 +1397,672 @@ _disk_service_read_data_from_disk.index set 2 !BCC_ENDASM ! 52 } ret -! 53 # 22 "implementation/../main.h" -! 22 void dump_ax(input); +! 53 # 25 "implementation/../main.h" +! 25 void dump_ax(input); !BCC_EOS -! 23 void print_stack(argument); +! 26 void print_stack(argument); !BCC_EOS -! 24 void print_newline(); +! 27 void print_newline(); !BCC_EOS -! 25 -! 26 typedef struct Directory_Table Directory_Table; +! 28 +! 29 typedef struct struct_partition_control partition_control; !BCC_EOS -! 27 typedef struct Struct_Table_Entry Table_Entry; +! 30 typedef struct File_System_Control_Information FSCI; !BCC_EOS -! 28 typedef struct struct_partition_control partition_control; +! 31 typedef struct meta_information_format mif; !BCC_EOS -! 29 typedef struct File_System_Control_Information FSCI; +! 32 typedef struct tag_record tag_record; !BCC_EOS -! 30 typedef struct meta_information_format mif; +! 33 typedef struct Parameter_Struct Parameter_Struct; !BCC_EOS -! 31 typedef struct tag_record tag_record; +! 34 +! 35 +! 36 typedef enum Service_Action +! 37 { +! 38 SERIVCE_LOAD_DISK = 1, +! 39 SERVICE_FIND_ENTRY = 2, +! 40 SERIVCE_READ_DATA = 3, +! 41 SERIVCE_WRITE_DATA = 4, +! 42 +! 43 } Service_Action; !BCC_EOS -! 32 typedef struct Parameter_Struct Parameter_Struct; +! 44 +! 45 struct File_System_Control_Information +! 46 { +! 47 char filesystem_information[256]; !BCC_EOS -! 33 -! 34 typedef enum Table_Entry_Kind -! 35 { -! 36 -! 37 ENTRY_EMPTY = 0, -! 38 ENTRY_FILE = 1, -! 39 ENTRY_DIRECTORY = 2, -! 40 } Table_Entry_Kind; +! 48 long master_table_index[2]; !BCC_EOS -! 41 -! 42 typedef enum Service_Action -! 43 { -! 44 SERIVCE_LOAD_DISK = 1, -! 45 SERVICE_FIND_ENTRY = 2, -! 46 SERIVCE_READ_DATA = 3, -! 47 SERIVCE_WRITE_DATA = 4, -! 48 -! 49 } Service_Action; +! 49 long this_partition_offset_on_disk[2]; !BCC_EOS -! 50 -! 51 struct Struct_Table_Entry -! 52 { -! 53 char filename[256]; +! 50 long next_free_sector[2]; +!BCC_EOS +! 51 long next_uniqe_id[2]; +!BCC_EOS +! 52 long next_secto +! 52 r_reuse_pointer[2]; !BCC_EOS -! 54 long file_id[2]; +! 53 long last_sector_index_on_partition[2]; !BCC_EOS -! 55 long file_size[2]; +! 54 long maximum_sectors_on_disk[2]; !BCC_EOS -! 56 void* ext_file_data_low; +! 55 long sector_size_on_disk[2]; !BCC_EOS -! 57 void* ext_file_data_high; +! 56 long not_used[48]; !BCC_EOS -! 58 long number_sector_s; +! 57 +! 58 }; +!BCC_EOS +! 59 +! 60 +! 61 struct Parameter_Struct +! 62 { +! 63 char* path; !BCC_EOS -! 59 short entry_kind; +! 64 char* new_path; !BCC_EOS -! 60 short extra_control_bits1; +! 65 int buffer_segment; !BCC_EOS -! 61 short extra_contro -! 61 l_bits2; +! 66 int buffer_address; !BCC_EOS -! 62 short extra_control_bits3; +! 67 int buffer_size; !BCC_EOS -! 63 long table_entry_sector_index[2]; +! 68 int data_length; !BCC_EOS -! 64 long data_pointer[27 * 2]; +! 69 int byte_offset_into_file; !BCC_EOS -! 65 }; +! 70 short entry_kind; +!BCC_EOS +! 71 }; +!BCC_EOS +! 72 # 5 "implementation/lsfs.h" +! 5 typedef struct lsfs_file lsfs_file; +!BCC_EOS +! 6 typedef struct Directory_Table Directory_Table; +!BCC_EOS +! 7 typedef struct Table_Entry Table_Entry; +!BCC_EOS +! 8 +! 9 int lsfs_disk_getattr(find_file, path); +!BCC_EOS +! 10 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry); +!BCC_EOS +! 11 Directory_Table* lsfs_find_directory(path, drop_filename); +!BCC_EOS +! 12 +! 13 typedef enum Table_Entry_Kind +! 14 { +! 15 +! 16 ENTRY_EMPTY = 0, +! 17 ENTRY_FILE = 1, +! 18 ENTRY_DIRECTORY = 2, +! 19 } Table_Entry_Kind; +!BCC_EOS +! 20 +! 21 struct Table_Entry +! 22 { +! 23 char filename[256]; +!BCC_EOS +! 24 long file_id[2]; +!BCC_EOS +! 25 long file_size[2]; +!BCC_EOS +! 26 void* ext_file_data_low; +!BCC_EOS +! 27 void* ext_file_data_high; +!BCC_EOS +! 28 long number_sector_s; +!BCC_EOS +! 29 short entry_kind; +!BCC_EOS +! 30 short extra_control_bits1; +!BCC_EOS +! 31 short extra_control_bits2; +!BCC_EOS +! 32 short extra_control_bits3; +!BCC_EOS +! 33 long table_entry_sector_index[2]; +!BCC_EOS +! 34 long data_pointer[27 * 2]; +!BCC_EOS +! 35 }; +!BCC_EOS +! 36 +! 37 struct lsfs_file { +! 38 long file_id[2]; !BCC_EOS -! 66 -! 67 struct File_System_Control_Information -! 68 { -! 69 char filesystem_information[256]; +! 39 long table_entry_pointer[2]; !BCC_EOS -! 70 long master_table_index[2]; +! 40 Table_Entry_Kind entry_kind; !BCC_EOS -! 71 long this_partition_offset_on_disk[2]; +! 41 char* filename; !BCC_EOS -! 72 long next_free_sector[2]; +! 42 long owner_id; !BCC_EOS -! 73 long next_uniqe_id[2]; +! 43 long size[2]; !BCC_EOS -! 74 long next_sector_reuse_pointer[2]; +! 44 long creation_date[2]; +!BCC_EOS +! 45 long access_time[2]; +!BCC_EOS +! 46 long modification_time[2]; +!BCC_EOS +! 47 long number_sector; +!BCC_EOS +! 48 long table_entry_sector_index[2]; +!BCC_EOS +! 49 long data_pointer[27 * 2]; +!BCC_EOS +! 50 }; +!BCC_EOS +! 51 +! 52 struct Directory_Table +! 53 { +! 54 Table_Entry entries[16 ]; +!BCC_EOS +! 55 +! 56 }; +!BCC_EOS +! 57 # 3 "implementation/lsfs.c" +! 3 extern FSCI fsci; +!BCC_EOS +! 4 +! 5 int lsfs_disk_getattr(find_file, path) +! 6 lsfs_file* find_file; +export _lsfs_disk_getattr +_lsfs_disk_getattr: +!BCC_EOS +! 7 char* path; +!BCC_EOS +! 8 { +! 9 int i; +!BCC_EOS +! 10 String_Array *split_path = string_split_c(path, '/', 0 ); +push bp +mov bp,sp +push di +push si +add sp,*-4 +! Debug: list int = const 0 (used reg = ) +xor ax,ax +push ax +! Debug: list int = const $2F (used reg = ) +mov ax,*$2F +push ax +! Debug: list * char path = [S+$E+4] (used reg = ) +push 6[bp] +! Debug: func () * struct String_Array = string_split_c+0 (used reg = ) +call _string_split_c +add sp,*6 +! Debug: eq * struct String_Array = ax+0 to * struct String_Array split_path = [S+$A-$A] (used reg = ) +mov -8[bp],ax +!BCC_EOS +! 11 Length_String *filename = split_path->strings[split_path->length-1]; +dec sp +dec sp +mov bx,-8[bp] +! Debug: sub int = const 1 to unsigned int = [bx+0] (used reg = ) +mov bx,[bx] +mov si,-8[bp] +! Debug: ptradd unsigned int = bx-1 to * * struct Length_String = [si+2] (used reg = ) +mov ax,bx +dec ax +shl ax,*1 +add ax,2[si] +mov bx,ax +! Debug: eq * struct Length_String = [bx+0] to * struct Length_String filename = [S+$C-$C] (used reg = ) +mov bx,[bx] +mov -$A[bp],bx +!BCC_EOS +! 12 +! 13 +! 14 Directory_Table *dir_table = lsfs_find_directory(path, 1 ); +dec sp +dec sp +! Debug: list int = const 1 (used reg = ) +mov ax,*1 +push ax +! Debug: list * char path = [S+$10+4] (used reg = ) +push 6[bp] +! Debug: func () * struct Directory_Table = lsfs_find_directory+0 (used reg = ) +call _lsfs_find_directory +add sp,*4 +! Debug: eq * struct Directory_Table = ax+0 to * struct Directory_Table dir_table = [S+$E-$E] (used reg = ) +mov -$C[bp],ax +!BCC_EOS +! 15 +! 16 for (i = 0; i < 16 ; ++i) +! Debug: eq int = const 0 to int i = [S+$E-8] (used reg = ) +xor ax,ax +mov -6[bp],ax !BCC_EOS -! 75 long last_sector_index_on_partition[2]; !BCC_EOS -! 76 long maximum_sectors_on_disk[2]; +! 17 { +br .2C +.2D: +! 18 if(strcmp( filename +! 18 ->chars, dir_table->entries[i].filename ) == 0) { +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = ) +! Debug: list * char = bx+0 (used reg = ) +push bx +mov bx,-$A[bp] +! Debug: list * char = [bx+4] (used reg = ) +push 4[bx] +! Debug: func () int = strcmp+0 (used reg = ) +call _strcmp +add sp,*4 +! Debug: logeq int = const 0 to int = ax+0 (used reg = ) +test ax,ax +bne .2E +.2F: +! 19 find_file->file_id[0] = dir_table->entries[i].file_id; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: ptradd int = const 0 to [2] long find_file = [S+$E+2] (used reg = bx) +mov si,4[bp] +! Debug: eq [2] long = bx+$100 to long = [si+0] (used reg = ) +mov ax,bx +add ax,#$100 +xor bx,bx +mov [si],ax +mov 2[si],bx +!BCC_EOS +! 20 find_file->entry_kind = dir_table->entries[i].entry_kind; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: eq short = [bx+$118] to int = [si+$10] (used reg = ) +mov bx,$118[bx] +mov $10[si],bx !BCC_EOS -! 77 long sector_size_on_disk[2]; +! 21 find_file->table_entry_pointer[0] = i; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+8 (used reg = ) +! Debug: eq int i = [S+$E-8] to long = [bx+8] (used reg = ) +mov ax,-6[bp] +cwd +mov si,dx +mov 8[bx],ax +mov $A[bx],si !BCC_EOS -! 78 long not_used[48]; +! 22 find_file->filename = dir_table->entries[i].filename; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: eq [$100] char = bx+0 to * char = [si+$12] (used reg = ) +mov $12[si],bx !BCC_EOS -! 79 -! 80 }; +! 23 find_file->table_entry_sector_index[0] = dir_table->entries[i].table_entry_sector_index; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: ptradd int = const 0 to [2] long = si+$3C (used reg = bx) +! Debug: eq [2] long = bx+$120 to long = [si+$3C] (used reg = ) +mov ax,bx +add ax,#$120 +xor bx,bx +mov $3C[si],ax +mov $3E[si],bx +!BCC_EOS +! 24 find_file->owner_id = 1; +mov bx,4[bp] +! Debug: eq int = const 1 to long = [bx+$14] (used reg = ) +mov ax,*1 +xor si,si +mov $14[bx],ax +mov $16[bx],si !BCC_EOS -! 81 -! 82 typedef struct Directory_Table -! 83 { -! 84 Table_Entry entries[16 ]; +! 25 find_file->size[0] = dir_table->entries[i].file_size; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: ptradd int = const 0 to [2] long = si+$18 (used reg = bx) +! Debug: eq [2] long = bx+$108 to long = [si+$18] (used reg = ) +mov ax,bx +add ax,#$108 +xor bx,bx +mov $18[si],ax +mov $1A[si],bx +!BCC_EOS +! 26 find_file->creation_date[0] = 0; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$20 (used reg = ) +! Debug: eq int = const 0 to long = [bx+$20] (used reg = ) +xor ax,ax +xor si,si +mov $20[bx],ax +mov $22[bx],si !BCC_EOS -! 85 -! 86 }; +! 27 find_file->access_time[0] = 0; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$28 (used reg = ) +! Debug: eq int = const 0 to long = [bx+$28] (used reg = ) +xor ax,ax +xor si,si +mov $28[bx],ax +mov $2A[bx],si !BCC_EOS -! 87 -! 88 struct Parameter_Struct -! 89 { -! 90 char* path; +! 28 find_file->modification_time[0] = 0; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$30 (used reg = ) +! Debug: eq int = const 0 to long = [bx+$30] (used reg = ) +xor ax,ax +xor si,si +mov $30[bx],ax +mov $32[bx],si !BCC_EOS -! 91 char* new_path; +! 29 memcpy(find_file->data_pointer, dir_table->entries[i].data_pointer, 27 * 8); +! Debug: list int = const $D8 (used reg = ) +mov ax,#$D8 +push ax +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: cast * long = const 0 to [$36] long = bx+$128 (used reg = ) +! Debug: list * long = bx+$128 (used reg = ) +add bx,#$128 +push bx +mov bx,4[bp] +! Debug: cast * long = const 0 to [$36] long = bx+$44 (used reg = ) +! Debug: list * long = bx+$44 (used reg = ) +add bx,*$44 +push bx +! Debug: func () void = memcpy+0 (used reg = ) +call _memcpy +add sp,*6 !BCC_EOS -! 92 int buffer_segment; +! 30 find_file->number_sector = 1; +mov bx,4[bp] +! Debug: eq int = const 1 to long = [bx+$38] (used reg = ) +mov ax,*1 +xor si,si +mov $38[bx],ax +mov $3A[bx],si !BCC_EOS -! 93 int buffer_address; +! 31 return 1; +mov ax,*1 +add sp,*8 +pop si +pop di +pop bp +ret !BCC_EOS -! 94 int buffer_size; +! 32 } +! 33 } +.2E: +! 34 return 0; +.2B: +! Debug: preinc int i = [S+$E-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +.2C: +! Debug: lt int = const $10 to int i = [S+$E-8] (used reg = ) +mov ax,-6[bp] +cmp ax,*$10 +blt .2D +.31: +.2A: +xor ax,ax +add sp,*8 +pop si +pop di +pop bp +ret !BCC_EOS -! 95 int data_length; +! 35 } +! 36 +! 37 Directory_Table* lsfs_find_directory(path, drop_filename) +! Register BX SI used in function lsfs_disk_getattr +! 38 char *path; +export _lsfs_find_directory +_lsfs_find_directory: !BCC_EOS -! 96 int byte_offset_into_file; +! 39 short drop_filename; !BCC_EOS -! 97 Table_Entry_Kind entry_kind; +! 40 { +! 41 int number_of_traversal; !BCC_EOS -! 98 }; +! 42 int i, j; !BCC_EOS -! 99 # 4 "implementation/lsfs.c" -! 4 struct lsfs_file { -! 5 long file_id[2]; +! 43 String_Array *split_path; !BCC_EOS -! 6 long table_entry_pointer[2]; +! 44 Directory_Table *dir_table = calloc(1, sizeof(Directory_Table)); +push bp +mov bp,sp +push di +push si +add sp,*-$A +! Debug: list int = const $2000 (used reg = ) +mov ax,#$2000 +push ax +! Debug: list int = const 1 (used reg = ) +mov ax,*1 +push ax +! Debug: func () * void = calloc+0 (used reg = ) +call _calloc +add sp,*4 +! Debug: eq * void = ax+0 to * struct Directory_Table dir_table = [S+$10-$10] (used reg = ) +mov -$E[bp],ax !BCC_EOS -! 7 Table_Entry_Kind entry_kind; +! 45 +! 46 disk_service_read_data_from_disk(fsci.master_table_index[0], 16 , dir_table, 0x7e0); +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * struct Directory_Table dir_table = [S+$12-$10] (used reg = ) +push -$E[bp] +! Debug: list int = const $10 (used reg = ) +mov ax,*$10 +push ax +! Debug: list long = [fsci+$100] (used reg = ) +push [_fsci+$102] +push [_fsci+$100] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$A !BCC_EOS -! 8 char* filename; +! 47 split_path = string_split_c(path, '/', 0 ); +! Debug: list int = const 0 (used reg = ) +xor ax,ax +push ax +! Debug: list int = const $2F (used reg = ) +mov ax,*$2F +push ax +! Debug: list * char path = [S+$14+2] (used reg = ) +push 4[bp] +! Debug: func () * struct String_Array = string_split_c+0 (used reg = ) +call _string_split_c +add sp,*6 +! Debug: eq * struct String_Array = ax+0 to * struct String_Array split_path = [S+$10-$E] (used reg = ) +mov -$C[bp],ax !BCC_EOS -! 9 long owner_id; +! 48 +! 49 number_of_traversal = split_path->length; +mov bx,-$C[bp] +! Debug: eq unsigned int = [bx+0] to int number_of_traversal = [S+$10-8] (used reg = ) +mov bx,[bx] +mov -6[bp],bx !BCC_EOS -! 10 long size[2]; +! 50 +! 51 if (drop_filename) +mov ax,6[bp] +test ax,ax +je .32 +.33: +! 52 { +! 53 number_of_traversal -= 1; +! Debug: subab int = const 1 to int number_of_traversal = [S+$10-8] (used reg = ) +mov ax,-6[bp] +dec ax +mov -6[bp],ax !BCC_EOS -! 11 long creation_date[2]; +! 54 } +! 55 +! 56 +! 57 for (i = 0; i < number_of_traversal; ++i) +.32: +! Debug: eq int = const 0 to int i = [S+$10-$A] (used reg = ) +xor ax,ax +mov -8[bp],ax !BCC_EOS -! 12 long access_time[2]; !BCC_EOS -! 13 long modification_time[2]; +! 58 { +jmp .36 +.37: +! 59 for (j = 0; j < 16 ; ++j) +! Debug: eq int = const 0 to int j = [S+$10-$C] (used reg = ) +xor ax,ax +mov -$A[bp],ax !BCC_EOS -! 14 long number_sector; !BCC_EOS -! 15 long table_entry_sector_index[2]; +! 60 { +jmp .3A +.3B: +! 61 if (strcmp(dir_table->entries[j].filename, split_path->strings[i]->chars) == 0) +mov bx,-$C[bp] +! Debug: ptradd int i = [S+$10-$A] to * * struct Length_String = [bx+2] (used reg = ) +mov ax,-8[bp] +shl ax,*1 +add ax,2[bx] +mov bx,ax +mov bx,[bx] +! Debug: list * char = [bx+4] (used reg = ) +push 4[bx] +! Debug: ptradd int j = [S+$12-$C] to [$10] struct Table_Entry dir_table = [S+$12-$10] (used reg = ) +mov ax,-$A[bp] +mov cx,#$200 +imul cx +add ax,-$E[bp] +mov bx,ax +! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = ) +! Debug: list * char = bx+0 (used reg = ) +push bx +! Debug: func () int = strcmp+0 (used reg = ) +call _strcmp +add sp,*4 +! Debug: logeq int = const 0 to int = ax+0 (used reg = ) +test ax,ax +jne .3C +.3D: +! 62 { +! 63 int index_sector = dir_table->entries[j].data_pointer[0]; +dec sp +dec sp +! Debug: ptradd int j = [S+$12-$C] to [$10] struct Table_Entry dir_table = [S+$12-$10] (used reg = ) +mov ax,-$A[bp] +mov cx,#$200 +imul cx +add ax,-$E[bp] +mov bx,ax +! Debug: ptradd int = const 0 to [$36] long = bx+$128 (used reg = ) +! Debug: eq long = [bx+$128] to int index_sector = [S+$12-$12] (used reg = ) +mov bx,$128[bx] +mov -$10[bp],bx +!BCC_EOS +! 64 +! 65 disk_service_read_data_from_disk(index_sector, 16 , dir_table); +! Debug: list * struct Directory_Table dir_table = [S+$12-$10] (used reg = ) +push -$E[bp] +! Debug: list int = const $10 (used reg = ) +mov ax,*$10 +push ax +! Debug: list int index_sector = [S+$16-$12] (used reg = ) +push -$10[bp] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*6 !BCC_EOS -! 16 long data_pointer[27 * 2]; +! 66 break; +inc sp +inc sp +jmp .38 !BCC_EOS -! 17 }; +! 67 } +inc sp +inc sp +! 68 } +.3C: +! 69 } +.39: +! Debug: preinc int j = [S+$10-$C] (used reg = ) +mov ax,-$A[bp] +inc ax +mov -$A[bp],ax +.3A: +! Debug: lt int = const $10 to int j = [S+$10-$C] (used reg = ) +mov ax,-$A[bp] +cmp ax,*$10 +jl .3B +.3E: +.38: +! 70 return dir_table; +.35: +! Debug: preinc int i = [S+$10-$A] (used reg = ) +mov ax,-8[bp] +inc ax +mov -8[bp],ax +.36: +! Debug: lt int number_of_traversal = [S+$10-8] to int i = [S+$10-$A] (used reg = ) +mov ax,-8[bp] +cmp ax,-6[bp] +jl .37 +.3F: +.34: +mov ax,-$E[bp] +add sp,*$A +pop si +pop di +pop bp +ret !BCC_EOS -! 18 -! 19 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry) -! 20 lsfs_file *file; +! 71 } +! 72 +! 73 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry, data_segment) +! Register BX used in function lsfs_find_directory +! 74 lsfs_file *file; export _lsfs_disk_read_data_from_file _lsfs_disk_read_data_from_file: !BCC_EOS -! 21 int buffer_size; +! 75 int buffer_size; !BCC_EOS -! 22 char *data; +! 76 char *data; !BCC_EOS -! 23 long offset_to_next_entry; +! 77 long offset_to_next_entry; !BCC_EOS -! 24 { -! 25 int integer_file_size = file->size; +! 78 unsigned int data_segment; +!BCC_EOS +! 79 { +! 80 int integer_file_size = file->size; push bp mov bp,sp push di @@ -1472,21 +2074,22 @@ mov bx,4[bp] add bx,*$18 mov -6[bp],bx !BCC_EOS -! 26 int integer_offset = offset_to_next_entry; +! 81 int integer_o +! 81 ffset = offset_to_next_entry; dec sp dec sp ! Debug: eq long offset_to_next_entry = [S+$A+8] to int integer_offset = [S+$A-$A] (used reg = ) mov ax,$A[bp] mov -8[bp],ax !BCC_EOS -! 27 int integer_datapointer = 0; +! 82 int integer_datapointer = 0; dec sp dec sp ! Debug: eq int = const 0 to int integer_datapointer = [S+$C-$C] (used reg = ) xor ax,ax mov -$A[bp],ax !BCC_EOS -! 28 int data_length = integer_file_size - integer_offset; +! 83 int data_length = integer_file_size - integer_offset; dec sp dec sp ! Debug: sub int integer_offset = [S+$E-$A] to int integer_file_size = [S+$E-8] (used reg = ) @@ -1495,68 +2098,68 @@ sub ax,-8[bp] ! Debug: eq int = ax+0 to int data_length = [S+$E-$E] (used reg = ) mov -$C[bp],ax !BCC_EOS -! 29 int amount_read = 0; +! 84 int amount_read = 0; dec sp dec sp ! Debug: eq int = const 0 to int amount_read = [S+$10-$10] (used reg = ) xor ax,ax mov -$E[bp],ax !BCC_EOS -! 30 int amount_to_read = 0; +! 85 int amount_to_read = 0; dec sp dec sp ! Debug: eq int = const 0 to int amount_to_read = [S+$12-$12] (used reg = ) xor ax,ax mov -$10[bp],ax !BCC_EOS -! 31 int remaining_offset = offset_to_next_entry; +! 86 int remaining_offset = offset_to_next_entry; dec sp dec sp ! Debug: eq long offset_to_next_entry = [S+$14+8] to int remaining_offset = [S+$14-$14] (used reg = ) mov ax,$A[bp] mov -$12[bp],ax !BCC_EOS -! 32 -! 33 -! 34 -! 35 -! 36 -! 37 int data_pointer_index = 0; +! 87 +! 88 +! 89 +! 90 +! 91 +! 92 int data_pointer_index = 0; dec sp dec sp ! Debug: eq int = const 0 to int data_pointer_index = [S+$16-$16] (used reg = ) xor ax,ax mov -$14[bp],ax !BCC_EOS -! 38 -! 39 if (data_length > buffer_size) +! 93 +! 94 if (data_length > buffer_size) ! Debug: gt int buffer_size = [S+$16+4] to int data_length = [S+$16-$E] (used reg = ) mov ax,-$C[bp] cmp ax,6[bp] -jle .21 -.22: -! 40 { -! 41 data_length = buffer_size; +jle .40 +.41: +! 95 { +! 96 data_length = buffer_size; ! Debug: eq int buffer_size = [S+$16+4] to int data_length = [S+$16-$E] (used reg = ) mov ax,6[bp] mov -$C[bp],ax !BCC_EOS -! 42 } -! 43 -! 44 while(data_length > 0) -.21: -! 45 { -br .24 -.25: -! 46 -! 47 if (remaining_offset == 0) +! 97 } +! 98 +! 99 while(data_length > 0) +.40: +! 100 { +br .43 +.44: +! 101 +! 102 if (remaining_offset == 0) ! Debug: logeq int = const 0 to int remaining_offset = [S+$16-$14] (used reg = ) mov ax,-$12[bp] test ax,ax -bne .26 -.27: -! 48 { -! 49 char *tmp_buffer = calloc(4 , 512 ); +bne .45 +.46: +! 103 { +! 104 char *tmp_buffer = calloc(4 , 512 ); dec sp dec sp ! Debug: list int = const $200 (used reg = ) @@ -1571,35 +2174,34 @@ add sp,*4 ! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$18-$18] (used reg = ) mov -$16[bp],ax !BCC_EOS -! 50 -! 51 -! 52 if (data_length < (4 * 512 )) +! 105 +! 106 +! 107 if (data_length < (4 * 512 )) ! Debug: lt int = const $800 to int data_length = [S+$18-$E] (used reg = ) mov ax,-$C[bp] cmp ax,#$800 -jge .28 -.29: -! 53 { -! 54 amount_to_read = data_length; +jge .47 +.48: +! 108 { +! 109 amount_to_read = data_length; ! Debug: eq int data_length = [S+$18-$E] to int amount_to_read = [S+$18-$12] (used reg = ) mov ax,-$C[bp] mov -$10[bp],ax !BCC_EOS -! 55 } -! 56 e -! 56 lse -! 57 { -jmp .2A -.28: -! 58 amount_to_read = (4 * 512 ); +! 110 } +! 111 else +! 112 { +jmp .49 +.47: +! 113 amount_to_read = (4 * 512 ); ! Debug: eq int = const $800 to int amount_to_read = [S+$18-$12] (used reg = ) mov ax,#$800 mov -$10[bp],ax !BCC_EOS -! 59 } -! 60 -! 61 integer_datapointer = file->data_pointer[data_pointer_index]; -.2A: +! 114 } +! 115 +! 116 integer_datapointer = file->data_pointer[data_pointer_index]; +.49: mov bx,4[bp] ! Debug: ptradd int data_pointer_index = [S+$18-$16] to [$36] long = bx+$44 (used reg = ) mov ax,-$14[bp] @@ -1610,28 +2212,31 @@ add bx,ax mov bx,$44[bx] mov -$A[bp],bx !BCC_EOS -! 62 if (integer_datapointer == 0) +! 117 if (integer_datapointer == 0) ! Debug: logeq int = const 0 to int integer_datapointer = [S+$18-$C] (used reg = ) mov ax,-$A[bp] test ax,ax -jne .2B -.2C: -! 63 { -! 64 break; +jne .4A +.4B: +! 118 { +! 119 break; inc sp inc sp -br .23 +br .42 !BCC_EOS -! 65 } -! 66 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer); -.2B: -! Debug: list * char tmp_buffer = [S+$18-$18] (used reg = ) +! 120 } +! 121 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer, 0x7e0); +.4A: +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char tmp_buffer = [S+$1A-$18] (used reg = ) push -$16[bp] ! Debug: list int = const 4 (used reg = ) mov ax,*4 push ax mov bx,4[bp] -! Debug: ptradd int data_pointer_index = [S+$1C-$16] to [$36] long = bx+$44 (used reg = ) +! Debug: ptradd int data_pointer_index = [S+$1E-$16] to [$36] long = bx+$44 (used reg = ) mov ax,-$14[bp] shl ax,*1 shl ax,*1 @@ -1641,54 +2246,61 @@ push $46[bx] push $44[bx] ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) call _disk_service_read_data_from_disk -add sp,*8 +add sp,*$A !BCC_EOS -! 67 memcpy((data + amount_read), tmp_buffer, amount_to_read); +! 122 memcpy((data + amount_read), data_segment, tmp_buffer, 0x7e0, amount_to_read); ! Debug: list int amount_to_read = [S+$18-$12] (used reg = ) push -$10[bp] -! Debug: list * char tmp_buffer = [S+$1A-$18] (used reg = ) +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char tmp_buffer = [S+$1C-$18] (used reg = ) push -$16[bp] -! Debug: ptradd int amount_read = [S+$1C-$10] to * char data = [S+$1C+6] (used reg = ) +! Debug: list unsigned int data_segment = [S+$1E+$C] (used reg = ) +push $E[bp] +! Debug: ptradd int amount_read = [S+$20-$10] to * char data = [S+$20+6] (used reg = ) mov ax,-$E[bp] add ax,8[bp] ! Debug: list * char = ax+0 (used reg = ) push ax ! Debug: func () void = memcpy+0 (used reg = ) call _memcpy -add sp,*6 +add sp,*$A !BCC_EOS -! 68 data_length -= amount_to_read; +! 123 data_length -= amount_to_read; ! Debug: subab int amount_to_read = [S+$18-$12] to int data_length = [S+$18-$E] (used reg = ) mov ax,-$C[bp] sub ax,-$10[bp] mov -$C[bp],ax !BCC_EOS -! 69 amount_read += amount_to_read; +! 124 amount_read += amount_to_read; ! Debug: addab int amount_to_read = [S+$18-$12] to int amount_read = [S+$18-$10] (used reg = ) mov ax,-$E[bp] add ax,-$10[bp] mov -$E[bp],ax !BCC_EOS -! 70 data_pointer_index++; -! Debug: postinc int data_pointer_index = [S+$18-$16] (used reg = ) +! 125 data_pointer_index = data_pointer_index + 2; +! Debug: add int = const 2 to int data_pointer_index = [S+$18-$16] (used reg = ) mov ax,-$14[bp] +! Debug: eq int = ax+2 to int data_pointer_index = [S+$18-$16] (used reg = ) +inc ax inc ax mov -$14[bp],ax !BCC_EOS -! 71 -! 72 } +! 126 +! 127 } inc sp inc sp -! 73 else if (remaining_offset < (4 * 512 )) -br .2D -.26: +! 128 else if (remaining_offset < (4 * 512 )) +br .4C +.45: ! Debug: lt int = const $800 to int remaining_offset = [S+$16-$14] (used reg = ) mov ax,-$12[bp] cmp ax,#$800 -bge .2E -.2F: -! 74 { -! 75 char *tmp_buffer = calloc(1, (4 * 512 )); +bge .4D +.4E: +! 129 { +! 130 char *tmp_buffer = calloc(1, (4 * 512 )); dec sp dec sp ! Debug: list int = const $800 (used reg = ) @@ -1703,45 +2315,48 @@ add sp,*4 ! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$18-$18] (used reg = ) mov -$16[bp],ax !BCC_EOS -! 76 -! 77 -! 78 if (data_length < ((4 * 512 ) - remaining_offset) ) +! 131 +! 132 +! 133 if (data_length < ((4 * 512 ) - remaining_offset) ) ! Debug: sub int remaining_offset = [S+$18-$14] to int = const $800 (used reg = ) mov ax,#$800 sub ax,-$12[bp] ! Debug: lt int = ax+0 to int data_length = [S+$18-$E] (used reg = ) cmp ax,-$C[bp] -jle .30 -.31: -! 79 { -! 80 amount_to_read = data_length; +jle .4F +.50: +! 134 { +! 135 amount_to_read = data_length; ! Debug: eq int data_length = [S+$18-$E] to int amount_to_read = [S+$18-$12] (used reg = ) mov ax,-$C[bp] mov -$10[bp],ax !BCC_EOS -! 81 } -! 82 else -! 83 { -jmp .32 -.30: -! 84 amount_to_read = ((4 * 512 ) - remaining_offset); +! 136 } +! 137 else +! 138 { +jmp .51 +.4F: +! 139 amount_to_read = ((4 * 512 ) - remaining_offset); ! Debug: sub int remaining_offset = [S+$18-$14] to int = const $800 (used reg = ) mov ax,#$800 sub ax,-$12[bp] ! Debug: eq int = ax+0 to int amount_to_read = [S+$18-$12] (used reg = ) mov -$10[bp],ax !BCC_EOS -! 85 } -! 86 -! 87 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer); -.32: -! Debug: list * char tmp_buffer = [S+$18-$18] (used reg = ) +! 140 } +! 141 +! 142 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer, 0x7e0); +.51: +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char tmp_buffer = [S+$1A-$18] (used reg = ) push -$16[bp] ! Debug: list int = const 4 (used reg = ) mov ax,*4 push ax mov bx,4[bp] -! Debug: ptradd int data_pointer_index = [S+$1C-$16] to [$36] long = bx+$44 (used reg = ) +! Debug: ptradd int data_pointer_index = [S+$1E-$16] to [$36] long = bx+$44 (used reg = ) mov ax,-$14[bp] shl ax,*1 shl ax,*1 @@ -1751,84 +2366,92 @@ push $46[bx] push $44[bx] ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) call _disk_service_read_data_from_disk -add sp,*8 +add sp,*$A !BCC_EOS -! 88 -! 89 memcpy(data, (tmp_buffer + remaining_offset), amount_to_read); +! 143 +! 144 memcpy(data, data_segment, (tmp_buffer + remaining_offset), 0x7e0, amount_to_read); ! Debug: list int amount_to_read = [S+$18-$12] (used reg = ) push -$10[bp] -! Debug: ptradd int remaining_offset = [S+$1A-$14] to * char tmp_buffer = [S+$1A-$18] (used reg = ) +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: ptradd int remaining_offset = [S+$1C-$14] to * char tmp_buffer = [S+$1C-$18] (used reg = ) mov ax,-$12[bp] add ax,-$16[bp] ! Debug: list * char = ax+0 (used reg = ) push ax -! Debug: list * char data = [S+$1C+6] (used reg = ) +! Debug: list unsigned int data_segment = [S+$1E+$C] (used reg = ) +push $E[bp] +! Debug: list * char data = [S+$20+6] (used reg = ) push 8[bp] ! Debug: func () void = memcpy+0 (used reg = ) call _memcpy -add sp,*6 +add sp,*$A !BCC_EOS -! 90 data_length -= amount_to_read; +! 145 data_length -= amount_to_read; ! Debug: subab int amount_to_read = [S+$18-$12] to int data_length = [S+$18-$E] (used reg = ) mov ax,-$C[bp] sub ax,-$10[bp] mov -$C[bp],ax !BCC_EOS -! 91 amount_read += amount_to_read; +! 146 amount_read += amount_to_read; ! Debug: addab int amount_to_read = [S+$18-$12] to int amount_read = [S+$18-$10] (used reg = ) mov ax,-$E[bp] add ax,-$10[bp] mov -$E[bp],ax !BCC_EOS -! 92 remaining_offset -= amount_to_read; +! 147 remaining_offset -= amount_to_read; ! Debug: subab int amount_to_read = [S+$18-$12] to int remaining_offset = [S+$18-$14] (used reg = ) mov ax,-$12[bp] sub ax,-$10[bp] mov -$12[bp],ax !BCC_EOS -! 93 -! 94 data_pointer_index++; -! Debug: postinc int data_pointer_index = [S+$18-$16] (used reg = ) +! 148 +! 149 data_pointer_index = data_ +! 149 pointer_index + 2; +! Debug: add int = const 2 to int data_pointer_index = [S+$18-$16] (used reg = ) mov ax,-$14[bp] +! Debug: eq int = ax+2 to int data_pointer_index = [S+$18-$16] (used reg = ) +inc ax inc ax mov -$14[bp],ax !BCC_EOS -! 95 -! 96 } +! 150 +! 151 } inc sp inc sp -! 97 else -! 98 { -jmp .33 -.2E: -! 99 -! 100 remaining_offset -= (4 * 512 ); +! 152 else +! 153 { +jmp .52 +.4D: +! 154 +! 155 remaining_offset -= (4 * 512 ); ! Debug: subab int = const $800 to int remaining_offset = [S+$16-$14] (used reg = ) mov ax,-$12[bp] add ax,#-$800 mov -$12[bp],ax !BCC_EOS -! 101 data_pointer_index++; +! 156 data_pointer_index++; ! Debug: postinc int data_pointer_index = [S+$16-$16] (used reg = ) mov ax,-$14[bp] inc ax mov -$14[bp],ax !BCC_EOS -! 102 } -! 103 -! 104 } -.33: -.2D: -! 105 # 109 -! 109 -! 110 return amount_read; -.24: +! 157 } +! 158 +! 159 } +.52: +.4C: +! 160 # 164 +! 164 +! 165 return amount_read; +.43: ! Debug: gt int = const 0 to int data_length = [S+$16-$E] (used reg = ) mov ax,-$C[bp] test ax,ax -bgt .25 -.34: -.23: +bgt .44 +.53: +.42: mov ax,-$E[bp] add sp,*$10 pop si @@ -1836,9 +2459,9 @@ pop di pop bp ret !BCC_EOS -! 111 -! 112 } -! 113 +! 166 +! 167 } +! 168 ! Register BX used in function lsfs_disk_read_data_from_file .data .bss diff --git a/lsfs.s b/lsfs.s new file mode 100644 index 0000000..06f7ad1 --- /dev/null +++ b/lsfs.s @@ -0,0 +1,2469 @@ +! 1 +! 1 # 1 "implementation/lsfs.c" +! 1 # 1 "implementation/../std_singos/stdio.h" +! 1 void print(string); +!BCC_EOS +! 2 void* dump_ax_return(input); +!BCC_EOS +! 3 +! 4 void print(string) +! 5 char* string; +export _print +_print: +!BCC_EOS +! 6 { +! 7 #asm +!BCC_ASM +_print.string set 2 + + push bp + mov bp,sp + mov si,4[bp] + call 0x0000:0x7C47 + pop bp +! 13 endasm +!BCC_ENDASM +! 14 } +ret +! 15 +! 16 void print_stack(argument) +! 17 { +export _print_stack +_print_stack: +! 18 #asm +!BCC_ASM +_print_stack.argument set 2 + + push bp + mov bp,sp + push ds + push ax + + mov ax, ss + mov ds, ax + mov si,4[bp] + call 0x0000:0x7C47 + + pop ax + pop ds + pop bp +! 32 endasm +!BCC_ENDASM +! 33 } +ret +! 34 +! 35 void* dump_ax_return(input) +! 36 void* input; +export _dump_ax_return +_dump_ax_return: +!BCC_EOS +! 37 { +! 38 return input; +push bp +mov bp,sp +push di +push si +mov ax,4[bp] +pop si +pop di +pop bp +ret +!BCC_EOS +! 39 } +! 40 +! 41 void dump_ax(input) +! 42 void* input; +export _dump_ax +_dump_ax: +!BCC_EOS +! 43 { +! 44 dump_ax_return(input) +push bp +mov bp,sp +push di +push si +! 45 #asm +! Debug: list * void input = [S+6+2] (used reg = ) +push 4[bp] +! Debug: func () * void = dump_ax_return+0 (used reg = ) +call _dump_ax_return +inc sp +inc sp +!BCC_EOS +!BCC_ASM +_dump_ax.input set 8 +.dump_ax.input set 4 + push bp + mov bp,sp + call 0x000:0x7C2A + pop bp +! 50 endasm +!BCC_ENDASM +!BCC_EOS +! 51 } +pop si +pop di +pop bp +ret +! 52 +! 53 void print_newline() +! 54 { +export _print_newline +_print_newline: +! 55 #asm +!BCC_ASM + + printCRLF: + mov ah, #0xE + mov al, #13 + int #0x10 + mov al, #10 + int #0x10 + ret +! 63 endasm +!BCC_ENDASM +! 64 } +ret +! 65 # 1 "implementation/../std_singos/stdlib.h" +! 1 unsigned int global_heap_start = 0; +.data +export _global_heap_start +_global_heap_start: +.word 0 +!BCC_EOS +! 2 unsigned int global_heap_end = 0; +export _global_heap_end +_global_heap_end: +.word 0 +!BCC_EOS +! 3 unsigned int global_heap_next = 0; +export _global_heap_next +_global_heap_next: +.word 0 +!BCC_EOS +! 4 +! 5 void* malloc(num_bytes); +!BCC_EOS +! 6 void* calloc(number_elements, size); +!BCC_EOS +! 7 int set_heap_settings(param_start, param_end); +!BCC_EOS +! 8 unsigned int get_heap_next(); +!BCC_EOS +! 9 +! 10 void* malloc(num_bytes) +! 11 int num_bytes; +.text +export _malloc +_malloc: +!BCC_EOS +! 12 { +! 13 unsigned int allocated_pointer = global_heap_next; +push bp +mov bp,sp +push di +push si +dec sp +dec sp +! Debug: eq unsigned int = [global_heap_next+0] to unsigned int allocated_pointer = [S+8-8] (used reg = ) +mov ax,[_global_heap_next] +mov -6[bp],ax +!BCC_EOS +! 14 global_heap_next = global_heap_next + num_bytes; +! Debug: add int num_bytes = [S+8+2] to unsigned int = [global_heap_next+0] (used reg = ) +mov ax,[_global_heap_next] +add ax,4[bp] +! Debug: eq unsigned int = ax+0 to unsigned int = [global_heap_next+0] (used reg = ) +mov [_global_heap_next],ax +!BCC_EOS +! 15 if (global_heap_next > global_heap_end) +! Debug: gt unsigned int = [global_heap_end+0] to unsigned int = [global_heap_next+0] (used reg = ) +mov ax,[_global_heap_next] +cmp ax,[_global_heap_end] +jbe .1 +.2: +! 16 { +! 17 return 0; +xor ax,ax +inc sp +inc sp +pop si +pop di +pop bp +ret +!BCC_EOS +! 18 } +! 19 +! 20 return allocated_pointer; +.1: +mov ax,-6[bp] +inc sp +inc sp +pop si +pop di +pop bp +ret +!BCC_EOS +! 21 } +! 22 +! 23 void* calloc(number_elements, size) +! 24 unsigned int number_elements; +export _calloc +_calloc: +!BCC_EOS +! 25 unsigned int size; +!BCC_EOS +! 26 { +! 27 int i; +!BCC_EOS +! 28 char* temp_pointer; +!BCC_EOS +! 29 unsigned int num_bytes = number_elements * size; +push bp +mov bp,sp +push di +push si +add sp,*-6 +! Debug: mul unsigned int size = [S+$C+4] to unsigned int number_elements = [S+$C+2] (used reg = ) +mov ax,4[bp] +mov cx,6[bp] +imul cx +! Debug: eq unsigned int = ax+0 to unsigned int num_bytes = [S+$C-$C] (used reg = ) +mov -$A[bp],ax +!BCC_EOS +! 30 void* allocated_pointer = global_heap_next; +dec sp +dec sp +! Debug: eq unsigned int = [global_heap_next+0] to * void allocated_pointer = [S+$E-$E] (used reg = ) +mov bx,[_global_heap_next] +mov -$C[bp],bx +!BCC_EOS +! 31 global_heap_next = global_heap_next + num_bytes; +! Debug: add unsigned int num_bytes = [S+$E-$C] to unsigned int = [global_heap_next+0] (used reg = ) +mov ax,[_global_heap_next] +add ax,-$A[bp] +! Debug: eq unsigned int = ax+0 to unsigned int = [global_heap_next+0] (used reg = ) +mov [_global_heap_next],ax +!BCC_EOS +! 32 if (global_heap_next > global_heap_end) +! Debug: gt unsigned int = [global_heap_end+0] to unsigned int = [global_heap_next+0] (used reg = ) +mov ax,[_global_heap_next] +cmp ax,[_global_heap_end] +jbe .3 +.4: +! 33 { +! 34 return 0; +xor ax,ax +add sp,*8 +pop si +pop di +pop bp +ret +!BCC_EOS +! 35 } +! 36 +! 37 +! 38 temp_pointer = allocated_pointer; +.3: +! Debug: eq * void allocated_pointer = [S+$E-$E] to * char temp_pointer = [S+$E-$A] (used reg = ) +mov bx,-$C[bp] +mov -8[bp],bx +!BCC_EOS +! 39 for (i = 0; i < num_bytes; ++i) +! Debug: eq int = const 0 to int i = [S+$E-8] (used reg = ) +xor ax,ax +mov -6[bp],ax +!BCC_EOS +!BCC_EOS +! 40 { +jmp .7 +.8: +! 41 *temp_pointer = 0; +mov bx,-8[bp] +! Debug: eq int = const 0 to char = [bx+0] (used reg = ) +xor al,al +mov [bx],al +!BCC_EOS +! 42 temp_pointer++; +! Debug: postinc * char temp_pointer = [S+$E-$A] (used reg = ) +mov bx,-8[bp] +inc bx +mov -8[bp],bx +!BCC_EOS +! 43 } +! 44 +! 45 return allocated_pointer; +.6: +! Debug: preinc int i = [S+$E-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +.7: +! Debug: lt unsigned int num_bytes = [S+$E-$C] to int i = [S+$E-8] (used reg = ) +mov ax,-6[bp] +cmp ax,-$A[bp] +jb .8 +.9: +.5: +mov ax,-$C[bp] +add sp,*8 +pop si +pop di +pop bp +ret +!BCC_EOS +! 46 } +! 47 +! 48 int set_heap_settings(param_start, param_end) +! Register BX used in function calloc +! 49 unsigned int param_start; +export _set_heap_settings +_set_heap_settings: +!BCC_EOS +! 50 unsigned int param_end; +!BCC_EOS +! 51 { +! 52 global_heap_start = param_start; +push bp +mov bp,sp +push di +push si +! Debug: eq unsigned int param_start = [S+6+2] to unsigned int = [global_heap_start+0] (used reg = ) +mov ax,4[bp] +mov [_global_heap_start],ax +!BCC_EOS +! 53 global_heap_next = param_start; +! Debug: eq unsigned int param_start = [S+6+2] to unsigned int = [global_heap_next+0] (used reg = ) +mov ax,4[bp] +mov [_global_heap_next],ax +!BCC_EOS +! 54 global_heap_end = param_end; +! Debug: eq unsigned int param_end = [S+6+4] to unsigned int = [global_heap_end+0] (used reg = ) +mov ax,6[bp] +mov [_global_heap_end],ax +!BCC_EOS +! 55 return 0; +xor ax,ax +pop si +pop di +pop bp +ret +!BCC_EOS +! 56 } +! 57 +! 58 unsigned int get_heap_next() +! 59 { +export _get_heap_next +_get_heap_next: +! 60 return global_heap_n +push bp +mov bp,sp +push di +push si +! 60 ext; +mov ax,[_global_heap_next] +pop si +pop di +pop bp +ret +!BCC_EOS +! 61 # 19 "implementation/../main.h" +! 19 } +! 20 # 2 "implementation/../std_singos/string.h" +! 2 typedef struct Length_String { +! 3 short dynamic; +!BCC_EOS +! 4 unsigned int length; +!BCC_EOS +! 5 char *chars; +!BCC_EOS +! 6 } Length_String; +!BCC_EOS +! 7 +! 8 typedef struct String_Array { +! 9 unsigned int length; +!BCC_EOS +! 10 Length_String **strings; +!BCC_EOS +! 11 } String_Array; +!BCC_EOS +! 12 +! 13 void strcpy (destination, destination_segment, source, source_segment ); +!BCC_EOS +! 14 int strlen (source, source_segment); +!BCC_EOS +! 15 void memcpy (destination, destination_segment, source, source_segment, num_bytes ); +!BCC_EOS +! 16 +! 17 +! 18 String_Array *string_split_c(string, delim, keep_delim); +!BCC_EOS +! 19 Length_String *make_length_string(length, chars); +!BCC_EOS +! 20 Length_String *make_length_string_c(cstring); +!BCC_EOS +! 21 String_Array *length_string_split(string, delim, keep_delim); +!BCC_EOS +! 22 String_Array *create_length_string_array(array_size); +!BCC_EOS +! 23 Length_String *create_length_string(length, chars); +!BCC_EOS +! 24 +! 25 +! 26 +! 27 int strlen (source, source_segment) +! 28 { +export _strlen +_strlen: +! 29 #asm +!BCC_ASM +_strlen.source set 2 +_strlen.source_segment set 4 + + +push bp + mov bp,sp + push ds + push bx + + mov ax, 6[bp]; + mov ds, ax + + mov bx, 4[bp]; + + label_strlen: + mov cx, #0x0 ; Set counte to zero + .label_strlen_loop: + mov BYTE al, [bx] + cmp al, #0x0 + je .label_strlen_done + inc cx ; Count 1 + inc bx ; Look at next char + jmp .label_strlen_loop + .label_strlen_done: + mov ax, cx + + pop bx + pop ds + pop bp +! 57 endasm +!BCC_ENDASM +! 58 } +ret +! 59 +! 60 void strcpy (destination, destination_segment, source, source_segment ) +! 61 char *destination; +export _strcpy +_strcpy: +!BCC_EOS +! 62 int destination_segment; +!BCC_EOS +! 63 char *source; +!BCC_EOS +! 64 int source_segment; +!BCC_EOS +! 65 { +! 66 #asm +!BCC_ASM +_strcpy.source set 6 +_strcpy.destination set 2 +_strcpy.source_segment set 8 +_strcpy.destination_segment set 4 + ; copy two strings + ; IN si: the first (zero terminated) string + ; IN di: the second (zero terminated) string + ; OUT SF and ZF (same semantics as cmp) + +! 72 76 + + push bp + mov bp,sp + label_strcpy: + push ax + push bx + push di + push es + push si + push ds + mov ax, 4[bp]; ; + mov di, ax + mov ax, 6[bp]; ; + mov es, ax + mov ax, 8[bp]; ; + mov si, ax + mov ax, 10[bp]; ; + mov ds, ax + mov cx, 0x050 ;TODO(Jrn) Hardcded number of bytes to copy + .label_strcpy_loop: + movsb + cmp cx, 0x0 + je .label_strcpy_end + dec cx + jmp .label_strcpy_loop + .label_strcpy_end: + pop ds + pop si + pop es + pop di + pop bx + pop ax + pop bp + +! 110 endasm +!BCC_ENDASM +! 111 } +ret +! 112 +! 113 void memcpy (destination, destination_segment, source, source_segment, num_bytes) +! 114 void *destination; +export _memcpy +_memcpy: +!BCC_EOS +! 115 int destination_segment; +!BCC_EOS +! 116 void *source; +!BCC_EOS +! 117 int source_segment; +!BCC_EOS +! 118 int num_bytes; +!BCC_EOS +! 119 { +! 120 #asm +!BCC_ASM +_memcpy.source set 6 +_memcpy.destination set 2 +_memcpy.num_bytes set $A +_memcpy.source_segment set 8 +_memcpy.destination_segment set 4 + ; copy two strings + ; IN si: the first (zero terminated) string + ; IN di: the second (zero terminated) string + ; OUT SF and ZF (same semantics as cmp) + +! 126 131 + + push bp + mov bp,sp + label_memcpy: + push ax + push bx + push di + push es + push si + push ds + mov ax, 4[bp]; ; + mov di, ax + mov ax, 6[bp]; ; + mov es, ax + mov ax, 8[bp]; ; + mov si, ax + mov ax, 10[bp]; ; + mov ds, ax + mov cx, 12[bp]; + .label_memcpy_loop: + movsb + cmp cx, 0x0 + je .label_memcpy_end + dec cx + jmp .label_memcpy_loop + .label_memcpy_end: + pop ds + pop si + pop es + pop di + pop bx + pop ax + pop bp + +! 165 endasm +!BCC_ENDASM +! 166 } +ret +! 167 +! 168 int strcmp(source_1, source_2) +! 169 char* source_1; +export _strcmp +_strcmp: +!BCC_EOS +! 170 char* source_2; +!BCC_EOS +! 171 { +! 172 int i; +!BCC_EOS +! 173 int count; +!BCC_EOS +! 174 +! 175 count = strlen(source_1); +push bp +mov bp,sp +push di +push si +add sp,*-4 +! Debug: list * char source_1 = [S+$A+2] (used reg = ) +push 4[bp] +! Debug: func () int = strlen+0 (used reg = ) +call _strlen +inc sp +inc sp +! Debug: eq int = ax+0 to int count = [S+$A-$A] (used reg = ) +mov -8[bp],ax +!BCC_EOS +! 176 if (count != strlen(source_2)) +! Debug: list * char source_2 = [S+$A+4] (used reg = ) +push 6[bp] +! Debug: func () int = strlen+0 (used reg = ) +call _strlen +inc sp +inc sp +! Debug: ne int = ax+0 to int count = [S+$A-$A] (used reg = ) +! Debug: expression subtree swapping +cmp ax,-8[bp] +je .A +.B: +! 177 { +! 178 +! 179 } +! 180 +! 181 +! 182 for (i = 0; i < count; ++i) +.A: +! Debug: eq int = const 0 to int i = [S+$A-8] (used reg = ) +xor ax,ax +mov -6[bp],ax +!BCC_EOS +!BCC_EOS +! 183 { +jmp .E +.F: +! 184 if(source_1[i] != source_2[i]) +! Debug: ptradd int i = [S+$A-8] to * char source_2 = [S+$A+4] (used reg = ) +mov ax,-6[bp] +add ax,6[bp] +mov bx,ax +! Debug: ptradd int i = [S+$A-8] to * char source_1 = [S+$A+2] (used reg = bx) +mov ax,-6[bp] +add ax,4[bp] +mov si,ax +! Debug: ne char = [bx+0] to char = [si+0] (used reg = ) +mov al,[si] +cmp al,[bx] +je .10 +.11: +! 185 { +! 186 return -1; +mov ax,*-1 +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 187 } +! 188 } +.10: +! 189 +! 190 return 0; +.D: +! Debug: preinc int i = [S+$A-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +.E: +! Debug: lt int count = [S+$A-$A] to int i = [S+$A-8] (used reg = ) +mov ax,-6[bp] +cmp ax,-8[bp] +jl .F +.12: +.C: +xor ax,ax +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 191 # 223 +! 223 +! 224 } +! 225 +! 226 String_Array *string_split_c(string, delim, keep_delim) +! Register BX SI used in function strcmp +! 227 char *string; +export _string_split_c +_string_split_c: +!BCC_EOS +! 228 char delim; +!BCC_EOS +! 229 short keep_delim; +!BCC_EOS +! 230 { +! 231 return length_string_split(make_length_string_c(string), delim, keep_delim); +push bp +mov bp,sp +push di +push si +! Debug: list short keep_delim = [S+6+6] (used reg = ) +push 8[bp] +! Debug: list char delim = [S+8+4] (used reg = ) +mov al,6[bp] +xor ah,ah +push ax +! Debug: list * char string = [S+$A+2] (used reg = ) +push 4[bp] +! Debug: func () * struct Length_String = make_length_string_c+0 (used reg = ) +call _make_length_string_c +inc sp +inc sp +! Debug: list * struct Length_String = ax+0 (used reg = ) +push ax +! Debug: func () * struct String_Array = length_string_split+0 (used reg = ) +call _length_string_split +add sp,*6 +! Debug: cast * struct String_Array = const 0 to * struct String_Array = ax+0 (used reg = ) +pop si +pop di +pop bp +ret +!BCC_EOS +! 232 } +! 233 +! 234 Length_String *make_length_string_c(cstring) +! 235 char *cstring; +export _make_length_string_c +_make_length_string_c: +!BCC_EOS +! 236 { +! 237 return make_length_string(strlen(cstring, 0x7e0), cstring); +push bp +mov bp,sp +push di +push si +! Debug: list * char cstring = [S+6+2] (used reg = ) +push 4[bp] +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char cstring = [S+$A+2] (used reg = ) +push 4[bp] +! Debug: func () int = strlen+0 (used reg = ) +call _strlen +add sp,*4 +! Debug: list int = ax+0 (used reg = ) +push ax +! Debug: func () * struct Length_String = make_length_string+0 (used reg = ) +call _make_length_string +add sp,*4 +! Debug: cast * struct Length_String = const 0 to * struct Length_String = ax+0 (used reg = ) +pop si +pop di +pop bp +ret +!BCC_EOS +! 238 } +! 239 +! 240 Length_String *make_length_string(length, chars) +! 241 unsigned int length; +export _make_length_string +_make_length_string: +!BCC_EOS +! 242 char *chars; +!BCC_EOS +! 243 { +! 244 +! 245 Length_String *legth_string = malloc +! 245 (sizeof(Length_String)); +push bp +mov bp,sp +push di +push si +dec sp +dec sp +! Debug: list int = const 6 (used reg = ) +mov ax,*6 +push ax +! Debug: func () * void = malloc+0 (used reg = ) +call _malloc +inc sp +inc sp +! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = ) +mov -6[bp],ax +!BCC_EOS +! 246 char *copy = malloc(length + 1); +dec sp +dec sp +! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = ) +mov ax,4[bp] +! Debug: list unsigned int = ax+1 (used reg = ) +inc ax +push ax +! Debug: func () * void = malloc+0 (used reg = ) +call _malloc +inc sp +inc sp +! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = ) +mov -8[bp],ax +!BCC_EOS +! 247 memcpy(copy, 0x7e0, chars, 0x7e0, length); +! Debug: list unsigned int length = [S+$A+2] (used reg = ) +push 4[bp] +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char chars = [S+$E+4] (used reg = ) +push 6[bp] +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char copy = [S+$12-$A] (used reg = ) +push -8[bp] +! Debug: func () void = memcpy+0 (used reg = ) +call _memcpy +add sp,*$A +!BCC_EOS +! 248 copy[length] = '\0'; +! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = ) +mov ax,4[bp] +add ax,-8[bp] +mov bx,ax +! Debug: eq int = const 0 to char = [bx+0] (used reg = ) +xor al,al +mov [bx],al +!BCC_EOS +! 249 +! 250 legth_string->dynamic = 0; +mov bx,-6[bp] +! Debug: eq int = const 0 to short = [bx+0] (used reg = ) +xor ax,ax +mov [bx],ax +!BCC_EOS +! 251 legth_string->length = length; +mov bx,-6[bp] +! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = ) +mov ax,4[bp] +mov 2[bx],ax +!BCC_EOS +! 252 legth_string->chars = (char *)chars; +mov bx,-6[bp] +! Debug: eq * char chars = [S+$A+4] to * char = [bx+4] (used reg = ) +mov si,6[bp] +mov 4[bx],si +!BCC_EOS +! 253 +! 254 return legth_string; +mov ax,-6[bp] +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 255 } +! 256 +! 257 String_Array *length_string_split(string, delim, keep_delim) +! Register BX SI used in function make_length_string +! 258 Length_String *string; +export _length_string_split +_length_string_split: +!BCC_EOS +! 259 char delim; +!BCC_EOS +! 260 short keep_delim; +!BCC_EOS +! 261 { +! 262 unsigned int i; +!BCC_EOS +! 263 unsigned int last; +!BCC_EOS +! 264 +! 265 unsigned int count = 0; +push bp +mov bp,sp +push di +push si +add sp,*-6 +! Debug: eq int = const 0 to unsigned int count = [S+$C-$C] (used reg = ) +xor ax,ax +mov -$A[bp],ax +!BCC_EOS +! 266 unsigned int insert_index = 0; +dec sp +dec sp +! Debug: eq int = const 0 to unsigned int insert_index = [S+$E-$E] (used reg = ) +xor ax,ax +mov -$C[bp],ax +!BCC_EOS +! 267 String_Array *result; +!BCC_EOS +! 268 int k; +!BCC_EOS +! 269 +! 270 i = 0; +add sp,*-4 +! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = ) +xor ax,ax +mov -6[bp],ax +!BCC_EOS +! 271 last = 0; +! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = ) +xor ax,ax +mov -8[bp],ax +!BCC_EOS +! 272 while(i < string->length) { +jmp .14 +.15: +! 273 if (string->chars[i] == delim) { +mov bx,4[bp] +! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = ) +mov ax,-6[bp] +add ax,4[bx] +mov bx,ax +! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = ) +mov al,[bx] +cmp al,6[bp] +jne .16 +.17: +! 274 if (i > last+1) { +! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) +mov ax,-8[bp] +! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) +inc ax +cmp ax,-6[bp] +jae .18 +.19: +! 275 ++count; +! Debug: preinc unsigned int count = [S+$12-$C] (used reg = ) +mov ax,-$A[bp] +inc ax +mov -$A[bp],ax +!BCC_EOS +! 276 } +! 277 last = i; +.18: +! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = ) +mov ax,-6[bp] +mov -8[bp],ax +!BCC_EOS +! 278 } +! 279 ++i; +.16: +! Debug: preinc unsigned int i = [S+$12-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +!BCC_EOS +! 280 } +! 281 if (i > last+1) { +.14: +mov bx,4[bp] +! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = ) +mov ax,-6[bp] +cmp ax,2[bx] +jb .15 +.1A: +.13: +! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) +mov ax,-8[bp] +! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) +inc ax +cmp ax,-6[bp] +jae .1B +.1C: +! 282 ++count; +! Debug: preinc unsigned int count = [S+$12-$C] (used reg = ) +mov ax,-$A[bp] +inc ax +mov -$A[bp],ax +!BCC_EOS +! 283 } +! 284 +! 285 result = create_length_string_array(count); +.1B: +! Debug: list unsigned int count = [S+$12-$C] (used reg = ) +push -$A[bp] +! Debug: func () * struct String_Array = create_length_string_array+0 (used reg = ) +call _create_length_string_array +inc sp +inc sp +! Debug: eq * struct String_Array = ax+0 to * struct String_Array result = [S+$12-$10] (used reg = ) +mov -$E[bp],ax +!BCC_EOS +! 286 +! 287 if (keep_delim) +mov ax,8[bp] +test ax,ax +je .1D +.1E: +! 288 { +! 289 k = 0; +! Debug: eq int = const 0 to int k = [S+$12-$12] (used reg = ) +xor ax,ax +mov -$10[bp],ax +!BCC_EOS +! 290 } +! 291 else +! 292 { +jmp .1F +.1D: +! 293 k = 1; +! Debug: eq int = const 1 to int k = [S+$12-$12] (used reg = ) +mov ax,*1 +mov -$10[bp],ax +!BCC_EOS +! 294 } +! 295 +! 296 i = 0; +.1F: +! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = ) +xor ax,ax +mov -6[bp],ax +!BCC_EOS +! 297 last = 0; +! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = ) +xor ax,ax +mov -8[bp],ax +!BCC_EOS +! 298 while(i < string->length) { +jmp .21 +.22: +! 299 if (string->chars[i] == delim) { +mov bx,4[bp] +! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = ) +mov ax,-6[bp] +add ax,4[bx] +mov bx,ax +! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = ) +mov al,[bx] +cmp al,6[bp] +jne .23 +.24: +! 300 if (i > last+1) { +! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) +mov ax,-8[bp] +! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) +inc ax +cmp ax,-6[bp] +jae .25 +.26: +! 301 result->strings[insert_index++] = create_length_string(i-(last+k), string->chars+(last+k)); +! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = ) +mov ax,-8[bp] +add ax,-$10[bp] +mov bx,4[bp] +! Debug: ptradd unsigned int = ax+0 to * char = [bx+4] (used reg = ) +add ax,4[bx] +! Debug: list * char = ax+0 (used reg = ) +push ax +! Debug: add int k = [S+$14-$12] to unsigned int last = [S+$14-$A] (used reg = ) +mov ax,-8[bp] +add ax,-$10[bp] +! Debug: sub unsigned int = ax+0 to unsigned int i = [S+$14-8] (used reg = ) +push ax +mov ax,-6[bp] +sub ax,-$14[bp] +inc sp +inc sp +! Debug: list unsigned int = ax+0 (used reg = ) +push ax +! Debug: func () * struct Length_String = create_length_string+0 (used reg = ) +call _create_length_string +add sp,*4 +push ax +! Debug: postinc unsigned int insert_index = [S+$14-$E] (used reg = ) +mov ax,-$C[bp] +inc ax +mov -$C[bp],ax +mov bx,-$E[bp] +! Debug: ptradd unsigned int = ax-1 to * * struct Length_String = [bx+2] (used reg = ) +dec ax +shl ax,*1 +add ax,2[bx] +mov bx,ax +! Debug: eq * struct Length_String (temp) = [S+$14-$14] to * struct Length_String = [bx+0] (used reg = ) +mov si,-$12[bp] +mov [bx],si +inc sp +inc sp +!BCC_EOS +! 302 } +! 303 last = i; +.25: +! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = ) +mov ax,-6[bp] +mov -8[bp],ax +!BCC_EOS +! 304 } +! 305 ++i; +.23: +! Debug: preinc unsigned int i = [S+$12-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +!BCC_EOS +! 306 } +! 307 if (i > last+1) { +.21: +mov bx,4[bp] +! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = ) +mov ax,-6[bp] +cmp ax,2[bx] +jb .22 +.27: +.20: +! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) +mov ax,-8[bp] +! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) +inc ax +cmp ax,-6[bp] +jae .28 +.29: +! 308 result->strings[insert_index++] = create_length_string(i-(last+k), ((string->chars)+(last+k))); +! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = ) +mov ax,-8[bp] +add ax,-$10[bp] +mov bx,4[bp] +! Debug: ptradd unsigned int = ax+0 to * char = [bx+4] (used reg = ) +add ax,4[bx] +! Debug: list * char = ax+0 (used reg = ) +push ax +! Debug: add int k = [S+$14-$12] to unsigned int last = [S+$14-$A] (used reg = ) +mov ax,-8[bp] +add ax,-$10[bp] +! Debug: sub unsigned int = ax+0 to unsigned int i = [S+$14-8] (used reg = ) +push ax +mov ax,-6[bp] +sub ax,-$14[bp] +inc sp +inc sp +! Debug: list unsigned int = ax+0 (used reg = ) +push ax +! Debug: func () * struct Length_String = create_length_string+0 (used reg = ) +call _create_length_string +add sp,*4 +push ax +! Debug: postinc unsigned int insert_index = [S+$14-$E] (used reg = ) +mov ax,-$C[bp] +inc ax +mov -$C[bp],ax +mov bx,-$E[bp] +! Debug: ptradd unsigned int = ax-1 to * * struct Length_String = [bx+2] (used reg = ) +dec ax +shl ax,*1 +add ax,2[bx] +mov bx,ax +! Debug: eq * struct Length_String (temp) = [S+$14-$14] to * struct Length_String = [bx+0] (used reg = ) +mov si,-$12[bp] +mov [bx],si +inc sp +inc sp +!BCC_EOS +! 309 } +! 310 +! 311 return result; +.28: +mov ax,-$E[bp] +add sp,*$C +pop si +pop di +pop bp +ret +!BCC_EOS +! 312 +! 313 } +! 314 +! 315 String_Array *create_length_string_array(array_size) +! Register BX SI used in function length_string_split +! 316 int array_size; +export _create_length_string_array +_create_length_string_array: +!BCC_EOS +! 317 { +! 318 String_Array *result = malloc(sizeof(String_Array)); +push bp +mov bp,sp +push di +push si +dec sp +dec sp +! Debug: list int = const 4 (used reg = ) +mov ax,*4 +push ax +! Debug: func () * void = malloc+0 (used reg = ) +call _malloc +inc sp +inc sp +! Debug: eq * void = ax+0 to * struct String_Array result = [S+8-8] (used reg = ) +mov -6[bp],ax +!BCC_EOS +! 319 result->length = array_size; +mov bx,-6[bp] +! Debug: eq int array_size = [S+8+2] to unsigned int = [bx+0] (used reg = ) +mov ax,4[bp] +mov [bx],ax +!BCC_EOS +! 320 result->strings = malloc(array_size * sizeof(Length_String)); +! Debug: mul int = const 6 to int array_size = [S+8+2] (used reg = ) +mov ax,4[bp] +mov dx,ax +shl ax,*1 +add ax,dx +shl ax,*1 +! Debug: list int = ax+0 (used reg = ) +push ax +! Debug: func () * void = malloc+0 (used reg = ) +call _malloc +inc sp +inc sp +mov bx,-6[bp] +! Debug: eq * void = ax+0 to * * struct Length_String = [bx+2] (used reg = ) +mov 2[bx],ax +!BCC_EOS +! 321 return result; +mov ax,-6[bp] +inc sp +inc sp +pop si +pop di +pop bp +ret +!BCC_EOS +! 322 } +! 323 +! 324 +! 325 Length_String *create_length_string(length, chars) +! Register BX used in function create_length_string_array +! 326 unsigned int length; +export _create_length_string +_create_length_string: +!BCC_EOS +! 327 char *chars; +!BCC_EOS +! 328 { +! 329 +! 330 Length_String *legth_string = malloc(sizeof(Length_String)); +push bp +mov bp,sp +push di +push si +dec sp +dec sp +! Debug: list int = const 6 (used reg = ) +mov ax,*6 +push ax +! Debug: func () * void = malloc+0 (used reg = ) +call _malloc +inc sp +inc sp +! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = ) +mov -6[bp],ax +!BCC_EOS +! 331 char *copy = malloc(length + 1); +dec sp +dec sp +! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = ) +mov ax,4[bp] +! Debug: list unsigned int = ax+1 (used reg = ) +inc ax +push ax +! Debug: func () * void = malloc+0 (used reg = ) +call _malloc +inc sp +inc sp +! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = ) +mov -8[bp],ax +!BCC_EOS +! 332 memcpy(copy, 0x7e0, chars, 0x7e0, length); +! Debug: list unsigned int length = [S+$A+2] (used reg = ) +push 4[bp] +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char chars = [S+$E+4] (used reg = ) +push 6[bp] +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char copy = [S+$12-$A] (used reg = ) +push -8[bp] +! Debug: func () void = memcpy+0 (used reg = ) +call _memcpy +add sp,*$A +!BCC_EOS +! 333 copy[length] = '\0'; +! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = ) +mov ax,4[bp] +add ax,-8[bp] +mov bx,ax +! Debug: eq int = const 0 to char = [bx+0] (used reg = ) +xor al,al +mov [bx],al +!BCC_EOS +! 334 +! 335 legth_string->dynamic = 1; +mov bx,-6[bp] +! Debug: eq int = const 1 to short = [bx+0] (used reg = ) +mov ax,*1 +mov [bx],ax +!BCC_EOS +! 336 legth_string->length = length; +mov bx,-6[bp] +! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = ) +mov ax,4[bp] +mov 2[bx],ax +!BCC_EOS +! 337 legth_string->chars = copy; +mov bx,-6[bp] +! Debug: eq * char copy = [S+$A-$A] to * char = [bx+4] (used reg = ) +mov si,-8[bp] +mov 4[bx],si +!BCC_EOS +! 338 +! 339 return legth_string; +mov ax,-6[bp] +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 340 # 21 +! 20 "implementation/../main.h" +! 21 } +! 22 # 1 "implementation/../driver/disk.h" +! 1 int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); +! Register BX SI used in function create_length_string +!BCC_EOS +! 2 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); +!BCC_EOS +! 3 +! 4 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment) +! 5 long* index; +export _disk_service_read_data_from_disk +_disk_service_read_data_from_disk: +!BCC_EOS +! 6 long number_sectors; +!BCC_EOS +! 7 void* data_buffer; +!BCC_EOS +! 8 int data_buffer_segment; +!BCC_EOS +! 9 { +! 10 +! 11 #asm +!BCC_ASM +_disk_service_read_data_from_disk.data_buffer set 8 +_disk_service_read_data_from_disk.number_sectors set 4 +_disk_service_read_data_from_disk.data_buffer_segment set $A +_disk_service_read_data_from_disk.index set 2 + +! 13 define number_sectors 8[bp]; + + + + push bp + mov bp,sp + pusha + + lsfs_load_data: + mov ax, 4[bp]; + mov WORD [DAPACK.lba_addr_dw_low], ax + mov bx, 8[bp]; + mov WORD [DAPACK.blkcnt], bx + mov cx, 12[bp]; + mov WORD [DAPACK.db_addr_segment], cx + mov dx, 10[bp]; ; + mov WORD [DAPACK.db_addr_offset], dx + mov si, #DAPACK ; address of + mov ah, #0x42 ; READ + mov dl, [global_disk_identifier] + int #0x13 + ;call 0x0000:0x7C2A + popa + pop bp + ret + + + DAPACK: + DAPACK.dap_Size: db 0x10 + DAPACK.rev_byte: db 0x0 + DAPACK.blkcnt: dw 0x0 + DAPACK.db_addr_offset: dw 0x0 + DAPACK.db_addr_segment: dw 0x0 + DAPACK.lba_addr_dw_low: dd 0x0 + DAPACK.lba_addr_dw_high: dd 0x0 + + global_disk_identifier: db 0x80 + +! 51 endasm +!BCC_ENDASM +! 52 } +ret +! 53 # 25 "implementation/../main.h" +! 25 void dump_ax(input); +!BCC_EOS +! 26 void print_stack(argument); +!BCC_EOS +! 27 void print_newline(); +!BCC_EOS +! 28 +! 29 typedef struct struct_partition_control partition_control; +!BCC_EOS +! 30 typedef struct File_System_Control_Information FSCI; +!BCC_EOS +! 31 typedef struct meta_information_format mif; +!BCC_EOS +! 32 typedef struct tag_record tag_record; +!BCC_EOS +! 33 typedef struct Parameter_Struct Parameter_Struct; +!BCC_EOS +! 34 +! 35 +! 36 typedef enum Service_Action +! 37 { +! 38 SERIVCE_LOAD_DISK = 1, +! 39 SERVICE_FIND_ENTRY = 2, +! 40 SERIVCE_READ_DATA = 3, +! 41 SERIVCE_WRITE_DATA = 4, +! 42 +! 43 } Service_Action; +!BCC_EOS +! 44 +! 45 struct File_System_Control_Information +! 46 { +! 47 char filesystem_information[256]; +!BCC_EOS +! 48 long master_table_index[2]; +!BCC_EOS +! 49 long this_partition_offset_on_disk[2]; +!BCC_EOS +! 50 long next_free_sector[2]; +!BCC_EOS +! 51 long next_uniqe_id[2]; +!BCC_EOS +! 52 long next_secto +! 52 r_reuse_pointer[2]; +!BCC_EOS +! 53 long last_sector_index_on_partition[2]; +!BCC_EOS +! 54 long maximum_sectors_on_disk[2]; +!BCC_EOS +! 55 long sector_size_on_disk[2]; +!BCC_EOS +! 56 long not_used[48]; +!BCC_EOS +! 57 +! 58 }; +!BCC_EOS +! 59 +! 60 +! 61 struct Parameter_Struct +! 62 { +! 63 char* path; +!BCC_EOS +! 64 char* new_path; +!BCC_EOS +! 65 int buffer_segment; +!BCC_EOS +! 66 int buffer_address; +!BCC_EOS +! 67 int buffer_size; +!BCC_EOS +! 68 int data_length; +!BCC_EOS +! 69 int byte_offset_into_file; +!BCC_EOS +! 70 short entry_kind; +!BCC_EOS +! 71 }; +!BCC_EOS +! 72 # 5 "implementation/lsfs.h" +! 5 typedef struct lsfs_file lsfs_file; +!BCC_EOS +! 6 typedef struct Directory_Table Directory_Table; +!BCC_EOS +! 7 typedef struct Table_Entry Table_Entry; +!BCC_EOS +! 8 +! 9 int lsfs_disk_getattr(find_file, path); +!BCC_EOS +! 10 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry); +!BCC_EOS +! 11 Directory_Table* lsfs_find_directory(path, drop_filename); +!BCC_EOS +! 12 +! 13 typedef enum Table_Entry_Kind +! 14 { +! 15 +! 16 ENTRY_EMPTY = 0, +! 17 ENTRY_FILE = 1, +! 18 ENTRY_DIRECTORY = 2, +! 19 } Table_Entry_Kind; +!BCC_EOS +! 20 +! 21 struct Table_Entry +! 22 { +! 23 char filename[256]; +!BCC_EOS +! 24 long file_id[2]; +!BCC_EOS +! 25 long file_size[2]; +!BCC_EOS +! 26 void* ext_file_data_low; +!BCC_EOS +! 27 void* ext_file_data_high; +!BCC_EOS +! 28 long number_sector_s; +!BCC_EOS +! 29 short entry_kind; +!BCC_EOS +! 30 short extra_control_bits1; +!BCC_EOS +! 31 short extra_control_bits2; +!BCC_EOS +! 32 short extra_control_bits3; +!BCC_EOS +! 33 long table_entry_sector_index[2]; +!BCC_EOS +! 34 long data_pointer[27 * 2]; +!BCC_EOS +! 35 }; +!BCC_EOS +! 36 +! 37 struct lsfs_file { +! 38 long file_id[2]; +!BCC_EOS +! 39 long table_entry_pointer[2]; +!BCC_EOS +! 40 Table_Entry_Kind entry_kind; +!BCC_EOS +! 41 char* filename; +!BCC_EOS +! 42 long owner_id; +!BCC_EOS +! 43 long size[2]; +!BCC_EOS +! 44 long creation_date[2]; +!BCC_EOS +! 45 long access_time[2]; +!BCC_EOS +! 46 long modification_time[2]; +!BCC_EOS +! 47 long number_sector; +!BCC_EOS +! 48 long table_entry_sector_index[2]; +!BCC_EOS +! 49 long data_pointer[27 * 2]; +!BCC_EOS +! 50 }; +!BCC_EOS +! 51 +! 52 struct Directory_Table +! 53 { +! 54 Table_Entry entries[16 ]; +!BCC_EOS +! 55 +! 56 }; +!BCC_EOS +! 57 # 3 "implementation/lsfs.c" +! 3 extern FSCI fsci; +!BCC_EOS +! 4 +! 5 int lsfs_disk_getattr(find_file, path) +! 6 lsfs_file* find_file; +export _lsfs_disk_getattr +_lsfs_disk_getattr: +!BCC_EOS +! 7 char* path; +!BCC_EOS +! 8 { +! 9 int i; +!BCC_EOS +! 10 String_Array *split_path = string_split_c(path, '/', 0 ); +push bp +mov bp,sp +push di +push si +add sp,*-4 +! Debug: list int = const 0 (used reg = ) +xor ax,ax +push ax +! Debug: list int = const $2F (used reg = ) +mov ax,*$2F +push ax +! Debug: list * char path = [S+$E+4] (used reg = ) +push 6[bp] +! Debug: func () * struct String_Array = string_split_c+0 (used reg = ) +call _string_split_c +add sp,*6 +! Debug: eq * struct String_Array = ax+0 to * struct String_Array split_path = [S+$A-$A] (used reg = ) +mov -8[bp],ax +!BCC_EOS +! 11 Length_String *filename = split_path->strings[split_path->length-1]; +dec sp +dec sp +mov bx,-8[bp] +! Debug: sub int = const 1 to unsigned int = [bx+0] (used reg = ) +mov bx,[bx] +mov si,-8[bp] +! Debug: ptradd unsigned int = bx-1 to * * struct Length_String = [si+2] (used reg = ) +mov ax,bx +dec ax +shl ax,*1 +add ax,2[si] +mov bx,ax +! Debug: eq * struct Length_String = [bx+0] to * struct Length_String filename = [S+$C-$C] (used reg = ) +mov bx,[bx] +mov -$A[bp],bx +!BCC_EOS +! 12 +! 13 +! 14 Directory_Table *dir_table = lsfs_find_directory(path, 1 ); +dec sp +dec sp +! Debug: list int = const 1 (used reg = ) +mov ax,*1 +push ax +! Debug: list * char path = [S+$10+4] (used reg = ) +push 6[bp] +! Debug: func () * struct Directory_Table = lsfs_find_directory+0 (used reg = ) +call _lsfs_find_directory +add sp,*4 +! Debug: eq * struct Directory_Table = ax+0 to * struct Directory_Table dir_table = [S+$E-$E] (used reg = ) +mov -$C[bp],ax +!BCC_EOS +! 15 +! 16 for (i = 0; i < 16 ; ++i) +! Debug: eq int = const 0 to int i = [S+$E-8] (used reg = ) +xor ax,ax +mov -6[bp],ax +!BCC_EOS +!BCC_EOS +! 17 { +br .2C +.2D: +! 18 if(strcmp( filename +! 18 ->chars, dir_table->entries[i].filename ) == 0) { +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = ) +! Debug: list * char = bx+0 (used reg = ) +push bx +mov bx,-$A[bp] +! Debug: list * char = [bx+4] (used reg = ) +push 4[bx] +! Debug: func () int = strcmp+0 (used reg = ) +call _strcmp +add sp,*4 +! Debug: logeq int = const 0 to int = ax+0 (used reg = ) +test ax,ax +bne .2E +.2F: +! 19 find_file->file_id[0] = dir_table->entries[i].file_id; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: ptradd int = const 0 to [2] long find_file = [S+$E+2] (used reg = bx) +mov si,4[bp] +! Debug: eq [2] long = bx+$100 to long = [si+0] (used reg = ) +mov ax,bx +add ax,#$100 +xor bx,bx +mov [si],ax +mov 2[si],bx +!BCC_EOS +! 20 find_file->entry_kind = dir_table->entries[i].entry_kind; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: eq short = [bx+$118] to int = [si+$10] (used reg = ) +mov bx,$118[bx] +mov $10[si],bx +!BCC_EOS +! 21 find_file->table_entry_pointer[0] = i; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+8 (used reg = ) +! Debug: eq int i = [S+$E-8] to long = [bx+8] (used reg = ) +mov ax,-6[bp] +cwd +mov si,dx +mov 8[bx],ax +mov $A[bx],si +!BCC_EOS +! 22 find_file->filename = dir_table->entries[i].filename; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: eq [$100] char = bx+0 to * char = [si+$12] (used reg = ) +mov $12[si],bx +!BCC_EOS +! 23 find_file->table_entry_sector_index[0] = dir_table->entries[i].table_entry_sector_index; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: ptradd int = const 0 to [2] long = si+$3C (used reg = bx) +! Debug: eq [2] long = bx+$120 to long = [si+$3C] (used reg = ) +mov ax,bx +add ax,#$120 +xor bx,bx +mov $3C[si],ax +mov $3E[si],bx +!BCC_EOS +! 24 find_file->owner_id = 1; +mov bx,4[bp] +! Debug: eq int = const 1 to long = [bx+$14] (used reg = ) +mov ax,*1 +xor si,si +mov $14[bx],ax +mov $16[bx],si +!BCC_EOS +! 25 find_file->size[0] = dir_table->entries[i].file_size; +! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: ptradd int = const 0 to [2] long = si+$18 (used reg = bx) +! Debug: eq [2] long = bx+$108 to long = [si+$18] (used reg = ) +mov ax,bx +add ax,#$108 +xor bx,bx +mov $18[si],ax +mov $1A[si],bx +!BCC_EOS +! 26 find_file->creation_date[0] = 0; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$20 (used reg = ) +! Debug: eq int = const 0 to long = [bx+$20] (used reg = ) +xor ax,ax +xor si,si +mov $20[bx],ax +mov $22[bx],si +!BCC_EOS +! 27 find_file->access_time[0] = 0; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$28 (used reg = ) +! Debug: eq int = const 0 to long = [bx+$28] (used reg = ) +xor ax,ax +xor si,si +mov $28[bx],ax +mov $2A[bx],si +!BCC_EOS +! 28 find_file->modification_time[0] = 0; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$30 (used reg = ) +! Debug: eq int = const 0 to long = [bx+$30] (used reg = ) +xor ax,ax +xor si,si +mov $30[bx],ax +mov $32[bx],si +!BCC_EOS +! 29 memcpy(find_file->data_pointer, dir_table->entries[i].data_pointer, 27 * 8); +! Debug: list int = const $D8 (used reg = ) +mov ax,#$D8 +push ax +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: cast * long = const 0 to [$36] long = bx+$128 (used reg = ) +! Debug: list * long = bx+$128 (used reg = ) +add bx,#$128 +push bx +mov bx,4[bp] +! Debug: cast * long = const 0 to [$36] long = bx+$44 (used reg = ) +! Debug: list * long = bx+$44 (used reg = ) +add bx,*$44 +push bx +! Debug: func () void = memcpy+0 (used reg = ) +call _memcpy +add sp,*6 +!BCC_EOS +! 30 find_file->number_sector = 1; +mov bx,4[bp] +! Debug: eq int = const 1 to long = [bx+$38] (used reg = ) +mov ax,*1 +xor si,si +mov $38[bx],ax +mov $3A[bx],si +!BCC_EOS +! 31 return 1; +mov ax,*1 +add sp,*8 +pop si +pop di +pop bp +ret +!BCC_EOS +! 32 } +! 33 } +.2E: +! 34 return 0; +.2B: +! Debug: preinc int i = [S+$E-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +.2C: +! Debug: lt int = const $10 to int i = [S+$E-8] (used reg = ) +mov ax,-6[bp] +cmp ax,*$10 +blt .2D +.31: +.2A: +xor ax,ax +add sp,*8 +pop si +pop di +pop bp +ret +!BCC_EOS +! 35 } +! 36 +! 37 Directory_Table* lsfs_find_directory(path, drop_filename) +! Register BX SI used in function lsfs_disk_getattr +! 38 char *path; +export _lsfs_find_directory +_lsfs_find_directory: +!BCC_EOS +! 39 short drop_filename; +!BCC_EOS +! 40 { +! 41 int number_of_traversal; +!BCC_EOS +! 42 int i, j; +!BCC_EOS +! 43 String_Array *split_path; +!BCC_EOS +! 44 Directory_Table *dir_table = calloc(1, sizeof(Directory_Table)); +push bp +mov bp,sp +push di +push si +add sp,*-$A +! Debug: list int = const $2000 (used reg = ) +mov ax,#$2000 +push ax +! Debug: list int = const 1 (used reg = ) +mov ax,*1 +push ax +! Debug: func () * void = calloc+0 (used reg = ) +call _calloc +add sp,*4 +! Debug: eq * void = ax+0 to * struct Directory_Table dir_table = [S+$10-$10] (used reg = ) +mov -$E[bp],ax +!BCC_EOS +! 45 +! 46 disk_service_read_data_from_disk(fsci.master_table_index[0], 16 , dir_table, 0x7e0); +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * struct Directory_Table dir_table = [S+$12-$10] (used reg = ) +push -$E[bp] +! Debug: list int = const $10 (used reg = ) +mov ax,*$10 +push ax +! Debug: list long = [fsci+$100] (used reg = ) +push [_fsci+$102] +push [_fsci+$100] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$A +!BCC_EOS +! 47 split_path = string_split_c(path, '/', 0 ); +! Debug: list int = const 0 (used reg = ) +xor ax,ax +push ax +! Debug: list int = const $2F (used reg = ) +mov ax,*$2F +push ax +! Debug: list * char path = [S+$14+2] (used reg = ) +push 4[bp] +! Debug: func () * struct String_Array = string_split_c+0 (used reg = ) +call _string_split_c +add sp,*6 +! Debug: eq * struct String_Array = ax+0 to * struct String_Array split_path = [S+$10-$E] (used reg = ) +mov -$C[bp],ax +!BCC_EOS +! 48 +! 49 number_of_traversal = split_path->length; +mov bx,-$C[bp] +! Debug: eq unsigned int = [bx+0] to int number_of_traversal = [S+$10-8] (used reg = ) +mov bx,[bx] +mov -6[bp],bx +!BCC_EOS +! 50 +! 51 if (drop_filename) +mov ax,6[bp] +test ax,ax +je .32 +.33: +! 52 { +! 53 number_of_traversal -= 1; +! Debug: subab int = const 1 to int number_of_traversal = [S+$10-8] (used reg = ) +mov ax,-6[bp] +dec ax +mov -6[bp],ax +!BCC_EOS +! 54 } +! 55 +! 56 +! 57 for (i = 0; i < number_of_traversal; ++i) +.32: +! Debug: eq int = const 0 to int i = [S+$10-$A] (used reg = ) +xor ax,ax +mov -8[bp],ax +!BCC_EOS +!BCC_EOS +! 58 { +jmp .36 +.37: +! 59 for (j = 0; j < 16 ; ++j) +! Debug: eq int = const 0 to int j = [S+$10-$C] (used reg = ) +xor ax,ax +mov -$A[bp],ax +!BCC_EOS +!BCC_EOS +! 60 { +jmp .3A +.3B: +! 61 if (strcmp(dir_table->entries[j].filename, split_path->strings[i]->chars) == 0) +mov bx,-$C[bp] +! Debug: ptradd int i = [S+$10-$A] to * * struct Length_String = [bx+2] (used reg = ) +mov ax,-8[bp] +shl ax,*1 +add ax,2[bx] +mov bx,ax +mov bx,[bx] +! Debug: list * char = [bx+4] (used reg = ) +push 4[bx] +! Debug: ptradd int j = [S+$12-$C] to [$10] struct Table_Entry dir_table = [S+$12-$10] (used reg = ) +mov ax,-$A[bp] +mov cx,#$200 +imul cx +add ax,-$E[bp] +mov bx,ax +! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = ) +! Debug: list * char = bx+0 (used reg = ) +push bx +! Debug: func () int = strcmp+0 (used reg = ) +call _strcmp +add sp,*4 +! Debug: logeq int = const 0 to int = ax+0 (used reg = ) +test ax,ax +jne .3C +.3D: +! 62 { +! 63 int index_sector = dir_table->entries[j].data_pointer[0]; +dec sp +dec sp +! Debug: ptradd int j = [S+$12-$C] to [$10] struct Table_Entry dir_table = [S+$12-$10] (used reg = ) +mov ax,-$A[bp] +mov cx,#$200 +imul cx +add ax,-$E[bp] +mov bx,ax +! Debug: ptradd int = const 0 to [$36] long = bx+$128 (used reg = ) +! Debug: eq long = [bx+$128] to int index_sector = [S+$12-$12] (used reg = ) +mov bx,$128[bx] +mov -$10[bp],bx +!BCC_EOS +! 64 +! 65 disk_service_read_data_from_disk(index_sector, 16 , dir_table); +! Debug: list * struct Directory_Table dir_table = [S+$12-$10] (used reg = ) +push -$E[bp] +! Debug: list int = const $10 (used reg = ) +mov ax,*$10 +push ax +! Debug: list int index_sector = [S+$16-$12] (used reg = ) +push -$10[bp] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*6 +!BCC_EOS +! 66 break; +inc sp +inc sp +jmp .38 +!BCC_EOS +! 67 } +inc sp +inc sp +! 68 } +.3C: +! 69 } +.39: +! Debug: preinc int j = [S+$10-$C] (used reg = ) +mov ax,-$A[bp] +inc ax +mov -$A[bp],ax +.3A: +! Debug: lt int = const $10 to int j = [S+$10-$C] (used reg = ) +mov ax,-$A[bp] +cmp ax,*$10 +jl .3B +.3E: +.38: +! 70 return dir_table; +.35: +! Debug: preinc int i = [S+$10-$A] (used reg = ) +mov ax,-8[bp] +inc ax +mov -8[bp],ax +.36: +! Debug: lt int number_of_traversal = [S+$10-8] to int i = [S+$10-$A] (used reg = ) +mov ax,-8[bp] +cmp ax,-6[bp] +jl .37 +.3F: +.34: +mov ax,-$E[bp] +add sp,*$A +pop si +pop di +pop bp +ret +!BCC_EOS +! 71 } +! 72 +! 73 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry, data_segment) +! Register BX used in function lsfs_find_directory +! 74 lsfs_file *file; +export _lsfs_disk_read_data_from_file +_lsfs_disk_read_data_from_file: +!BCC_EOS +! 75 int buffer_size; +!BCC_EOS +! 76 char *data; +!BCC_EOS +! 77 long offset_to_next_entry; +!BCC_EOS +! 78 unsigned int data_segment; +!BCC_EOS +! 79 { +! 80 int integer_file_size = file->size; +push bp +mov bp,sp +push di +push si +dec sp +dec sp +mov bx,4[bp] +! Debug: eq [2] long = bx+$18 to int integer_file_size = [S+8-8] (used reg = ) +add bx,*$18 +mov -6[bp],bx +!BCC_EOS +! 81 int integer_o +! 81 ffset = offset_to_next_entry; +dec sp +dec sp +! Debug: eq long offset_to_next_entry = [S+$A+8] to int integer_offset = [S+$A-$A] (used reg = ) +mov ax,$A[bp] +mov -8[bp],ax +!BCC_EOS +! 82 int integer_datapointer = 0; +dec sp +dec sp +! Debug: eq int = const 0 to int integer_datapointer = [S+$C-$C] (used reg = ) +xor ax,ax +mov -$A[bp],ax +!BCC_EOS +! 83 int data_length = integer_file_size - integer_offset; +dec sp +dec sp +! Debug: sub int integer_offset = [S+$E-$A] to int integer_file_size = [S+$E-8] (used reg = ) +mov ax,-6[bp] +sub ax,-8[bp] +! Debug: eq int = ax+0 to int data_length = [S+$E-$E] (used reg = ) +mov -$C[bp],ax +!BCC_EOS +! 84 int amount_read = 0; +dec sp +dec sp +! Debug: eq int = const 0 to int amount_read = [S+$10-$10] (used reg = ) +xor ax,ax +mov -$E[bp],ax +!BCC_EOS +! 85 int amount_to_read = 0; +dec sp +dec sp +! Debug: eq int = const 0 to int amount_to_read = [S+$12-$12] (used reg = ) +xor ax,ax +mov -$10[bp],ax +!BCC_EOS +! 86 int remaining_offset = offset_to_next_entry; +dec sp +dec sp +! Debug: eq long offset_to_next_entry = [S+$14+8] to int remaining_offset = [S+$14-$14] (used reg = ) +mov ax,$A[bp] +mov -$12[bp],ax +!BCC_EOS +! 87 +! 88 +! 89 +! 90 +! 91 +! 92 int data_pointer_index = 0; +dec sp +dec sp +! Debug: eq int = const 0 to int data_pointer_index = [S+$16-$16] (used reg = ) +xor ax,ax +mov -$14[bp],ax +!BCC_EOS +! 93 +! 94 if (data_length > buffer_size) +! Debug: gt int buffer_size = [S+$16+4] to int data_length = [S+$16-$E] (used reg = ) +mov ax,-$C[bp] +cmp ax,6[bp] +jle .40 +.41: +! 95 { +! 96 data_length = buffer_size; +! Debug: eq int buffer_size = [S+$16+4] to int data_length = [S+$16-$E] (used reg = ) +mov ax,6[bp] +mov -$C[bp],ax +!BCC_EOS +! 97 } +! 98 +! 99 while(data_length > 0) +.40: +! 100 { +br .43 +.44: +! 101 +! 102 if (remaining_offset == 0) +! Debug: logeq int = const 0 to int remaining_offset = [S+$16-$14] (used reg = ) +mov ax,-$12[bp] +test ax,ax +bne .45 +.46: +! 103 { +! 104 char *tmp_buffer = calloc(4 , 512 ); +dec sp +dec sp +! Debug: list int = const $200 (used reg = ) +mov ax,#$200 +push ax +! Debug: list int = const 4 (used reg = ) +mov ax,*4 +push ax +! Debug: func () * void = calloc+0 (used reg = ) +call _calloc +add sp,*4 +! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$18-$18] (used reg = ) +mov -$16[bp],ax +!BCC_EOS +! 105 +! 106 +! 107 if (data_length < (4 * 512 )) +! Debug: lt int = const $800 to int data_length = [S+$18-$E] (used reg = ) +mov ax,-$C[bp] +cmp ax,#$800 +jge .47 +.48: +! 108 { +! 109 amount_to_read = data_length; +! Debug: eq int data_length = [S+$18-$E] to int amount_to_read = [S+$18-$12] (used reg = ) +mov ax,-$C[bp] +mov -$10[bp],ax +!BCC_EOS +! 110 } +! 111 else +! 112 { +jmp .49 +.47: +! 113 amount_to_read = (4 * 512 ); +! Debug: eq int = const $800 to int amount_to_read = [S+$18-$12] (used reg = ) +mov ax,#$800 +mov -$10[bp],ax +!BCC_EOS +! 114 } +! 115 +! 116 integer_datapointer = file->data_pointer[data_pointer_index]; +.49: +mov bx,4[bp] +! Debug: ptradd int data_pointer_index = [S+$18-$16] to [$36] long = bx+$44 (used reg = ) +mov ax,-$14[bp] +shl ax,*1 +shl ax,*1 +add bx,ax +! Debug: eq long = [bx+$44] to int integer_datapointer = [S+$18-$C] (used reg = ) +mov bx,$44[bx] +mov -$A[bp],bx +!BCC_EOS +! 117 if (integer_datapointer == 0) +! Debug: logeq int = const 0 to int integer_datapointer = [S+$18-$C] (used reg = ) +mov ax,-$A[bp] +test ax,ax +jne .4A +.4B: +! 118 { +! 119 break; +inc sp +inc sp +br .42 +!BCC_EOS +! 120 } +! 121 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer, 0x7e0); +.4A: +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char tmp_buffer = [S+$1A-$18] (used reg = ) +push -$16[bp] +! Debug: list int = const 4 (used reg = ) +mov ax,*4 +push ax +mov bx,4[bp] +! Debug: ptradd int data_pointer_index = [S+$1E-$16] to [$36] long = bx+$44 (used reg = ) +mov ax,-$14[bp] +shl ax,*1 +shl ax,*1 +add bx,ax +! Debug: list long = [bx+$44] (used reg = ) +push $46[bx] +push $44[bx] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$A +!BCC_EOS +! 122 memcpy((data + amount_read), data_segment, tmp_buffer, 0x7e0, amount_to_read); +! Debug: list int amount_to_read = [S+$18-$12] (used reg = ) +push -$10[bp] +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char tmp_buffer = [S+$1C-$18] (used reg = ) +push -$16[bp] +! Debug: list unsigned int data_segment = [S+$1E+$C] (used reg = ) +push $E[bp] +! Debug: ptradd int amount_read = [S+$20-$10] to * char data = [S+$20+6] (used reg = ) +mov ax,-$E[bp] +add ax,8[bp] +! Debug: list * char = ax+0 (used reg = ) +push ax +! Debug: func () void = memcpy+0 (used reg = ) +call _memcpy +add sp,*$A +!BCC_EOS +! 123 data_length -= amount_to_read; +! Debug: subab int amount_to_read = [S+$18-$12] to int data_length = [S+$18-$E] (used reg = ) +mov ax,-$C[bp] +sub ax,-$10[bp] +mov -$C[bp],ax +!BCC_EOS +! 124 amount_read += amount_to_read; +! Debug: addab int amount_to_read = [S+$18-$12] to int amount_read = [S+$18-$10] (used reg = ) +mov ax,-$E[bp] +add ax,-$10[bp] +mov -$E[bp],ax +!BCC_EOS +! 125 data_pointer_index = data_pointer_index + 2; +! Debug: add int = const 2 to int data_pointer_index = [S+$18-$16] (used reg = ) +mov ax,-$14[bp] +! Debug: eq int = ax+2 to int data_pointer_index = [S+$18-$16] (used reg = ) +inc ax +inc ax +mov -$14[bp],ax +!BCC_EOS +! 126 +! 127 } +inc sp +inc sp +! 128 else if (remaining_offset < (4 * 512 )) +br .4C +.45: +! Debug: lt int = const $800 to int remaining_offset = [S+$16-$14] (used reg = ) +mov ax,-$12[bp] +cmp ax,#$800 +bge .4D +.4E: +! 129 { +! 130 char *tmp_buffer = calloc(1, (4 * 512 )); +dec sp +dec sp +! Debug: list int = const $800 (used reg = ) +mov ax,#$800 +push ax +! Debug: list int = const 1 (used reg = ) +mov ax,*1 +push ax +! Debug: func () * void = calloc+0 (used reg = ) +call _calloc +add sp,*4 +! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$18-$18] (used reg = ) +mov -$16[bp],ax +!BCC_EOS +! 131 +! 132 +! 133 if (data_length < ((4 * 512 ) - remaining_offset) ) +! Debug: sub int remaining_offset = [S+$18-$14] to int = const $800 (used reg = ) +mov ax,#$800 +sub ax,-$12[bp] +! Debug: lt int = ax+0 to int data_length = [S+$18-$E] (used reg = ) +cmp ax,-$C[bp] +jle .4F +.50: +! 134 { +! 135 amount_to_read = data_length; +! Debug: eq int data_length = [S+$18-$E] to int amount_to_read = [S+$18-$12] (used reg = ) +mov ax,-$C[bp] +mov -$10[bp],ax +!BCC_EOS +! 136 } +! 137 else +! 138 { +jmp .51 +.4F: +! 139 amount_to_read = ((4 * 512 ) - remaining_offset); +! Debug: sub int remaining_offset = [S+$18-$14] to int = const $800 (used reg = ) +mov ax,#$800 +sub ax,-$12[bp] +! Debug: eq int = ax+0 to int amount_to_read = [S+$18-$12] (used reg = ) +mov -$10[bp],ax +!BCC_EOS +! 140 } +! 141 +! 142 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer, 0x7e0); +.51: +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char tmp_buffer = [S+$1A-$18] (used reg = ) +push -$16[bp] +! Debug: list int = const 4 (used reg = ) +mov ax,*4 +push ax +mov bx,4[bp] +! Debug: ptradd int data_pointer_index = [S+$1E-$16] to [$36] long = bx+$44 (used reg = ) +mov ax,-$14[bp] +shl ax,*1 +shl ax,*1 +add bx,ax +! Debug: list long = [bx+$44] (used reg = ) +push $46[bx] +push $44[bx] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$A +!BCC_EOS +! 143 +! 144 memcpy(data, data_segment, (tmp_buffer + remaining_offset), 0x7e0, amount_to_read); +! Debug: list int amount_to_read = [S+$18-$12] (used reg = ) +push -$10[bp] +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: ptradd int remaining_offset = [S+$1C-$14] to * char tmp_buffer = [S+$1C-$18] (used reg = ) +mov ax,-$12[bp] +add ax,-$16[bp] +! Debug: list * char = ax+0 (used reg = ) +push ax +! Debug: list unsigned int data_segment = [S+$1E+$C] (used reg = ) +push $E[bp] +! Debug: list * char data = [S+$20+6] (used reg = ) +push 8[bp] +! Debug: func () void = memcpy+0 (used reg = ) +call _memcpy +add sp,*$A +!BCC_EOS +! 145 data_length -= amount_to_read; +! Debug: subab int amount_to_read = [S+$18-$12] to int data_length = [S+$18-$E] (used reg = ) +mov ax,-$C[bp] +sub ax,-$10[bp] +mov -$C[bp],ax +!BCC_EOS +! 146 amount_read += amount_to_read; +! Debug: addab int amount_to_read = [S+$18-$12] to int amount_read = [S+$18-$10] (used reg = ) +mov ax,-$E[bp] +add ax,-$10[bp] +mov -$E[bp],ax +!BCC_EOS +! 147 remaining_offset -= amount_to_read; +! Debug: subab int amount_to_read = [S+$18-$12] to int remaining_offset = [S+$18-$14] (used reg = ) +mov ax,-$12[bp] +sub ax,-$10[bp] +mov -$12[bp],ax +!BCC_EOS +! 148 +! 149 data_pointer_index = data_ +! 149 pointer_index + 2; +! Debug: add int = const 2 to int data_pointer_index = [S+$18-$16] (used reg = ) +mov ax,-$14[bp] +! Debug: eq int = ax+2 to int data_pointer_index = [S+$18-$16] (used reg = ) +inc ax +inc ax +mov -$14[bp],ax +!BCC_EOS +! 150 +! 151 } +inc sp +inc sp +! 152 else +! 153 { +jmp .52 +.4D: +! 154 +! 155 remaining_offset -= (4 * 512 ); +! Debug: subab int = const $800 to int remaining_offset = [S+$16-$14] (used reg = ) +mov ax,-$12[bp] +add ax,#-$800 +mov -$12[bp],ax +!BCC_EOS +! 156 data_pointer_index++; +! Debug: postinc int data_pointer_index = [S+$16-$16] (used reg = ) +mov ax,-$14[bp] +inc ax +mov -$14[bp],ax +!BCC_EOS +! 157 } +! 158 +! 159 } +.52: +.4C: +! 160 # 164 +! 164 +! 165 return amount_read; +.43: +! Debug: gt int = const 0 to int data_length = [S+$16-$E] (used reg = ) +mov ax,-$C[bp] +test ax,ax +bgt .44 +.53: +.42: +mov ax,-$E[bp] +add sp,*$10 +pop si +pop di +pop bp +ret +!BCC_EOS +! 166 +! 167 } +! 168 +! Register BX used in function lsfs_disk_read_data_from_file +.data +.bss + +! 0 errors detected diff --git a/main.c b/main.c index 4fb6417..e7a5a59 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,7 @@ /* */ #include "main.h" + int main(selector, pointer_parameter_segment, pointer_parameter_struct) int selector; void* pointer_parameter_segment; @@ -12,19 +13,19 @@ void* pointer_parameter_struct; /* selectot should be a "selector" for which disk service*/ /* one wnats to use. */ /* 0 should not be used, to try to ensure that a value has been set explicitly. */ - FSCI fsci; Service_Action service_action; Directory_Table current_table; Parameter_Struct parameter_struct; int local_segment = 0x7e0; - unsigned int heap_start = 0x2000; + unsigned int heap_start = 0x2200; unsigned int heap_end = 0xffff; int stack_segment = 0x8fc0; int path_length; - long index_as_long; + long index_as_long = 0; char *local_path = 0; + FSCI *fsci = 0x2000; service_action = selector; switch (service_action) @@ -35,20 +36,36 @@ void* pointer_parameter_struct; What do we need to know: Index of FSCI */ + set_heap_settings(heap_start, heap_end); index_as_long = pointer_parameter_struct; - disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment); + disk_service_read_data_from_disk(index_as_long, (long) 1, fsci, local_segment); print("File System has been loaded: "); print_newline(); - set_heap_settings(heap_start, heap_end); - print_stack(fsci.filesystem_information); + print(fsci->filesystem_information); + print_newline(); + dump_ax(fsci->master_table_index[0]); print_newline(); } break; case SERVICE_FIND_ENTRY: { String_Array *path_array; + lsfs_file* find_file; int i; + dump_ax(fsci->master_table_index[0]); + disk_service_read_data_from_disk(fsci->master_table_index[0], (long) DEFAULT_TABLE_SIZE, ¤t_table, stack_segment); + print("Current table: "); + print_newline(); + print_stack(current_table.entries[0].filename); + print_newline(); + print_stack(current_table.entries[1].filename); + print_newline(); + print_stack(current_table.entries[2].filename); + print_newline(); + + memcpy(¶meter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct)); path_length = strlen(parameter_struct.path, pointer_parameter_segment); + dump_ax(path_length); local_path = malloc(256); memcpy(local_path, local_segment, parameter_struct.path, pointer_parameter_segment, path_length); local_path[path_length] = 0; @@ -66,16 +83,23 @@ void* pointer_parameter_struct; print_newline(); print_newline(); + find_file = calloc(sizeof(lsfs_file), 1); + lsfs_disk_getattr(find_file, local_path, fsci); print_newline(); - disk_service_read_data_from_disk(fsci.master_table_index[0], DEFAULT_TABLE_SIZE, ¤t_table, stack_segment); - print("Current table: "); - print_newline(); - print_stack(current_table.entries[0].filename); + print("Loding SingOS kernel: "); + print(find_file->filename); print_newline(); - print_stack(current_table.entries[1].filename); + print("Kernel file id: "); + dump_ax(find_file->file_id[0]); print_newline(); - print_stack(current_table.entries[2].filename); + print("Kernel file size: "); + dump_ax(find_file->size[0]); print_newline(); + print("Kernel first data pointer: "); + dump_ax(find_file->data_pointer[0]); + + lsfs_disk_read_data_from_file(find_file, 0xffff, 0x00, (long) 0x0, 0x50); + } break; case SERIVCE_READ_DATA: diff --git a/main.h b/main.h index f094fa2..33201a8 100644 --- a/main.h +++ b/main.h @@ -1,14 +1,17 @@ #ifndef MAIN_H #define MAIN_H +#define false 0 +#define true 1 + #define SPACE_MBR_RECORD 2048 /* Sectors*/ #define SPACE_VBR_RECORD 2048 /* Sectors*/ #define SIZE_FSCI_RECORD 1 /* Sectors*/ #define DEFAULT_ENTRY_SIZE 1 /* Sectors*/ #define SECTOR_SIZE 512 /* BYTES*/ #define NUMBER_OF_MBR_PARTITIONS 4 -#define DEFAULT_FILE_SIZE 4 /* This is in sectors*/ -#define DEFAULT_DATA_POINTER_SIZE 4 /* This is in sectors*/ +#define DEFAULT_FILE_SIZE 8 /* This is in sectors*/ +#define DEFAULT_DATA_POINTER_SIZE 8 /* This is in sectors*/ #define DEFAULT_TABLE_SIZE 16 #define NUM_DATA_POINTERS 27 @@ -17,27 +20,17 @@ #include "std_singos/string.h" #include "driver/disk.h" -#include "implementation/lsfs.h" void dump_ax(input); void print_stack(argument); void print_newline(); -typedef struct Directory_Table Directory_Table; -typedef struct Struct_Table_Entry Table_Entry; typedef struct struct_partition_control partition_control; typedef struct File_System_Control_Information FSCI; typedef struct meta_information_format mif; typedef struct tag_record tag_record; typedef struct Parameter_Struct Parameter_Struct; -typedef enum Table_Entry_Kind -{ - /* These are specific values since, is has to corrospond to the implementation in assembly*/ - ENTRY_EMPTY = 0, - ENTRY_FILE = 1, - ENTRY_DIRECTORY = 2, -} Table_Entry_Kind; typedef enum Service_Action { @@ -48,22 +41,6 @@ typedef enum Service_Action } Service_Action; -struct Struct_Table_Entry -{ - char filename[256]; - long file_id[2]; - long file_size[2]; - void* ext_file_data_low; - void* ext_file_data_high; - long number_sector_s; /* <- Just try to remove the last undercore and compile . */ - short entry_kind; - short extra_control_bits1; - short extra_control_bits2; - short extra_control_bits3; - long table_entry_sector_index[2]; - long data_pointer[NUM_DATA_POINTERS * 2]; /* if it is a directory, the first pointer will be to the next table. */ -}; - struct File_System_Control_Information { char filesystem_information[256]; @@ -79,11 +56,6 @@ struct File_System_Control_Information }; -typedef struct Directory_Table -{ - Table_Entry entries[DEFAULT_TABLE_SIZE]; - -}; struct Parameter_Struct { @@ -94,7 +66,8 @@ struct Parameter_Struct int buffer_size; int data_length; int byte_offset_into_file; - Table_Entry_Kind entry_kind; + short entry_kind; }; +#include "implementation/lsfs.h" #endif diff --git a/main.s b/main.s index cbc41c3..5432cd2 100644 --- a/main.s +++ b/main.s @@ -374,9 +374,9 @@ pop di pop bp ret !BCC_EOS -! 61 # 16 "main.h" -! 16 } -! 17 # 2 "std_singos/string.h" +! 61 # 19 "main.h" +! 19 } +! 20 # 2 "std_singos/string.h" ! 2 type ! 2 def struct Length_String { ! 3 short dynamic; @@ -588,17 +588,135 @@ _memcpy.destination_segment set 4 ! 166 } ret ! 167 -! 168 String_Array *string_split_c(string, delim, keep_delim) -! 169 char *string; +! 168 int strcmp(source_1, source_2) +! 169 char* source_1; +export _strcmp +_strcmp: +!BCC_EOS +! 170 char* source_2; +!BCC_EOS +! 171 { +! 172 int i; +!BCC_EOS +! 173 int count; +!BCC_EOS +! 174 +! 175 count = strlen(source_1, 0x7e0); +push bp +mov bp,sp +push di +push si +add sp,*-4 +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char source_1 = [S+$C+2] (used reg = ) +push 4[bp] +! Debug: func () int = strlen+0 (used reg = ) +call _strlen +add sp,*4 +! Debug: eq int = ax+0 to int count = [S+$A-$A] (used reg = ) +mov -8[bp],ax +!BCC_EOS +! 176 if (count != strlen(source_2, 0x7e0)) +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char source_2 = [S+$C+4] (used reg = ) +push 6[bp] +! Debug: func () int = strlen+0 (used reg = ) +call _strlen +add sp,*4 +! Debug: ne int = ax+0 to int count = [S+$A-$A] (used reg = ) +! Debug: expression subtree swapping +cmp ax,-8[bp] +je .A +.B: +! 177 { +! 178 return -1; +mov ax,*-1 +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 179 } +! 180 +! 181 +! 182 for (i = 0; i < count; i++) +.A: +! Debug: eq int = const 0 to int i = [S+$A-8] (used reg = ) +xor ax,ax +mov -6[bp],ax +!BCC_EOS +!BCC_EOS +! 183 { +jmp .E +.F: +! 184 if(source_1[i] != source_2[i]) +! Debug: ptradd int i = [S+$A-8] to * char source_2 = [S+$A+4] (used reg = ) +mov ax,-6[bp] +add ax,6[bp] +mov bx,ax +! Debug: ptradd int i = [S+$A-8] to * char source_1 = [S+$A+2] (used reg = bx) +mov ax,-6[bp] +add ax,4[bp] +mov si,ax +! Debug: ne char = [bx+0] to char = [si+0] (used reg = ) +mov al,[si] +cmp al,[bx] +je .10 +.11: +! 185 { +! 186 return -1; +mov ax,*-1 +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 187 } +! 188 } +.10: +! 189 +! 190 return 0; +.D: +! Debug: postinc int i = [S+$A-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +.E: +! Debug: lt int count = [S+$A-$A] to int i = [S+$A-8] (used reg = ) +mov ax,-6[bp] +cmp ax,-8[bp] +jl .F +.12: +.C: +xor ax,ax +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 191 # 223 +! 223 +! 224 } +! 225 +! 226 String_Array *string_split_c(string, delim, keep_delim) +! Register BX SI used in function strcmp +! 227 char *string; export _string_split_c _string_split_c: !BCC_EOS -! 170 char delim; +! 228 char delim; !BCC_EOS -! 171 short keep_delim; +! 229 short keep_delim; !BCC_EOS -! 172 { -! 173 return length_string_split(make_length_string_c(string), delim, keep_delim); +! 230 { +! 231 return length_string_split(make_length_string_c(string), delim, keep_delim); push bp mov bp,sp push di @@ -626,15 +744,15 @@ pop di pop bp ret !BCC_EOS -! 174 } -! 175 -! 176 Length_String *make_length_string_c(cstring) -! 177 char *cstring; +! 232 } +! 233 +! 234 Length_String *make_length_string_c(cstring) +! 235 char *cstring; export _make_length_string_c _make_length_string_c: !BCC_EOS -! 178 { -! 179 return make_length_string(strlen(cstring, 0x7e0), cstring); +! 236 { +! 237 return make_length_string(strlen(cstring, 0x7e0), cstring); push bp mov bp,sp push di @@ -660,18 +778,18 @@ pop di pop bp ret !BCC_EOS -! 180 } -! 181 -! 182 Length_String *make_length_string(length, chars) -! 183 unsigned int length; +! 238 } +! 239 +! 240 Length_String *make_length_string(length, chars) +! 241 unsigned int length; export _make_length_string _make_length_string: !BCC_EOS -! 184 char *chars; +! 242 char *chars; !BCC_EOS -! 185 { -! 186 -! 187 Length_String *legth_string = malloc(sizeof(Length_String)); +! 243 { +! 244 +! 245 Length_String *legth_string = malloc(sizeof(Length_String)); push bp mov bp,sp push di @@ -688,9 +806,10 @@ inc sp ! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = ) mov -6[bp],ax !BCC_EOS -! 188 char *copy = malloc(length + 1); +! 246 char *copy = malloc(length dec sp dec sp +! 246 + 1); ! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = ) mov ax,4[bp] ! Debug: list unsigned int = ax+1 (used reg = ) @@ -703,7 +822,7 @@ inc sp ! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = ) mov -8[bp],ax !BCC_EOS -! 189 memcpy(copy, 0x7e0, chars, 0x7e0, length); +! 247 memcpy(copy, 0x7e0, chars, 0x7e0, length); ! Debug: list unsigned int length = [S+$A+2] (used reg = ) push 4[bp] ! Debug: list int = const $7E0 (used reg = ) @@ -720,7 +839,7 @@ push -8[bp] call _memcpy add sp,*$A !BCC_EOS -! 190 copy[length] = ''; +! 248 copy[length] = ''; ! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = ) mov ax,4[bp] add ax,-8[bp] @@ -729,27 +848,27 @@ mov bx,ax xor al,al mov [bx],al !BCC_EOS -! 191 -! 192 legth_string->dynamic = 0; +! 249 +! 250 legth_string->dynamic = 0; mov bx,-6[bp] ! Debug: eq int = const 0 to short = [bx+0] (used reg = ) xor ax,ax mov [bx],ax !BCC_EOS -! 193 legth_string->length = length; +! 251 legth_string->length = length; mov bx,-6[bp] ! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = ) mov ax,4[bp] mov 2[bx],ax !BCC_EOS -! 194 legth_string->chars = (char *)chars; +! 252 legth_string->chars = (char *)chars; mov bx,-6[bp] ! Debug: eq * char chars = [S+$A+4] to * char = [bx+4] (used reg = ) mov si,6[bp] mov 4[bx],si !BCC_EOS -! 195 -! 196 return legth_string; +! 253 +! 254 return legth_string; mov ax,-6[bp] add sp,*4 pop si @@ -757,26 +876,25 @@ pop di pop bp ret !BCC_EOS -! 197 } -! 198 -! 199 String_Array *length_string_split(string, delim, keep_delim) +! 255 } +! 256 +! 257 String_Array *length_string_split(string, delim, keep_delim) ! Register BX SI used in function make_length_string -! 200 Length_String *string; +! 258 Length_String *string; export _length_string_split _length_string_split: !BCC_EOS -! 201 char delim; +! 259 char delim; !BCC_EOS -! 202 short keep_delim; +! 260 short keep_delim; !BCC_EOS -! 203 { -! 204 unsigned int i; +! 261 { +! 262 unsigned int i; !BCC_EOS -! 205 unsi -! 205 gned int last; +! 263 unsigned int last; !BCC_EOS -! 206 -! 207 unsigned int count = 0; +! 264 +! 265 unsigned int count = 0; push bp mov bp,sp push di @@ -786,33 +904,33 @@ add sp,*-6 xor ax,ax mov -$A[bp],ax !BCC_EOS -! 208 unsigned int insert_index = 0; +! 266 unsigned int insert_index = 0; dec sp dec sp ! Debug: eq int = const 0 to unsigned int insert_index = [S+$E-$E] (used reg = ) xor ax,ax mov -$C[bp],ax !BCC_EOS -! 209 String_Array *result; +! 267 String_Array *result; !BCC_EOS -! 210 int k; +! 268 int k; !BCC_EOS -! 211 -! 212 i = 0; +! 269 +! 270 i = 0; add sp,*-4 ! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = ) xor ax,ax mov -6[bp],ax !BCC_EOS -! 213 last = 0; +! 271 last = 0; ! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = ) xor ax,ax mov -8[bp],ax !BCC_EOS -! 214 while(i < string->length) { -jmp .B -.C: -! 215 if (string->chars[i] == delim) { +! 272 while(i < string->length) { +jmp .14 +.15: +! 273 if (string->chars[i] == delim) { mov bx,4[bp] ! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = ) mov ax,-6[bp] @@ -821,64 +939,64 @@ mov bx,ax ! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = ) mov al,[bx] cmp al,6[bp] -jne .D -.E: -! 216 if (i > last+1) { +jne .16 +.17: +! 274 if (i > last+1) { ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) inc ax cmp ax,-6[bp] -jae .F -.10: -! 217 ++count; +jae .18 +.19: +! 275 ++count; ! Debug: preinc unsigned int count = [S+$12-$C] (used reg = ) mov ax,-$A[bp] inc ax mov -$A[bp],ax !BCC_EOS -! 218 } -! 219 last = i; -.F: +! 276 } +! 277 last = i; +.18: ! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-6[bp] mov -8[bp],ax !BCC_EOS -! 220 } -! 221 ++i; -.D: +! 278 } +! 279 ++i; +.16: ! Debug: preinc unsigned int i = [S+$12-8] (used reg = ) mov ax,-6[bp] inc ax mov -6[bp],ax !BCC_EOS -! 222 } -! 223 if (i > last+1) { -.B: +! 280 } +! 281 if (i > last+1) { +.14: mov bx,4[bp] ! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = ) mov ax,-6[bp] cmp ax,2[bx] -jb .C -.11: -.A: +jb .15 +.1A: +.13: ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) inc ax cmp ax,-6[bp] -jae .12 -.13: -! 224 ++count; +jae .1B +.1C: +! 282 ++count; ! Debug: preinc unsigned int count = [S+$12-$C] (used reg = ) mov ax,-$A[bp] inc ax mov -$A[bp],ax !BCC_EOS -! 225 } -! 226 -! 227 result = create_length_string_array(count); -.12: +! 283 } +! 284 +! 285 result = create_length_string_array(count); +.1B: ! Debug: list unsigned int count = [S+$12-$C] (used reg = ) push -$A[bp] ! Debug: func () * struct String_Array = create_length_string_array+0 (used reg = ) @@ -888,45 +1006,45 @@ inc sp ! Debug: eq * struct String_Array = ax+0 to * struct String_Array result = [S+$12-$10] (used reg = ) mov -$E[bp],ax !BCC_EOS -! 228 -! 229 if (keep_delim) +! 286 +! 287 if (keep_delim) mov ax,8[bp] test ax,ax -je .14 -.15: -! 230 { -! 231 k = 0; +je .1D +.1E: +! 288 { +! 289 k = 0; ! Debug: eq int = const 0 to int k = [S+$12-$12] (used reg = ) xor ax,ax mov -$10[bp],ax !BCC_EOS -! 232 } -! 233 else -! 234 { -jmp .16 -.14: -! 235 k = 1; +! 290 } +! 291 else +! 292 { +jmp .1F +.1D: +! 293 k = 1; ! Debug: eq int = const 1 to int k = [S+$12-$12] (used reg = ) mov ax,*1 mov -$10[bp],ax !BCC_EOS -! 236 } -! 237 -! 238 i = 0; -.16: +! 294 } +! 295 +! 296 i = 0; +.1F: ! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = ) xor ax,ax mov -6[bp],ax !BCC_EOS -! 239 last = 0; +! 297 last = 0; ! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = ) xor ax,ax mov -8[bp],ax !BCC_EOS -! 240 while(i < string->length) { -jmp .18 -.19: -! 241 if (string->chars[i] == delim) { +! 298 while(i < string->length) { +jmp .21 +.22: +! 299 if (string->chars[i] == delim) { mov bx,4[bp] ! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = ) mov ax,-6[bp] @@ -935,17 +1053,17 @@ mov bx,ax ! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = ) mov al,[bx] cmp al,6[bp] -jne .1A -.1B: -! 242 if (i > last+1) { +jne .23 +.24: +! 300 if (i > last+1) { ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) inc ax cmp ax,-6[bp] -jae .1C -.1D: -! 243 result->strings[insert_index++] = create_length_string(i-(last+k), string->chars+(last+k)); +jae .25 +.26: +! 301 result->strings[insert_index++] = create_length_string(i-(last+k), string->chars+(last+k)); ! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] add ax,-$10[bp] @@ -985,39 +1103,39 @@ mov [bx],si inc sp inc sp !BCC_EOS -! 244 } -! 245 last = i; -.1C: +! 302 } +! 303 last = i; +.25: ! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-6[bp] mov -8[bp],ax !BCC_EOS -! 246 } -! 247 ++i; -.1A: +! 304 } +! 305 ++i; +.23: ! Debug: preinc unsigned int i = [S+$12-8] (used reg = ) mov ax,-6[bp] inc ax mov -6[bp],ax !BCC_EOS -! 248 } -! 249 if (i > last+1) { -.18: +! 306 } +! 307 if (i > last+1) { +.21: mov bx,4[bp] ! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = ) mov ax,-6[bp] cmp ax,2[bx] -jb .19 -.1E: -.17: +jb .22 +.27: +.20: ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = ) inc ax cmp ax,-6[bp] -jae .1F -.20: -! 250 result->strings[insert_index++] = create_length_string(i-(last+k), ((string->chars)+(last+k))); +jae .28 +.29: +! 308 result->strings[insert_index++] = create_length_string(i-(last+k), ((string->chars)+(last+k))); ! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = ) mov ax,-8[bp] add ax,-$10[bp] @@ -1057,10 +1175,10 @@ mov [bx],si inc sp inc sp !BCC_EOS -! 251 } -! 252 -! 253 return result; -.1F: +! 309 } +! 310 +! 311 return result; +.28: mov ax,-$E[bp] add sp,*$C pop si @@ -1068,17 +1186,17 @@ pop di pop bp ret !BCC_EOS -! 254 -! 255 } -! 256 -! 257 String_Array *create_length_string_array(array_size) +! 312 +! 313 } +! 314 +! 315 String_Array *create_length_string_array(array_size) ! Register BX SI used in function length_string_split -! 258 int array_size; +! 316 int array_size; export _create_length_string_array _create_length_string_array: !BCC_EOS -! 259 { -! 260 String_Array *result = malloc(sizeof(String_Array)); +! 317 { +! 318 String_Array *result = malloc(sizeof(String_Array)); push bp mov bp,sp push di @@ -1095,13 +1213,13 @@ inc sp ! Debug: eq * void = ax+0 to * struct String_Array result = [S+8-8] (used reg = ) mov -6[bp],ax !BCC_EOS -! 261 result->length = array_size; +! 319 result->length = array_size; mov bx,-6[bp] ! Debug: eq int array_size = [S+8+2] to unsigned int = [bx+0] (used reg = ) mov ax,4[bp] mov [bx],ax !BCC_EOS -! 262 result->strings = malloc(array_size * sizeof(Length_String)); +! 320 result->strings = malloc(array_size * sizeof(Length_String)); ! Debug: mul int = const 6 to int array_size = [S+8+2] (used reg = ) mov ax,4[bp] mov dx,ax @@ -1118,7 +1236,7 @@ mov bx,-6[bp] ! Debug: eq * void = ax+0 to * * struct Length_String = [bx+2] (used reg = ) mov 2[bx],ax !BCC_EOS -! 263 return result; +! 321 return result; mov ax,-6[bp] inc sp inc sp @@ -1127,20 +1245,20 @@ pop di pop bp ret !BCC_EOS -! 264 } -! 265 -! 266 -! 267 Length_String *create_length_string(length, chars) +! 322 } +! 323 +! 324 +! 325 Length_String *create_length_string(length, chars) ! Register BX used in function create_length_string_array -! 268 unsigned int length; +! 326 unsigned int length; export _create_length_string _create_length_string: !BCC_EOS -! 269 char *chars; +! 327 char *chars; !BCC_EOS -! 270 { -! 271 -! 272 Length_String *legth_string = malloc(sizeof(Length_String)); +! 328 { +! 329 +! 330 Length_String *legth_string = malloc(sizeof(Length_String)); push bp mov bp,sp push di @@ -1157,7 +1275,7 @@ inc sp ! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = ) mov -6[bp],ax !BCC_EOS -! 273 char *copy = malloc(length + 1); +! 331 char *copy = malloc(length + 1); dec sp dec sp ! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = ) @@ -1172,7 +1290,7 @@ inc sp ! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = ) mov -8[bp],ax !BCC_EOS -! 274 memcpy(copy, 0x7e0, chars, 0x7e0, length); +! 332 memcpy(copy, 0x7e0, chars, 0x7e0, length); ! Debug: list unsigned int length = [S+$A+2] (used reg = ) push 4[bp] ! Debug: list int = const $7E0 (used reg = ) @@ -1189,7 +1307,7 @@ push -8[bp] call _memcpy add sp,*$A !BCC_EOS -! 275 copy[length] = ''; +! 333 copy[length] = ''; ! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = ) mov ax,4[bp] add ax,-8[bp] @@ -1198,27 +1316,27 @@ mov bx,ax xor al,al mov [bx],al !BCC_EOS -! 276 -! 277 legth_string->dynamic = 1; +! 334 +! 335 legth_string->dynamic = 1; mov bx,-6[bp] ! Debug: eq int = const 1 to short = [bx+0] (used reg = ) mov ax,*1 mov [bx],ax !BCC_EOS -! 278 legth_string->length = length; +! 336 legth_string->length = length; mov bx,-6[bp] ! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = ) mov ax,4[bp] mov 2[bx],ax !BCC_EOS -! 279 legth_string->chars = copy; +! 337 legth_string->chars = copy; mov bx,-6[bp] ! Debug: eq * char copy = [S+$A-$A] to * char = [bx+4] (used reg = ) mov si,-8[bp] mov 4[bx],si !BCC_EOS -! 280 -! 281 return legth_string; +! 338 +! 339 return legth_string; mov ax,-6[bp] add sp,*4 pop si @@ -1226,17 +1344,18 @@ pop di pop bp ret !BCC_EOS -! 282 # 18 "main.h" -! 18 } -! 19 # 1 "driver/disk.h" -! 1 int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); +! 340 # 21 "main.h" +! 21 } +! 22 # 1 "driver/disk.h" +! 1 int data_from_disk(index ! Register BX SI used in function create_length_string +! 1 , number_sectors, data_buffer, data_buffer_segment); !BCC_EOS ! 2 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); !BCC_EOS ! 3 ! 4 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment) -! 5 long* index; +! 5 long index; export _disk_service_read_data_from_disk _disk_service_read_data_from_disk: !BCC_EOS @@ -1244,15 +1363,15 @@ _disk_service_read_data_from_disk: !BCC_EOS ! 7 void* data_buffer; !BCC_EOS -! 8 int data_buffer_segment; +! 8 unsigned int data_buffer_segment; !BCC_EOS ! 9 { ! 10 ! 11 #asm !BCC_ASM -_disk_service_read_data_from_disk.data_buffer set 8 -_disk_service_read_data_from_disk.number_sectors set 4 -_disk_service_read_data_from_disk.data_buffer_segment set $A +_disk_service_read_data_from_disk.data_buffer set $A +_disk_service_read_data_from_disk.number_sectors set 6 +_disk_service_read_data_from_disk.data_buffer_segment set $C _disk_service_read_data_from_disk.index set 2 ! 13 define number_sectors 8[bp]; @@ -1262,15 +1381,21 @@ _disk_service_read_data_from_disk.index set 2 push bp mov bp,sp pusha - lsfs_load_data: mov ax, 4[bp]; + call 0x0000:0x7C2A mov WORD [DAPACK.lba_addr_dw_low], ax mov bx, 8[bp]; + mov ax, bx + call 0x0000:0x7C2A mov WORD [DAPACK.blkcnt], bx - mov cx, 12[bp]; + mov cx, 14[bp]; + mov ax, cx + call 0x0000:0x7C2A mov WORD [DAPACK.db_addr_segment], cx - mov dx, 10[bp]; ; + mov dx, 12[bp]; ; + mov ax, dx + call 0x0000:0x7C2A mov WORD [DAPACK.db_addr_offset], dx mov si, #DAPACK ; address of mov ah, #0x42 ; READ @@ -1293,25 +1418,18 @@ _disk_service_read_data_from_disk.index set 2 global_disk_identifier: db 0x80 -! 51 endasm +! 57 endasm !BCC_ENDASM -! 52 } +! 58 } ret -! 53 # 4 "implementation/lsfs.h" -! 4 typedef struct lsfs_file lsfs_file; -!BCC_EOS -! 5 # 22 "main.h" -! 22 void dump_ax(input); +! 59 # 24 "main.h" +! 24 void dump_ax(input); !BCC_EOS -! 23 void print_stack(argument); +! 25 void print_stack(argument); !BCC_EOS -! 24 void print_newline(); -!BCC_EOS -! 25 -! 26 typedef struct Directory_Table Directory_Table; -!BCC_EOS -! 27 typedef struct Struct_Table_Entry Table_Entry; +! 26 void print_newline(); !BCC_EOS +! 27 ! 28 typedef struct struct_partition_control partition_control; !BCC_EOS ! 29 typedef struct File_System_Control_Information FSCI; @@ -1323,288 +1441,1606 @@ ret ! 32 typedef struct Parameter_Struct Parameter_Struct; !BCC_EOS ! 33 -! 34 typedef enum Table_Entry_Kind -! 35 { -! 36 -! 37 ENTRY_EMPTY = 0, -! 38 ENTRY_FILE = 1, -! 39 ENTRY_DIRECTORY = 2, -! 40 } Table_Entry_Kind; -!BCC_EOS +! 34 +! 35 typedef enum Service_Action +! 36 { +! 37 SERIVCE_LOAD_DISK = 1, +! 38 SERVICE_FIND_ENTRY = 2, +! 39 SERIVCE_READ_DATA = 3, +! 40 SERIVCE_WRITE_DATA = 4, ! 41 -! 42 typedef enum Service_Action -! 43 { -! 44 SERIVCE_LOAD_DISK = 1, -! 45 SERVICE_FIND_ENTRY = 2, -! 46 SERIVCE_READ_DATA = 3, -! 47 SERIVCE_WRITE_DATA = 4, -! 48 -! 49 } Service_Action; +! 42 } Service_Action; !BCC_EOS -! 50 -! 51 struct Struct_Table_Entry -! 52 { -! 53 char filename[256]; +! 43 +! 44 struct File_System_Control_Information +! 45 { +! 46 char filesystem_information[256]; !BCC_EOS -! 54 long file_id[2]; +! 47 long master_table_index[2]; !BCC_EOS -! 55 long file_size[2]; +! 48 long this_partition_offset_on_disk[2]; !BCC_EOS -! 56 void* ext_file_data_low; +! 49 long next_free_sector[2]; !BCC_EOS -! 57 void* ext_file_data_high; +! 50 long +! 50 next_uniqe_id[2]; !BCC_EOS -! 58 long number_sector_s; +! 51 long next_sector_reuse_pointer[2]; !BCC_EOS -! 59 short entry_kind; +! 52 long last_sector_index_on_partition[2]; !BCC_EOS -! 60 short extra_control_bits1; +! 53 long maximum_sectors_on_disk[2]; !BCC_EOS -! 61 short extra_control_bits2; +! 54 long sector_size_on_disk[2]; !BCC_EOS -! 62 short extra_control_bits3; +! 55 long not_used[48]; !BCC_EOS -! 63 long table_entry_sector_index[2]; +! 56 +! 57 }; !BCC_EOS -! 64 long data_pointer[27 * 2]; +! 58 +! 59 +! 60 struct Parameter_Struct +! 61 { +! 62 char* path; !BCC_EOS -! 65 }; +! 63 char* new_path; !BCC_EOS -! 66 -! 67 struct File_Syst -! 67 em_Control_Information -! 68 { -! 69 char filesystem_information[256]; +! 64 int buffer_segment; !BCC_EOS -! 70 long master_table_index[2]; +! 65 int buffer_address; !BCC_EOS -! 71 long this_partition_offset_on_disk[2]; +! 66 int buffer_size; !BCC_EOS -! 72 long next_free_sector[2]; +! 67 int data_length; !BCC_EOS -! 73 long next_uniqe_id[2]; +! 68 int byte_offset_into_file; !BCC_EOS -! 74 long next_sector_reuse_pointer[2]; +! 69 short entry_kind; !BCC_EOS -! 75 long last_sector_index_on_partition[2]; +! 70 }; !BCC_EOS -! 76 long maximum_sectors_on_disk[2]; +! 71 # 6 "implementation/lsfs.h" +! 6 typedef struct lsfs_file lsfs_file; !BCC_EOS -! 77 long sector_size_on_disk[2]; +! 7 typedef struct Directory_Table Directory_Table; !BCC_EOS -! 78 long not_used[48]; +! 8 typedef struct Table_Entry Table_Entry; !BCC_EOS -! 79 -! 80 }; +! 9 +! 10 int lsfs_disk_getattr(find_file, path, fsci); !BCC_EOS -! 81 -! 82 typedef struct Directory_Table -! 83 { -! 84 Table_Entry entries[16 ]; +! 11 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry); !BCC_EOS -! 85 -! 86 }; +! 12 Directory_Table* lsfs_find_directory(path, drop_filename, fsci); !BCC_EOS -! 87 -! 88 struct Parameter_Struct -! 89 { -! 90 char* path; +! 13 +! 14 typedef enum Table_Entry_Kind +! 15 { +! 16 +! 17 ENTRY_EMPTY = 0, +! 18 ENTRY_FILE = 1, +! 19 ENTRY_DIRECTORY = 2, +! 20 } Table_Entry_Kind; !BCC_EOS -! 91 char* new_path; +! 21 +! 22 struct Table_Entry +! 23 { +! 24 char filename[256]; !BCC_EOS -! 92 int buffer_segment; +! 25 unsigned long file_id[2]; !BCC_EOS -! 93 int buffer_address; +! 26 unsigned long file_size[2]; !BCC_EOS -! 94 int buffer_size; +! 27 void* ext_file_data_low; !BCC_EOS -! 95 int data_length; +! 28 void* ext_file_data_high; !BCC_EOS -! 96 int byte_offset_into_file; +! 29 long number_sector_s; !BCC_EOS -! 97 Table_Entry_Kind entry_kind; +! 30 short entry_kind; !BCC_EOS -! 98 }; +! 31 short extra_control_bits1; !BCC_EOS -! 99 # 7 "main.c" -! 7 int main(selector, pointer_parameter_segment, pointer_parameter_struct) -! 8 int selector; -export _main -_main: +! 32 short extra_control_bits2; !BCC_EOS -! 9 void* pointer_parameter_segment; +! 33 short extra_control_bits3; !BCC_EOS -! 10 void* pointer_parameter_struct; +! 34 long table_entry_sector_index[2]; !BCC_EOS -! 11 { -! 12 -! 13 -! 14 -! 15 FSCI fsci; +! 35 long data_pointer[27 * 2]; !BCC_EOS -! 16 -! 17 Service_Action service_action; +! 36 }; !BCC_EOS -! 18 Directory_Table current_table; +! 37 +! 38 struct lsfs_file { +! 39 unsigned long file_id[2]; !BCC_EOS -! 19 Parameter_Struct parameter_struct; +! 40 long table_entry_pointer[2]; !BCC_EOS -! 20 int local_segment = 0x7e0; +! 41 Table_Entry_Kind entry_kind; +!BCC_EOS +! 42 char* filename; +!BCC_EOS +! 43 long owner_id; +!BCC_EOS +! 44 unsigned long size[2]; +!BCC_EOS +! 45 long creation_date[2]; +!BCC_EOS +! 46 long access_time[2]; +!BCC_EOS +! 47 long modification_time[2]; +!BCC_EOS +! 48 long number_sector; +!BCC_EOS +! 49 long table_entry_sector_index[2]; +!BCC_EOS +! 50 long data_pointer[27 * 2]; +!BCC_EOS +! 51 }; +!BCC_EOS +! 52 +! 53 struct Directory_Table +! 54 { +! 55 Table_Entry entries[16 ]; +!BCC_EOS +! 56 +! 57 }; +!BCC_EOS +! 58 # 75 +! 75 int lsfs_disk_getattr(find_file, path, fsci) +! 76 lsfs_file* find_file; +export _lsfs_disk_getattr +_lsfs_disk_getattr: +!BCC_EOS +! 77 char *path; +!BCC_EOS +! 78 FSCI *fsci; +!BCC_EOS +! 79 { +! 80 int i; +!BCC_EOS +! 81 String_Array *split_path = string_split_c(path, '/', 0 ); push bp mov bp,sp push di push si -add sp,#-$2214 -! Debug: eq int = const $7E0 to int local_segment = [S+$221A-$221A] (used reg = ) -mov ax,#$7E0 -mov -$2218[bp],ax -!BCC_EOS -! 21 unsigned int heap_start = 0x2000; -dec sp -dec sp -! Debug: eq int = const $2000 to unsigned int heap_start = [S+$221C-$221C] (used reg = ) -mov ax,#$2000 -mov -$221A[bp],ax +add sp,*-4 +! Debug: list int = const 0 (used reg = ) +xor ax,ax +push ax +! Debug: list int = const $2F (used reg = ) +mov ax,*$2F +push ax +! Debug: list * char path = [S+$E+4] (used reg = ) +push 6[bp] +! Debug: func () * struct String_Array = string_split_c+0 (used reg = ) +call _string_split_c +add sp,*6 +! Debug: eq * struct String_Array = ax+0 to * struct String_Array split_path = [S+$A-$A] (used reg = ) +mov -8[bp],ax !BCC_EOS -! 22 unsigned int heap_end = 0xffff; +! 82 Length_String *filename = split_path->strings[split_path->length-1]; dec sp dec sp -! Debug: eq unsigned int = const $FFFF to unsigned int heap_end = [S+$221E-$221E] (used reg = ) -mov ax,#$FFFF -mov -$221C[bp],ax +mov bx,-8[bp] +! Debug: sub int = const 1 to unsigned int = [bx+0] (used reg = ) +mov bx,[bx] +mov si,-8[bp] +! Debug: ptradd unsigned int = bx-1 to * * struct Length_String = [si+2] (used reg = ) +mov ax,bx +dec ax +shl ax,*1 +add ax,2[si] +mov bx,ax +! Debug: eq * struct Length_String = [bx+0] to * struct Length_String filename = [S+$C-$C] (used reg = ) +mov bx,[bx] +mov -$A[bp],bx !BCC_EOS -! 23 int stack_segment = 0x8fc0; +! 83 +! 84 +! 85 Directory_Table *dir_table = lsfs_find_directory(path, 1 , fsc dec sp dec sp -! Debug: eq unsigned int = const $8FC0 to int stack_segment = [S+$2220-$2220] (used reg = ) -mov ax,#$8FC0 -mov -$221E[bp],ax +! 85 i); +! Debug: list * struct File_System_Control_Information fsci = [S+$E+6] (used reg = ) +push 8[bp] +! Debug: list int = const 1 (used reg = ) +mov ax,*1 +push ax +! Debug: list * char path = [S+$12+4] (used reg = ) +push 6[bp] +! Debug: func () * struct Directory_Table = lsfs_find_directory+0 (used reg = ) +call _lsfs_find_directory +add sp,*6 +! Debug: eq * struct Directory_Table = ax+0 to * struct Directory_Table dir_table = [S+$E-$E] (used reg = ) +mov -$C[bp],ax !BCC_EOS -! 24 int path_length; +! 86 +! 87 for (i = 0; i < 16 ; i++) +! Debug: eq int = const 0 to int i = [S+$E-8] (used reg = ) +xor ax,ax +mov -6[bp],ax !BCC_EOS -! 25 long index_as_long; !BCC_EOS -! 26 -! 27 char *local_path = 0; -add sp,*-8 -! Debug: eq int = const 0 to * char local_path = [S+$2228-$2228] (used reg = ) -xor ax,ax -mov -$2226[bp],ax +! 88 { +br .2C +.2D: +! 89 int j; !BCC_EOS -! 28 service_action = selector; -! Debug: eq int selector = [S+$2228+2] to int service_action = [S+$2228-$208] (used reg = ) -mov ax,4[bp] -mov -$206[bp],ax -!BCC_EOS -! 29 -! 30 switch (service_action) -mov ax,-$206[bp] -! 31 { -br .23 -! 32 case SERIVCE_LOAD_DISK: -! 33 { -.24: -! 34 -! 35 -! 36 -! 37 -! 38 index_as_long = pointer_parameter_struct; -! Debug: eq * void pointer_parameter_struct = [S+$2228+6] to long index_as_long = [S+$2228-$2226] (used reg = ) -mov ax,8[bp] -xor bx,bx -mov -$2224[bp],ax -mov -$2222[bp],bx -!BCC_EOS -! 39 disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment); -! Debug: list int stack_segment = [S+$2228-$2220] (used reg = ) -push -$221E[bp] -! Debug: list * struct File_System_Control_Information fsci = S+$222A-$206 (used reg = ) -lea bx,-$204[bp] +! 90 print(dir_table->entries[i].filename); +dec sp +dec sp +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = ) +! Debug: list * char = bx+0 (used reg = ) push bx -! Debug: list int = const 1 (used reg = ) -mov ax,*1 -push ax -! Debug: list long index_as_long = [S+$222E-$2226] (used reg = ) -push -$2222[bp] -push -$2224[bp] -! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) -call _disk_service_read_data_from_disk -add sp,*$A +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp !BCC_EOS -! 40 print("File System has been loaded: "); -! Debug: list * char = .25+0 (used reg = ) -mov bx,#.25 -push bx +! 91 print(filename->chars); +mov bx,-$A[bp] +! Debug: list * char = [bx+4] (used reg = ) +push 4[bx] ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 41 print_newline(); +! 92 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 42 set_heap_settings(heap_start, heap_end); -! Debug: list unsigned int heap_end = [S+$2228-$221E] (used reg = ) -push -$221C[bp] -! Debug: list unsigned int heap_start = [S+$222A-$221C] (used reg = ) -push -$221A[bp] -! Debug: func () int = set_heap_settings+0 (used reg = ) -call _set_heap_settings -add sp,*4 +! 93 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline !BCC_EOS -! 43 print_stack(fsci.filesystem_information); -! Debug: list * char fsci = S+$2228-$206 (used reg = ) -lea bx,-$204[bp] +! 94 print("Size of table_entry: "); +! Debug: list * char = .2E+0 (used reg = ) +mov bx,#.2E push bx -! Debug: func () void = print_stack+0 (used reg = ) -call _print_stack +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp +!BCC_EOS +! 95 dump_ax(sizeof(Table_Entry)); +! Debug: list int = const $200 (used reg = ) +mov ax,#$200 +push ax +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax inc sp inc sp !BCC_EOS -! 44 print_newline(); +! 96 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 45 } break; -br .21 -!BCC_EOS -! 46 case SERVICE_FIND_ENTRY: -! 47 { -.26: -! 48 String_Array *path_array; -!BCC_EOS -! 49 int i; +! 97 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline !BCC_EOS -! 50 memcpy(¶meter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct)); -! Debug: list int = const $10 (used reg = ) -mov ax,*$10 -push ax -! Debug: list * void pointer_parameter_segment = [S+$222E+4] (used reg = ) -push 6[bp] -! Debug: list * void pointer_parameter_struct = [S+$2230+6] (used reg = ) -push 8[bp] -! Debug: list int stack_segment = [S+$2232-$2220] (used reg = ) -push -$221E[bp] -! Debug: list * struct Parameter_Struct parameter_struct = S+$2234-$2218 (used reg = ) -lea bx,-$2216[bp] +! 98 if(strcmp( filename->chars, dir_table->entries[i].filename ) == 0) { +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = ) +! Debug: list * char = bx+0 (used reg = ) +push bx +mov bx,-$A[bp] +! Debug: list * char = [bx+4] (used reg = ) +push 4[bx] +! Debug: func () int = strcmp+0 (used reg = ) +call _strcmp +add sp,*4 +! Debug: logeq int = const 0 to int = ax+0 (used reg = ) +test ax,ax +bne .2F +.30: +! 99 find_file->file_id[0] = dir_table->entries[i].file_id[0]; +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: ptradd int = const 0 to [2] unsigned long = bx+$100 (used reg = ) +! Debug: ptradd int = const 0 to [2] unsigned long find_file = [S+$10+2] (used reg = bx) +mov si,4[bp] +! Debug: eq unsigned long = [bx+$100] to unsigned long = [si+0] (used reg = ) +mov ax,$100[bx] +mov bx,$102[bx] +mov [si],ax +mov 2[si],bx +!BCC_EOS +! 100 find_file->entry_kind = dir_table->entries[i].entry_kind; +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: eq short = [bx+$118] to int = [si+$10] (used reg = ) +mov bx,$118[bx] +mov $10[si],bx +!BCC_EOS +! 101 find_file->table_entry_pointer[0] = i; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+8 (used reg = ) +! Debug: eq int i = [S+$10-8] to long = [bx+8] (used reg = ) +mov ax,-6[bp] +cwd +mov si,dx +mov 8[bx],ax +mov $A[bx],si +!BCC_EOS +! 102 find_file->filename = dir_table->entries[i].filename; +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: eq [$100] char = bx+0 to * char = [si+$12] (used reg = ) +mov $12[si],bx +!BCC_EOS +! 103 find_file->table_entry_sector_index[0] = dir_table->entries[i].table_entry_sector_index; +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +mov si,4[bp] +! Debug: ptradd int = const 0 to [2] long = si+$3C (used reg = bx) +! Debug: eq [2] long = bx+$120 to long = [si+$3C] (used reg = ) +mov ax,bx +add ax,#$120 +xor bx,bx +mov $3C[si],ax +mov $3E[si],bx +!BCC_EOS +! 104 find_file->owner_id = 1; +mov bx,4[bp] +! Debug: eq int = const 1 to long = [bx+$14] (used reg = ) +mov ax,*1 +xor si,si +mov $14[bx],ax +mov $16[bx],si +!BCC_EOS +! 105 find_file->size[0] = dir_table->entries[i].file_size[0]; +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: ptradd int = const 0 to [2] unsigned long = bx+$108 (used reg = ) +mov si,4[bp] +! Debug: ptradd int = const 0 to [2] unsigned long = si+$18 (used reg = bx) +! Debug: eq unsigned long = [bx+$108] to unsigned long = [si+$18] (used reg = ) +mov ax,$108[bx] +mov bx,$10A[bx] +mov $18[si],ax +mov $1A[si],bx +!BCC_EOS +! 106 find_file->creation_date[0] = 0; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$20 (used reg = ) +! Debug: eq int = const 0 to long = [bx+$20] (used reg = ) +xor ax,ax +xor si,si +mov $20[bx],ax +mov $22[bx],si +!BCC_EOS +! 107 find_file->access_time[0] = 0; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$28 (used reg = ) +! Debug: eq int = const 0 to long = [bx+$28] (used reg = ) +xor ax,ax +xor si,si +mov $28[bx],ax +mov $2A[bx],si +!BCC_EOS +! 108 find_file->modification_time[0] = 0; +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$30 (used reg = ) +! Debug: eq int = const 0 to long = [bx+$30] (used reg = ) +xor ax,ax +xor si,si +mov $30[bx],ax +mov $32[bx],si +!BCC_EOS +! 109 dump_ax(dir_table->entries[i].data_pointer[0]); +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: ptradd int = const 0 to [$36] long = bx+$128 (used reg = ) +! Debug: list long = [bx+$128] (used reg = ) +push $12A[bx] +push $128[bx] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 +!BCC_EOS +! 110 +! 111 for (j = 0; j < 27 ; j = j + 2) +! Debug: eq int = const 0 to int j = [S+$10-$10] (used reg = ) +xor ax,ax +mov -$E[bp],ax +!BCC_EOS +!BCC_EOS +! 112 { +jmp .34 +.35: +! 113 find_file->data_pointer[j] = dir_table->entries[i].data_pointer[j]; +! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = ) +mov ax,-6[bp] +mov cx,#$200 +imul cx +add ax,-$C[bp] +mov bx,ax +! Debug: ptradd int j = [S+$10-$10] to [$36] long = bx+$128 (used reg = ) +mov ax,-$E[bp] +shl ax,*1 +shl ax,*1 +add bx,ax +mov si,4[bp] +! Debug: ptradd int j = [S+$10-$10] to [$36] long = si+$44 (used reg = bx) +mov ax,-$E[bp] +shl ax,*1 +shl ax,*1 +add si,ax +! Debug: eq long = [bx+$128] to long = [si+$44] (used reg = ) +mov ax,$128[bx] +mov bx,$12A[bx] +mov $44[si],ax +mov $46[si],bx +!BCC_EOS +! 114 dump_ax(find_file->data_pointer[j]); +mov bx,4[bp] +! Debug: ptradd int j = [S+$10-$10] to [$36] long = bx+$44 (used reg = ) +mov ax,-$E[bp] +shl ax,*1 +shl ax,*1 +add bx,ax +! Debug: list long = [bx+$44] (used reg = ) +push $46[bx] +push $44[bx] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 +!BCC_EOS +! 115 } +! 116 +! 117 +! 118 find_file->number_sector = 1; +.33: +! Debug: add int = const 2 to int j = [S+$10-$10] (used reg = ) +mov ax,-$E[bp] +! Debug: eq int = ax+2 to int j = [S+$10-$10] (used reg = ) +inc ax +inc ax +mov -$E[bp],ax +.34: +! Debug: lt int = const $1B to int j = [S+$10-$10] (used reg = ) +mov ax,-$E[bp] +cmp ax,*$1B +jl .35 +.36: +.32: +mov bx,4[bp] +! Debug: eq int = const 1 to long = [bx+$38] (used reg = ) +mov ax,*1 +xor si,si +mov $38[bx],ax +mov $3A[bx],si +!BCC_EOS +! 119 return 1; +mov ax,*1 +add sp,*$A +pop si +pop di +pop bp +ret +!BCC_EOS +! 120 } +! 121 } +.2F: +inc sp +inc sp +! 122 return 0; +.2B: +! Debug: postinc int i = [S+$E-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +.2C: +! Debug: lt int = const $10 to int i = [S+$E-8] (used reg = ) +mov ax,-6[bp] +cmp ax,*$10 +blt .2D +.37: +.2A: +xor ax,ax +add sp,*8 +pop si +pop di +pop bp +ret +!BCC_EOS +! 123 } +! 124 +! 125 Directory_Table* lsfs_find_directory(path, drop_filename, fsci) +! Register BX SI used in function lsfs_disk_getattr +! 126 char *path; +export _lsfs_find_directory +_lsfs_find_directory: +!BCC_EOS +! 127 short drop_filename; +!BCC_EOS +! 128 FSCI *fsci; +!BCC_EOS +! 129 { +! 130 int number_of_traversal; +!BCC_EOS +! 131 int i, j; +!BCC_EOS +! 132 String_Array *split_path; +!BCC_EOS +! 133 Directory_Table *dir_table = calloc(1, sizeof(Directory_Table)); +push bp +mov bp,sp +push di +push si +add sp,*-$A +! Debug: list int = const $2000 (used reg = ) +mov ax,#$2000 +push ax +! Debug: list int = const 1 (used reg = ) +mov ax,*1 +push ax +! Debug: func () * void = calloc+0 (used reg = ) +call _calloc +add sp,*4 +! Debug: eq * void = ax+0 to * struct Directory_Table dir_table = [S+$10-$10] (used reg = ) +mov -$E[bp],ax +!BCC_EOS +! 134 +! 135 dump_ax(fsci->master_table_index[0]); +mov bx,8[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$100 (used reg = ) +! Debug: list long = [bx+$100] (used reg = ) +push $102[bx] +push $100[bx] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 +!BCC_EOS +! 136 disk_service_read_data_from_disk(fsci->master_table_index[0], (long) 16 , dir_table, 0x7e0); +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * struct Directory_Table dir_table = [S+$12-$10] (used reg = ) +push -$E[bp] +! Debug: list long = const $10 (used reg = ) +mov ax,*$10 +xor bx,bx +push bx +push ax +mov bx,8[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$100 (used reg = ) +! Debug: list long = [bx+$100] (used reg = ) +push $102[bx] +push $100[bx] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$C +!BCC_EOS +! 137 print(dir_table->entries[0].filename); +! Debug: ptradd int = const 0 to [$10] struct Table_Entry dir_table = [S+$10-$10] (used reg = ) +! Debug: cast * char = const 0 to [$100] char dir_table = [S+$10-$10] (used reg = ) +! Debug: list * char dir_table = [S+$10-$10] (used reg = ) +push -$E[bp] +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp +!BCC_EOS +! 138 split_path = string_split_c(path, '/', 0 ); +! Debug: list int = const 0 (used reg = ) +xor ax,ax +push ax +! Debug: list int = const $2F (used reg = ) +mov ax,*$2F +push ax +! Debug: list * char path = [S+$14+2] (used reg = ) +push 4[bp] +! Debug: func () * struct String_Array = string_split_c+0 (used reg = ) +call _string_split_c +add sp,*6 +! Debug: eq * struct String_Array = ax+0 to * struct String_Array split_path = [S+$10-$E] (used reg = ) +mov -$C[bp],ax +!BCC_EOS +! 139 +! 140 number_of_traversal = split_path->length; +mov bx,-$C[bp] +! Debug: eq unsigned int = [bx+0] to int number_of_traversal = [S+$10-8] (used reg = ) +mov bx,[bx] +mov -6[bp],bx +!BCC_EOS +! 141 +! 142 +! 143 if (drop_filename) +mov ax,6[bp] +test ax,ax +je .38 +.39: +! 144 { +! 145 number_of_traversal -= 1; +! Debug: subab int = const 1 to int number_of_traversal = [S+$10-8] (used reg = ) +mov ax,-6[bp] +dec ax +mov -6[bp],ax +!BCC_EOS +! 146 } +! 147 +! 148 +! 149 for (i = 0; i < number_of_traversal; ++i) +.38: +! Debug: eq int = const 0 to int i = [S+$10-$A] (used reg = ) +xor ax,ax +mov -8[bp],ax +!BCC_EOS +!BCC_EOS +! 150 { +br .3C +.3D: +! 151 for (j +! 151 = 0; j < 16 ; ++j) +! Debug: eq int = const 0 to int j = [S+$10-$C] (used reg = ) +xor ax,ax +mov -$A[bp],ax +!BCC_EOS +!BCC_EOS +! 152 { +br .40 +.41: +! 153 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 154 print("New: "); +! Debug: list * char = .42+0 (used reg = ) +mov bx,#.42 +push bx +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp +!BCC_EOS +! 155 print(dir_table->entries[j].filename); +! Debug: ptradd int j = [S+$10-$C] to [$10] struct Table_Entry dir_table = [S+$10-$10] (used reg = ) +mov ax,-$A[bp] +mov cx,#$200 +imul cx +add ax,-$E[bp] +mov bx,ax +! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = ) +! Debug: list * char = bx+0 (used reg = ) +push bx +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp +!BCC_EOS +! 156 print("vs "); +! Debug: list * char = .43+0 (used reg = ) +mov bx,#.43 +push bx +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp +!BCC_EOS +! 157 print(split_path->strings[i]->chars); +mov bx,-$C[bp] +! Debug: ptradd int i = [S+$10-$A] to * * struct Length_String = [bx+2] (used reg = ) +mov ax,-8[bp] +shl ax,*1 +add ax,2[bx] +mov bx,ax +mov bx,[bx] +! Debug: list * char = [bx+4] (used reg = ) +push 4[bx] +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp +!BCC_EOS +! 158 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 159 if (strcmp(dir_table->entries[j].filename, split_path->strings[i]->chars) == 0) +mov bx,-$C[bp] +! Debug: ptradd int i = [S+$10-$A] to * * struct Length_String = [bx+2] (used reg = ) +mov ax,-8[bp] +shl ax,*1 +add ax,2[bx] +mov bx,ax +mov bx,[bx] +! Debug: list * char = [bx+4] (used reg = ) +push 4[bx] +! Debug: ptradd int j = [S+$12-$C] to [$10] struct Table_Entry dir_table = [S+$12-$10] (used reg = ) +mov ax,-$A[bp] +mov cx,#$200 +imul cx +add ax,-$E[bp] +mov bx,ax +! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = ) +! Debug: list * char = bx+0 (used reg = ) +push bx +! Debug: func () int = strcmp+0 (used reg = ) +call _strcmp +add sp,*4 +! Debug: logeq int = const 0 to int = ax+0 (used reg = ) +test ax,ax +jne .44 +.45: +! 160 { +! 161 long index_sector = dir_table->entries[j].data_pointer[0]; +add sp,*-4 +! Debug: ptradd int j = [S+$14-$C] to [$10] struct Table_Entry dir_table = [S+$14-$10] (used reg = ) +mov ax,-$A[bp] +mov cx,#$200 +imul cx +add ax,-$E[bp] +mov bx,ax +! Debug: ptradd int = const 0 to [$36] long = bx+$128 (used reg = ) +! Debug: eq long = [bx+$128] to long index_sector = [S+$14-$14] (used reg = ) +mov ax,$128[bx] +mov bx,$12A[bx] +mov -$12[bp],ax +mov -$10[bp],bx +!BCC_EOS +! 162 +! 163 +! 164 dump_ax(index_sector); +! Debug: list long index_sector = [S+$14-$14] (used reg = ) +push -$10[bp] +push -$12[bp] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 +!BCC_EOS +! 165 disk_service_read_data_from_disk(index_sector, (long) 16 , dir_table, 0x7e0); +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * struct Directory_Table dir_table = [S+$16-$10] (used reg = ) +push -$E[bp] +! Debug: list long = const $10 (used reg = ) +mov ax,*$10 +xor bx,bx +push bx +push ax +! Debug: list long index_sector = [S+$1C-$14] (used reg = ) +push -$10[bp] +push -$12[bp] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$C +!BCC_EOS +! 166 break; +add sp,*4 +jmp .3E +!BCC_EOS +! 167 } +add sp,*4 +! 168 } +.44: +! 169 } +.3F: +! Debug: preinc int j = [S+$10-$C] (used reg = ) +mov ax,-$A[bp] +inc ax +mov -$A[bp],ax +.40: +! Debug: lt int = const $10 to int j = [S+$10-$C] (used reg = ) +mov ax,-$A[bp] +cmp ax,*$10 +blt .41 +.46: +.3E: +! 170 return dir_table; +.3B: +! Debug: preinc int i = [S+$10-$A] (used reg = ) +mov ax,-8[bp] +inc ax +mov -8[bp],ax +.3C: +! Debug: lt int number_of_traversal = [S+$10-8] to int i = [S+$10-$A] (used reg = ) +mov ax,-8[bp] +cmp ax,-6[bp] +blt .3D +.47: +.3A: +mov ax,-$E[bp] +add sp,*$A +pop si +pop di +pop bp +ret +!BCC_EOS +! 171 } +! 172 +! 173 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry, data_segment) +! Register BX used in function lsfs_find_directory +! 174 lsfs_file *file; +export _lsfs_disk_read_data_from_file +_lsfs_disk_read_data_from_file: +!BCC_EOS +! 175 unsigned int buffer_size; +!BCC_EOS +! 176 char *data; +!BCC_EOS +! 177 long offset_to_next_entry; +!BCC_EOS +! 178 unsigned int data_segment; +!BCC_EOS +! 179 { +! 180 unsigned int integer_file_size = file->size[0]; +push bp +mov bp,sp +push di +push si +dec sp +dec sp +mov bx,4[bp] +! Debug: ptradd int = const 0 to [2] unsigned long = bx+$18 (used reg = ) +! Debug: eq unsigned long = [bx+$18] to unsigned int integer_file_size = [S+8-8] (used reg = ) +mov bx,$18[bx] +mov -6[bp],bx +!BCC_EOS +! 181 unsigned int integer_offset = offset_to_next_entry; +dec sp +dec sp +! Debug: eq long offset_to_next_entry = [S+$A+8] to unsigned int integer_offset = [S+$A-$A] (used reg = ) +mov ax,$A[bp] +mov -8[bp],ax +!BCC_EOS +! 182 unsigned int integer_datapointer = 0; +dec sp +dec sp +! Debug: eq int = const 0 to unsigned int integer_datapointer = [S+$C-$C] (used reg = ) +xor ax,ax +mov -$A[bp],ax +!BCC_EOS +! 183 unsigned int data_length = integer_file_size - integer_offset; +dec sp +dec sp +! Debug: sub unsigned int integer_offset = [S+$E-$A] to unsigned int integer_file_size = [S+$E-8] (used reg = ) +mov ax,-6[bp] +sub ax,-8[bp] +! Debug: eq unsigned int = ax+0 to unsigned int data_length = [S+$E-$E] (used reg = ) +mov -$C[bp],ax +!BCC_EOS +! 184 unsigned int amount_read = 0; +dec sp +dec sp +! Debug: eq int = const 0 to unsigned int amount_read = [S+$10-$10] (used reg = ) +xor ax,ax +mov -$E[bp],ax +!BCC_EOS +! 185 unsigned int amount_to_read = 0; +dec sp +dec sp +! Debug: eq int = const 0 to unsigned int amount_to_read = [S+$12-$12] (used reg = ) +xor ax,ax +mov -$10[bp],ax +!BCC_EOS +! 186 unsigned int remaining_offset = offset_to_next_entry; +dec sp +dec sp +! Debug: eq long offset_to_next_entry = [S+$14+8] to unsigned int remaining_offset = [S+$14-$14] (used reg = ) +mov ax,$A[bp] +mov -$12[bp],ax +!BCC_EOS +! 187 void *next_data; +!BCC_EOS +! 188 +! 189 +! 190 +! 191 +! 192 +! 193 int data_pointer_index = 0; +add sp,*-4 +! Debug: eq int = const 0 to int data_pointer_index = [S+$18-$18] (used reg = ) +xor ax,ax +mov -$16[bp],ax +!BCC_EOS +! 194 +! 195 +! 196 +! 197 if (data_length > buffer_size) +! Debug: gt unsigned int buffer_size = [S+$18+4] to unsigned int data_length = [S+$18-$E] (used reg = ) +mov ax,-$C[bp] +cmp ax,6[bp] +jbe .48 +.49: +! 198 { +! 199 data_length = buffer_size; +! Debug: eq unsigned int buffer_size = [S+$18+4] to unsigned int data_length = [S+$18-$E] (used reg = ) +mov ax,6[bp] +mov -$C[bp],ax +!BCC_EOS +! 200 } +! 201 +! 202 while(data_length > 0) +.48: +! 203 { +br .4B +.4C: +! 204 +! 205 if (remaining_offset == 0) +! Debug: logeq int = const 0 to unsigned int remaining_offset = [S+$18-$14] (used reg = ) +mov ax,-$12[bp] +test ax,ax +bne .4D +.4E: +! 206 { +! 207 char *tmp_buffer = calloc(8 , 512 ); +dec sp +dec sp +! Debug: list int = const $200 (used reg = ) +mov ax,#$200 +push ax +! Debug: list int = const 8 (used reg = ) +mov ax,*8 +push ax +! Debug: func () * void = calloc+0 (used reg = ) +call _calloc +add sp,*4 +! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$1A-$1A] (used reg = ) +mov -$18[bp],ax +!BCC_EOS +! 208 +! 209 +! 210 if (data_length < (8 * 512 )) +! Debug: lt int = const $1000 to unsigned int data_length = [S+$1A-$E] (used reg = ) +mov ax,-$C[bp] +cmp ax,#$1000 +jae .4F +.50: +! 211 { +! 212 amount_to_read = data_length; +! Debug: eq unsigned int data_length = [S+$1A-$E] to unsigned int amount_to_read = [S+$1A-$12] (used reg = ) +mov ax,-$C[bp] +mov -$10[bp],ax +!BCC_EOS +! 213 } +! 214 else +! 215 { +jmp .51 +.4F: +! 216 amount_to_read = (8 * 512 ); +! Debug: eq int = const $1000 to unsigned int amount_to_read = [S+$1A-$12] (used reg = ) +mov ax,#$1000 +mov -$10[bp],ax +!BCC_EOS +! 217 } +! 218 +! 219 integer_datapointer = file->data_pointer[data_pointer_index]; +.51: +mov bx,4[bp] +! Debug: ptradd int data_pointer_index = [S+$1A-$18] to [$36] long = bx+$44 (used reg = ) +mov ax,-$16[bp] +shl ax,*1 +shl ax,*1 +add bx,ax +! Debug: eq long = [bx+$44] to unsigned int integer_datapointer = [S+$1A-$C] (used reg = ) +mov bx,$44[bx] +mov -$A[bp],bx +!BCC_EOS +! 220 if (integer_datapointer == 0) +! Debug: logeq int = const 0 to unsigned int integer_datapointer = [S+$1A-$C] (used reg = ) +mov ax,-$A[bp] +test ax,ax +jne .52 +.53: +! 221 { +! 222 break; +inc sp +inc sp +br .4A +!BCC_EOS +! 223 } +! 224 print_newline(); +.52: +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 225 dump_ax(file->data_pointer[data_pointer_index]); +mov bx,4[bp] +! Debug: ptradd int data_pointer_index = [S+$1A-$18] to [$36] long = bx+$44 (used reg = ) +mov ax,-$16[bp] +shl ax,*1 +shl ax,*1 +add bx,ax +! Debug: list long = [bx+$44] (used reg = ) +push $46[bx] +push $44[bx] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 +!BCC_EOS +! 226 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 227 next_data = +! 227 data + amount_read; +! Debug: ptradd unsigned int amount_read = [S+$1A-$10] to * char data = [S+$1A+6] (used reg = ) +mov ax,-$E[bp] +add ax,8[bp] +! Debug: eq * char = ax+0 to * void next_data = [S+$1A-$16] (used reg = ) +mov -$14[bp],ax +!BCC_EOS +! 228 dump_ax(next_data); +! Debug: list * void next_data = [S+$1A-$16] (used reg = ) +push -$14[bp] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +inc sp +inc sp +!BCC_EOS +! 229 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 230 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], (long) 8 , next_data, data_segment); +! Debug: list unsigned int data_segment = [S+$1A+$C] (used reg = ) +push $E[bp] +! Debug: list * void next_data = [S+$1C-$16] (used reg = ) +push -$14[bp] +! Debug: list long = const 8 (used reg = ) +mov ax,*8 +xor bx,bx +push bx +push ax +mov bx,4[bp] +! Debug: ptradd int data_pointer_index = [S+$22-$18] to [$36] long = bx+$44 (used reg = ) +mov ax,-$16[bp] +shl ax,*1 +shl ax,*1 +add bx,ax +! Debug: list long = [bx+$44] (used reg = ) +push $46[bx] +push $44[bx] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$C +!BCC_EOS +! 231 +! 232 +! 233 +! 234 data_length -= amount_to_read; +! Debug: subab unsigned int amount_to_read = [S+$1A-$12] to unsigned int data_length = [S+$1A-$E] (used reg = ) +mov ax,-$C[bp] +sub ax,-$10[bp] +mov -$C[bp],ax +!BCC_EOS +! 235 amount_read += amount_to_read; +! Debug: addab unsigned int amount_to_read = [S+$1A-$12] to unsigned int amount_read = [S+$1A-$10] (used reg = ) +mov ax,-$E[bp] +add ax,-$10[bp] +mov -$E[bp],ax +!BCC_EOS +! 236 data_pointer_index = data_pointer_index + 2; +! Debug: add int = const 2 to int data_pointer_index = [S+$1A-$18] (used reg = ) +mov ax,-$16[bp] +! Debug: eq int = ax+2 to int data_pointer_index = [S+$1A-$18] (used reg = ) +inc ax +inc ax +mov -$16[bp],ax +!BCC_EOS +! 237 +! 238 } +inc sp +inc sp +! 239 else if (remaining_offset < (8 * 512 )) +br .54 +.4D: +! Debug: lt int = const $1000 to unsigned int remaining_offset = [S+$18-$14] (used reg = ) +mov ax,-$12[bp] +cmp ax,#$1000 +bhis .55 +.56: +! 240 { +! 241 char *tmp_buffer = calloc(1, (8 * 512 )); +dec sp +dec sp +! Debug: list int = const $1000 (used reg = ) +mov ax,#$1000 +push ax +! Debug: list int = const 1 (used reg = ) +mov ax,*1 +push ax +! Debug: func () * void = calloc+0 (used reg = ) +call _calloc +add sp,*4 +! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$1A-$1A] (used reg = ) +mov -$18[bp],ax +!BCC_EOS +! 242 +! 243 +! 244 if (data_length < ((8 * 512 ) - remaining_offset) ) +! Debug: sub unsigned int remaining_offset = [S+$1A-$14] to int = const $1000 (used reg = ) +mov ax,#$1000 +sub ax,-$12[bp] +! Debug: lt unsigned int = ax+0 to unsigned int data_length = [S+$1A-$E] (used reg = ) +cmp ax,-$C[bp] +jbe .57 +.58: +! 245 { +! 246 amount_to_read = data_length; +! Debug: eq unsigned int data_length = [S+$1A-$E] to unsigned int amount_to_read = [S+$1A-$12] (used reg = ) +mov ax,-$C[bp] +mov -$10[bp],ax +!BCC_EOS +! 247 } +! 248 else +! 249 { +jmp .59 +.57: +! 250 amount_to_read = ((8 * 512 ) - remaining_offset); +! Debug: sub unsigned int remaining_offset = [S+$1A-$14] to int = const $1000 (used reg = ) +mov ax,#$1000 +sub ax,-$12[bp] +! Debug: eq unsigned int = ax+0 to unsigned int amount_to_read = [S+$1A-$12] (used reg = ) +mov -$10[bp],ax +!BCC_EOS +! 251 } +! 252 +! 253 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], (long) 8 , tmp_buffer, 0x7e0); +.59: +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: list * char tmp_buffer = [S+$1C-$1A] (used reg = ) +push -$18[bp] +! Debug: list long = const 8 (used reg = ) +mov ax,*8 +xor bx,bx +push bx +push ax +mov bx,4[bp] +! Debug: ptradd int data_pointer_index = [S+$22-$18] to [$36] long = bx+$44 (used reg = ) +mov ax,-$16[bp] +shl ax,*1 +shl ax,*1 +add bx,ax +! Debug: list long = [bx+$44] (used reg = ) +push $46[bx] +push $44[bx] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$C +!BCC_EOS +! 254 +! 255 memcpy(data, data_segment, (tmp_buffer + remaining_offset), 0x7e0, amount_to_read); +! Debug: list unsigned int amount_to_read = [S+$1A-$12] (used reg = ) +push -$10[bp] +! Debug: list int = const $7E0 (used reg = ) +mov ax,#$7E0 +push ax +! Debug: ptradd unsigned int remaining_offset = [S+$1E-$14] to * char tmp_buffer = [S+$1E-$1A] (used reg = ) +mov ax,-$12[bp] +add ax,-$18[bp] +! Debug: list * char = ax+0 (used reg = ) +push ax +! Debug: list unsigned int data_segment = [S+$20+$C] (used reg = ) +push $E[bp] +! Debug: list * char data = [S+$22+6] (used reg = ) +push 8[bp] +! Debug: func () void = memcpy+0 (used reg = ) +call _memcpy +add sp,*$A +!BCC_EOS +! 256 data_length -= amount_to_read; +! Debug: subab unsigned int amount_to_read = [S+$1A-$12] to unsigned int data_length = [S+$1A-$E] (used reg = ) +mov ax,-$C[bp] +sub ax,-$10[bp] +mov -$C[bp],ax +!BCC_EOS +! 257 amount_read += amount_to_read; +! Debug: addab unsigned int amount_to_read = [S+$1A-$12] to unsigned int amount_read = [S+$1A-$10] (used reg = ) +mov ax,-$E[bp] +add ax,-$10[bp] +mov -$E[bp],ax +!BCC_EOS +! 258 remaining_offset -= amount_to_read; +! Debug: subab unsigned int amount_to_read = [S+$1A-$12] to unsigned int remaining_offset = [S+$1A-$14] (used reg = ) +mov ax,-$12[bp] +sub ax,-$10[bp] +mov -$12[bp],ax +!BCC_EOS +! 259 +! 260 data_pointer_index = data_pointer_index + 2; +! Debug: add int = const 2 to int data_pointer_index = [S+$1A-$18] (used reg = ) +mov ax,-$16[bp] +! Debug: eq int = ax+2 to int data_pointer_index = [S+$1A-$18] (used reg = ) +inc ax +inc ax +mov -$16[bp],ax +!BCC_EOS +! 261 +! 262 } +inc sp +inc sp +! 263 else +! 264 { +jmp .5A +.55: +! 265 +! 266 remaining_offset -= (8 * 512 ); +! Debug: subab int = const $1000 to unsigned int remaining_offset = [S+$18-$14] (used reg = ) +mov ax,-$12[bp] +add ax,#-$1000 +mov -$12[bp],ax +!BCC_EOS +! 267 data_pointer_index = data_pointer_index + 2; +! Debug: add int = const 2 to int data_pointer_index = [S+$18-$18] (used reg = ) +mov ax,-$16[bp] +! Debug: eq int = ax+2 to int data_pointer_index = [S+$18-$18] (used reg = ) +inc ax +inc ax +mov -$16[bp],ax +!BCC_EOS +! 268 } +! 269 +! 270 } +.5A: +.54: +! 271 # 275 +! 275 +! 276 return amount_read; +.4B: +! Debug: gt int = const 0 to unsigned int data_length = [S+$18-$E] (used reg = ) +mov ax,-$C[bp] +test ax,ax +bne .4C +.5B: +.4A: +mov ax,-$E[bp] +add sp,*$12 +pop si +pop di +pop bp +ret +!BCC_EOS +! 277 +! 278 } +! 279 # 8 "main.c" +! 8 int main(selector, pointer_parameter_segment, pointer_parameter_struct) +! Register BX used in function lsfs_disk_read_data_from_file +! 9 int selector; +export _main +_main: +!BCC_EOS +! 10 void* pointer_parameter_segment; +!BCC_EOS +! 11 void* pointer_parameter_struct; +!BCC_EOS +! 12 { +! 13 +! 14 +! 15 +! 16 +! 17 Service_Action service_action; +!BCC_EOS +! 18 Directory_Table current_table; +!BCC_EOS +! 19 Parameter_Struct parameter_struct; +!BCC_EOS +! 20 int local_segment = 0x7e0; +push bp +mov bp,sp +push di +push si +add sp,#-$2014 +! Debug: eq int = const $7E0 to int local_segment = [S+$201A-$201A] (used reg = ) +mov ax,#$7E0 +mov -$2018[bp],ax +!BCC_EOS +! 21 unsigned int heap_start = 0x2200; +dec sp +dec sp +! Debug: eq int = const $2200 to unsigned int heap_start = [S+$201C-$201C] (used reg = ) +mov ax,#$2200 +mov -$201A[bp],ax +!BCC_EOS +! 22 unsigned int heap_end = 0xffff; +dec sp +dec sp +! Debug: eq unsigned int = const $FFFF to unsigned int heap_end = [S+$201E-$201E] (used reg = ) +mov ax,#$FFFF +mov -$201C[bp],ax +!BCC_EOS +! 23 int stack_segment = 0x8fc0; +dec sp +dec sp +! Debug: eq unsigned int = const $8FC0 to int stack_segment = [S+$2020-$2020] (used reg = ) +mov ax,#$8FC0 +mov -$201E[bp],ax +!BCC_EOS +! 24 int path_length; +!BCC_EOS +! 25 long index_as_long = 0; +add sp,*-6 +! Debug: eq int = const 0 to long index_as_long = [S+$2026-$2026] (used reg = ) +xor ax,ax +xor bx,bx +mov -$2024[bp],ax +mov -$2022[bp],bx +!BCC_EOS +! 26 +! 27 char *local_path = 0; +dec sp +dec sp +! Debug: eq int = const 0 to * char local_path = [S+$2028-$2028] (used reg = ) +xor ax,ax +mov -$2026[bp],ax +!BCC_EOS +! 28 FSCI *fsci = 0x2000; +dec sp +dec sp +! Debug: eq int = const $2000 to * struct File_System_Control_Information fsci = [S+$202A-$202A] (used reg = ) +mov ax,#$2000 +mov -$2028[bp],ax +!BCC_EOS +! 29 service_action = selector; +! Debug: eq int selector = [S+$202A+2] to int service_action = [S+$202A-8] (used reg = ) +mov ax,4[bp] +mov -6[bp],ax +!BCC_EOS +! 30 +! 31 switch (service_action) +mov ax,-6[bp] +! 32 { +br .5E +! 33 case SERIV +! 33 CE_LOAD_DISK: +! 34 { +.5F: +! 35 +! 36 +! 37 +! 38 +! 39 set_heap_settings(heap_start, heap_end); +! Debug: list unsigned int heap_end = [S+$202A-$201E] (used reg = ) +push -$201C[bp] +! Debug: list unsigned int heap_start = [S+$202C-$201C] (used reg = ) +push -$201A[bp] +! Debug: func () int = set_heap_settings+0 (used reg = ) +call _set_heap_settings +add sp,*4 +!BCC_EOS +! 40 index_as_long = pointer_parameter_struct; +! Debug: eq * void pointer_parameter_struct = [S+$202A+6] to long index_as_long = [S+$202A-$2026] (used reg = ) +mov ax,8[bp] +xor bx,bx +mov -$2024[bp],ax +mov -$2022[bp],bx +!BCC_EOS +! 41 disk_service_read_data_from_disk(index_as_long, (long) 1, fsci, local_segment); +! Debug: list int local_segment = [S+$202A-$201A] (used reg = ) +push -$2018[bp] +! Debug: list * struct File_System_Control_Information fsci = [S+$202C-$202A] (used reg = ) +push -$2028[bp] +! Debug: list long = const 1 (used reg = ) +mov ax,*1 +xor bx,bx +push bx +push ax +! Debug: list long index_as_long = [S+$2032-$2026] (used reg = ) +push -$2022[bp] +push -$2024[bp] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$C +!BCC_EOS +! 42 print("File System has been loaded: "); +! Debug: list * char = .60+0 (used reg = ) +mov bx,#.60 +push bx +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp +!BCC_EOS +! 43 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 44 print(fsci->filesystem_information); +! Debug: cast * char = const 0 to [$100] char fsci = [S+$202A-$202A] (used reg = ) +! Debug: list * char fsci = [S+$202A-$202A] (used reg = ) +push -$2028[bp] +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp +!BCC_EOS +! 45 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 46 dump_ax(fsci->master_table_index[0]); +mov bx,-$2028[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$100 (used reg = ) +! Debug: list long = [bx+$100] (used reg = ) +push $102[bx] +push $100[bx] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 +!BCC_EOS +! 47 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 48 } break; +br .5C +!BCC_EOS +! 49 case SERVICE_FIND_ENTRY: +! 50 { +.61: +! 51 String_Array *path_array; +!BCC_EOS +! 52 lsfs_file* find_file; +!BCC_EOS +! 53 int i; +!BCC_EOS +! 54 dump_ax(fsci->master_table_index[0]); +mov bx,-$2028[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$100 (used reg = ) +! Debug: list long = [bx+$100] (used reg = ) +push $102[bx] +push $100[bx] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 +!BCC_EOS +! 55 disk_service_read_data_from_disk(fsci->master_table_index[0], (long) 16 , ¤t_table, stack_segment); +! Debug: list int stack_segment = [S+$2030-$2020] (used reg = ) +push -$201E[bp] +! Debug: list * struct Directory_Table current_table = S+$2032-$2008 (used reg = ) +lea bx,-$2006[bp] +push bx +! Debug: list long = const $10 (used reg = ) +mov ax,*$10 +xor bx,bx +push bx +push ax +mov bx,-$2028[bp] +! Debug: ptradd int = const 0 to [2] long = bx+$100 (used reg = ) +! Debug: list long = [bx+$100] (used reg = ) +push $102[bx] +push $100[bx] +! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) +call _disk_service_read_data_from_disk +add sp,*$C +!BCC_EOS +! 56 print("Current table: "); +! Debug: list * char = .62+0 (used reg = ) +mov bx,#.62 +push bx +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp +!BCC_EOS +! 57 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 58 print_stack(current_table.entries[0].filename); +! Debug: list * char current_table = S+$2030-$2008 (used reg = ) +lea bx,-$2006[bp] +push bx +! Debug: func () void = print_stack+0 (used reg = ) +call _print_stack +inc sp +inc sp +!BCC_EOS +! 59 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 60 print_stack(current_table.entries[1].filename); +! Debug: list * char current_table = S+$2030-$1E08 (used reg = ) +lea bx,-$1E06[bp] +push bx +! Debug: func () void = print_stack+0 (used reg = ) +call _print_stack +inc sp +inc sp +!BCC_EOS +! 61 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 62 print_stack(current_table.entries[2].filename); +! Debug: list * char current_table = S+$2030-$1C08 (used reg = ) +lea bx,-$1C06[bp] +push bx +! Debug: func () void = print_stack+0 (used reg = ) +call _print_stack +inc sp +inc sp +!BCC_EOS +! 63 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 64 +! 65 +! 66 memcpy(¶meter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct)); +! Debug: list int = const $10 (used reg = ) +mov ax,*$10 +push ax +! Debug: list * void pointer_parameter_segment = [S+$2032+4] (used reg = ) +push 6[bp] +! Debug: list * void pointer_parameter_struct = [S+$2034+6] (used reg = ) +push 8[bp] +! Debug: list int stack_segment = [S+$2036-$2020] (used reg = ) +push -$201E[bp] +! Debug: list * struct Parameter_Struct parameter_struct = S+$2038-$2018 (used reg = ) +lea bx,-$2016[bp] push bx ! Debug: func () void = memcpy+0 (used reg = ) call _memcpy add sp,*$A !BCC_EOS -! 51 path_length = strlen(parameter_struct.path, pointer_parameter_segment); -! Debug: list * void pointer_parameter_segment = [S+$222C+4] (used reg = ) +! 67 path_length = strlen(parameter_struct.path, pointer_parameter_segment); +! Debug: list * void pointer_parameter_segment = [S+$2030+4] (used reg = ) push 6[bp] -! Debug: list * char parameter_struct = [S+$222E-$2218] (used reg = ) -push -$2216[bp] +! Debug: list * char parameter_struct = [S+$2032-$2018] (used reg = ) +push -$2016[bp] ! Debug: func () int = strlen+0 (used reg = ) call _strlen add sp,*4 -! Debug: eq int = ax+0 to int path_length = [S+$222C-$2222] (used reg = ) -mov -$2220[bp],ax +! Debug: eq int = ax+0 to int path_length = [S+$2030-$2022] (used reg = ) +mov -$2020[bp],ax +!BCC_EOS +! 68 dump_ax(path_length); +! Debug: list int path_length = [S+$2030-$2022] (used reg = ) +push -$2020[bp] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +inc sp +inc sp !BCC_EOS -! 52 local_path = malloc(256); +! 69 local_path = malloc(256); ! Debug: list int = const $100 (used reg = ) mov ax,#$100 push ax @@ -1612,80 +3048,79 @@ push ax call _malloc inc sp inc sp -! Debug: eq * void = ax+0 to * char local_path = [S+$222C-$2228] (used reg = ) -mov -$2226[bp],ax +! Debug: eq * void = ax+0 to * char local_path = [S+$2030-$2028] (used reg = ) +mov -$2026[bp],ax !BCC_EOS -! 53 -! 53 memcpy(local_path, local_segment, parameter_struct.path, pointer_parameter_segment, path_length); -! Debug: list int path_length = [S+$222C-$2222] (used reg = ) -push -$2220[bp] -! Debug: list * void pointer_parameter_segment = [S+$222E+4] (used reg = ) +! 70 memcpy(local_path, local_segment, parameter_struct.path, pointer_parameter_segment, path_length); +! Debug: list int path_length = [S+$2030-$2022] (used reg = ) +push -$2020[bp] +! Debug: list * void pointer_parameter_segment = [S+$2032+4] (used reg = ) push 6[bp] -! Debug: list * char parameter_struct = [S+$2230-$2218] (used reg = ) -push -$2216[bp] -! Debug: list int local_segment = [S+$2232-$221A] (used reg = ) -push -$2218[bp] -! Debug: list * char local_path = [S+$2234-$2228] (used reg = ) -push -$2226[bp] +! Debug: list * char parameter_struct = [S+$2034-$2018] (used reg = ) +push -$2016[bp] +! Debug: list int local_segment = [S+$2036-$201A] (used reg = ) +push -$2018[bp] +! Debug: list * char local_path = [S+$2038-$2028] (used reg = ) +push -$2026[bp] ! Debug: func () void = memcpy+0 (used reg = ) call _memcpy add sp,*$A !BCC_EOS -! 54 local_path[path_length] = 0; -! Debug: ptradd int path_length = [S+$222C-$2222] to * char local_path = [S+$222C-$2228] (used reg = ) -mov ax,-$2220[bp] -add ax,-$2226[bp] +! 71 local_path[path_length] = 0; +! Debug: ptradd int path_length = [S+$2030-$2022] to * char local_path = [S+$2030-$2028] (used reg = ) +mov ax,-$2020[bp] +add ax,-$2026[bp] mov bx,ax ! Debug: eq int = const 0 to char = [bx+0] (used reg = ) xor al,al mov [bx],al !BCC_EOS -! 55 print(local_path); -! Debug: list * char local_path = [S+$222C-$2228] (used reg = ) -push -$2226[bp] +! 72 print(local_path); +! Debug: list * char local_path = [S+$2030-$2028] (used reg = ) +push -$2026[bp] ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 56 -! 57 path_array = string_split_c(local_path, '/', 0); +! 73 +! 74 path_array = string_split_c(local_path, '/', 0); ! Debug: list int = const 0 (used reg = ) xor ax,ax push ax ! Debug: list int = const $2F (used reg = ) mov ax,*$2F push ax -! Debug: list * char local_path = [S+$2230-$2228] (used reg = ) -push -$2226[bp] +! Debug: list * char local_path = [S+$2034-$2028] (used reg = ) +push -$2026[bp] ! Debug: func () * struct String_Array = string_split_c+0 (used reg = ) call _string_split_c add sp,*6 -! Debug: eq * struct String_Array = ax+0 to * struct String_Array path_array = [S+$222C-$222A] (used reg = ) -mov -$2228[bp],ax +! Debug: eq * struct String_Array = ax+0 to * struct String_Array path_array = [S+$2030-$202C] (used reg = ) +mov -$202A[bp],ax !BCC_EOS -! 58 -! 59 print_newline(); +! 75 +! 76 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 60 print_newline(); +! 77 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 61 for (i = 0; i < path_array->length; ++i) -! Debug: eq int = const 0 to int i = [S+$222C-$222C] (used reg = ) +! 78 for (i = 0; i < path_array->length; ++i) +! Debug: eq int = const 0 to int i = [S+$2030-$2030] (used reg = ) xor ax,ax -mov -$222A[bp],ax +mov -$202E[bp],ax !BCC_EOS !BCC_EOS -! 62 { -jmp .29 -.2A: -! 63 print(path_array->strings[i]->chars); -mov bx,-$2228[bp] -! Debug: ptradd int i = [S+$222C-$222C] to * * struct Length_String = [bx+2] (used reg = ) -mov ax,-$222A[bp] +! 79 { +jmp .65 +.66: +! 80 print(path_array->strings[i]->chars); +mov bx,-$202A[bp] +! Debug: ptradd int i = [S+$2030-$2030] to * * struct Length_String = [bx+2] (used reg = ) +mov ax,-$202E[bp] shl ax,*1 add ax,2[bx] mov bx,ax @@ -1697,172 +3132,239 @@ call _print inc sp inc sp !BCC_EOS -! 64 print_newline(); +! 81 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 65 } -! 66 print_newline(); -.28: -! Debug: preinc int i = [S+$222C-$222C] (used reg = ) -mov ax,-$222A[bp] +! 82 } +! 83 print_newline(); +.64: +! Debug: preinc int i = [S+$2030-$2030] (used reg = ) +mov ax,-$202E[bp] inc ax -mov -$222A[bp],ax -.29: -mov bx,-$2228[bp] -! Debug: lt unsigned int = [bx+0] to int i = [S+$222C-$222C] (used reg = ) -mov ax,-$222A[bp] +mov -$202E[bp],ax +.65: +mov bx,-$202A[bp] +! Debug: lt unsigned int = [bx+0] to int i = [S+$2030-$2030] (used reg = ) +mov ax,-$202E[bp] cmp ax,[bx] -jb .2A -.2B: -.27: +jb .66 +.67: +.63: ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 67 print_newline(); +! 84 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 68 -! 69 print_newline(); +! 85 +! 86 find_file = calloc(sizeof(lsfs_file), 1); +! Debug: list int = const 1 (used reg = ) +mov ax,*1 +push ax +! Debug: list int = const $11C (used reg = ) +mov ax,#$11C +push ax +! Debug: func () * void = calloc+0 (used reg = ) +call _calloc +add sp,*4 +! Debug: eq * void = ax+0 to * struct lsfs_file find_file = [S+$2030-$202E] (used reg = ) +mov -$202C[bp],ax +!BCC_EOS +! 87 lsf +! 87 s_disk_getattr(find_file, local_path, fsci); +! Debug: list * struct File_System_Control_Information fsci = [S+$2030-$202A] (used reg = ) +push -$2028[bp] +! Debug: list * char local_path = [S+$2032-$2028] (used reg = ) +push -$2026[bp] +! Debug: list * struct lsfs_file find_file = [S+$2034-$202E] (used reg = ) +push -$202C[bp] +! Debug: func () int = lsfs_disk_getattr+0 (used reg = ) +call _lsfs_disk_getattr +add sp,*6 +!BCC_EOS +! 88 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 70 disk_service_read_data_from_disk(fsci.master_table_index[0], 16 , ¤t_table, stack_segment); -! Debug: list int stack_segment = [S+$222C-$2220] (used reg = ) -push -$221E[bp] -! Debug: list * struct Directory_Table current_table = S+$222E-$2208 (used reg = ) -lea bx,-$2206[bp] +! 89 print("Loding SingOS kernel: "); +! Debug: list * char = .68+0 (used reg = ) +mov bx,#.68 push bx -! Debug: list int = const $10 (used reg = ) -mov ax,*$10 -push ax -! Debug: list long fsci = [S+$2232-$106] (used reg = ) -push -$102[bp] -push -$104[bp] -! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) -call _disk_service_read_data_from_disk -add sp,*$A +! Debug: func () void = print+0 (used reg = ) +call _print +inc sp +inc sp !BCC_EOS -! 71 print("Current table: "); -! Debug: list * char = .2C+0 (used reg = ) -mov bx,#.2C -push bx +! 90 print(find_file->filename); +mov bx,-$202C[bp] +! Debug: list * char = [bx+$12] (used reg = ) +push $12[bx] ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 72 print_newline(); +! 91 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 73 print_stack(current_table.entries[0].filename); -! Debug: list * char current_table = S+$222C-$2208 (used reg = ) -lea bx,-$2206[bp] +! 92 print("Kernel file id: "); +! Debug: list * char = .69+0 (used reg = ) +mov bx,#.69 push bx -! Debug: func () void = print_stack+0 (used reg = ) -call _print_stack +! Debug: func () void = print+0 (used reg = ) +call _print inc sp inc sp !BCC_EOS -! 74 print_newline(); +! 93 dump_ax(find_file->file_id[0]); +! Debug: ptradd int = const 0 to [2] unsigned long find_file = [S+$2030-$202E] (used reg = ) +mov bx,-$202C[bp] +! Debug: list unsigned long = [bx+0] (used reg = ) +push 2[bx] +push [bx] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 +!BCC_EOS +! 94 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 75 print_stack(current_table.entries[1].filename); -! Debug: list * char current_table = S+$222C-$2008 (used reg = ) -lea bx,-$2006[bp] +! 95 print("Kernel file size: "); +! Debug: list * char = .6A+0 (used reg = ) +mov bx,#.6A push bx -! Debug: func () void = print_stack+0 (used reg = ) -call _print_stack +! Debug: func () void = print+0 (used reg = ) +call _print inc sp inc sp !BCC_EOS -! 76 print_newline(); +! 96 dump_ax(find_file->size[0]); +mov bx,-$202C[bp] +! Debug: ptradd int = const 0 to [2] unsigned long = bx+$18 (used reg = ) +! Debug: list unsigned long = [bx+$18] (used reg = ) +push $1A[bx] +push $18[bx] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 +!BCC_EOS +! 97 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 77 print_stack(current_table.entries[2].filename); -! Debug: list * char current_table = S+$222C-$1E08 (used reg = ) -lea bx,-$1E06[bp] +! 98 print("Kernel first data pointer: "); +! Debug: list * char = .6B+0 (used reg = ) +mov bx,#.6B push bx -! Debug: func () void = print_stack+0 (used reg = ) -call _print_stack +! Debug: func () void = print+0 (used reg = ) +call _print inc sp inc sp !BCC_EOS -! 78 print_newline(); -! Debug: func () void = print_newline+0 (used reg = ) -call _print_newline +! 99 dump_ax(find_file->data_pointer[0]); +mov bx,-$202C[bp] +! Debug: ptradd int = const 0 to [$36] long = bx+$44 (used reg = ) +! Debug: list long = [bx+$44] (used reg = ) +push $46[bx] +push $44[bx] +! Debug: func () void = dump_ax+0 (used reg = ) +call _dump_ax +add sp,*4 !BCC_EOS -! 79 -! 80 } break; -jmp .21 +! 100 +! 101 lsfs_disk_read_data_from_file(find_file, 0xffff, 0x00, (long) 0x0, 0x50); +! Debug: list int = const $50 (used reg = ) +mov ax,*$50 +push ax +! Debug: list long = const 0 (used reg = ) +xor ax,ax +xor bx,bx +push bx +push ax +! Debug: list int = const 0 (used reg = ) +xor ax,ax +push ax +! Debug: list unsigned int = const $FFFF (used reg = ) +mov ax,#$FFFF +push ax +! Debug: list * struct lsfs_file find_file = [S+$203A-$202E] (used reg = ) +push -$202C[bp] +! Debug: func () int = lsfs_disk_read_data_from_file+0 (used reg = ) +call _lsfs_disk_read_data_from_file +add sp,*$C !BCC_EOS -! 81 case SERIVCE_READ_DATA: -! 82 { -.2D: -! 83 # 91 -! 91 -! 92 print("Hit READ case"); -! Debug: list * char = .2E+0 (used reg = ) -mov bx,#.2E +! 102 +! 103 +! 104 } break; +jmp .5C +!BCC_EOS +! 105 case SERIVCE_READ_DATA: +! 106 { +.6C: +! 107 # 115 +! 115 +! 116 print("Hit READ case"); +! Debug: list * char = .6D+0 (used reg = ) +mov bx,#.6D push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 93 } break; -jmp .21 +! 117 } break; +jmp .5C !BCC_EOS -! 94 case SERIVCE_WRITE_DATA: -! 95 { -.2F: -! 96 print("Hit WRITE case"); -! Debug: list * char = .30+0 (used reg = ) -mov bx,#.30 +! 118 case SERIVCE_WRITE_DATA: +! 119 { +.6E: +! 120 print("Hit WRITE case"); +! Debug: list * char = .6F+0 (used reg = ) +mov bx,#.6F push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 97 } break; -jmp .21 +! 121 } break; +jmp .5C !BCC_EOS -! 98 default: -! 99 { -.31: -! 100 print("Default case"); -! Debug: list * char = .32+0 (used reg = ) -mov bx,#.32 +! 122 default: +! 123 { +.70: +! 124 print("Default case"); +! Debug: list * char = .71+0 (used reg = ) +mov bx,#.71 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 101 } -! 102 } -! 103 -! 104 return 0; -jmp .21 -.23: -add sp,*-4 +! 125 } +! 126 } +! 127 +! 128 return 0; +jmp .5C +.5E: +add sp,*-6 sub ax,*1 -beq .24 +beq .5F sub ax,*1 -beq .26 +beq .61 sub ax,*1 -je .2D +je .6C sub ax,*1 -je .2F -jmp .31 -.21: -..FFFF = -$222C -add sp,*4 +je .6E +jmp .70 +.5C: +..FFFF = -$2030 +add sp,*6 xor ax,ax lea sp,-4[bp] pop si @@ -1870,30 +3372,58 @@ pop di pop bp ret !BCC_EOS -! 105 -! 106 } -! 107 +! 129 +! 130 } +! 131 ! Register BX used in function main -.32: -.33: +.71: +.72: .ascii "Default case" .byte 0 -.30: -.34: +.6F: +.73: .ascii "Hit WRITE case" .byte 0 -.2E: -.35: +.6D: +.74: .ascii "Hit READ case" .byte 0 -.2C: -.36: +.6B: +.75: +.ascii "Kernel first data pointer: " +.byte 0 +.6A: +.76: +.ascii "Kernel file size: " +.byte 0 +.69: +.77: +.ascii "Kernel file id: " +.byte 0 +.68: +.78: +.ascii "Loding SingOS kernel: " +.byte 0 +.62: +.79: .ascii "Current table: " .byte 0 -.25: -.37: +.60: +.7A: .ascii "File System has been loaded: " .byte 0 +.43: +.7B: +.ascii "vs " +.byte 0 +.42: +.7C: +.ascii "New: " +.byte 0 +.2E: +.7D: +.ascii "Size of table_entry: " +.byte 0 .bss ! 0 errors detected diff --git a/std_singos/string.h b/std_singos/string.h index 6a6fbca..31247aa 100644 --- a/std_singos/string.h +++ b/std_singos/string.h @@ -165,6 +165,64 @@ int num_bytes; #endasm } +int strcmp(source_1, source_2) +char* source_1; +char* source_2; +{ + int i; + int count; + + count = strlen(source_1, 0x7e0); + if (count != strlen(source_2, 0x7e0)) + { + return -1; + } + + + for (i = 0; i < count; i++) + { + if(source_1[i] != source_2[i]) + { + return -1; + } + } + + return 0; + /* + #asm + #define DESTINATION 4[bp]; + #define DESTINATION_SEGMENT 6[bp]; + #define SOURCE 8[bp]; + #define SOURCE_SEGMENT 10[bp]; + ; Compares two strings + ; IN si: the first (zero terminated) string + ; IN di: the second (zero terminated) string + ; OUT SF and ZF (same semantics as cmp) + strcmp_stringcompare: + push bx + push si + push di + .strcmp_loop: + mov bl, [si] + mov bh, [di] + cmp bl, bh + jne .strcmp_end + test bl, bl ; bl and bh are the same, so bl = 0 => dl = 0 + jz .strcmp_end + inc si + inc di + jmp .strcmp_loop + .strcmp_end: + pop di + pop si + pop bx + + ret + + #endasm + */ +} + String_Array *string_split_c(string, delim, keep_delim) char *string; char delim;