push bp mov bp,sp push 8[bp] push 6[bp] call _main add sp, #0x4 pop bp retf ! 1 ! 1 # 1 "main.c" ! 1 # 1 "std_singos/string.h" ! 1 void strcpy (destination, destination_segment, source, source_segment ); !BCC_EOS ! 2 ! 3 void strcpy (destination, destination_segment, source, source_segment ) ! 4 char *destination; export _strcpy _strcpy: !BCC_EOS ! 5 int destination_segment; !BCC_EOS ! 6 char *source; !BCC_EOS ! 7 int source_segment; !BCC_EOS ! 8 { ! 9 #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) ! 15 19 push bp mov bp,sp stringcompare: 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 .loop: movsb cmp cx, 0x0 je .end dec cx jmp .loop .end: pop ds pop si pop es pop di pop bx pop ax pop bp ! 53 endasm !BCC_ENDASM ! 54 } ret ! 55 # 1 "driver/disk.h" ! 1 int data_from_disk(index, 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; 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 # 10 "main.c" ! 10 #define SPACE_VBR_RECORD 2048 ! 11 ! 12 #define DEFAULT_ENTRY_SIZE 1 ! 13 ! 14 #define NUMBER_OF_MBR_PARTITIONS 4 ! 15 ! 16 #define DEFAULT_DATA_POINTER_SIZE 4 ! 17 ! 18 ! 19 ! 20 void dump_ax(input); !BCC_EOS ! 21 void print_stack(argument); !BCC_EOS ! 22 void print_newline(); !BCC_EOS ! 23 ! 24 typedef struct Directory_Table Directory_Table; !BCC_EOS ! 25 typedef struct Struct_Table_Entry Table_Entry; !BCC_EOS ! 26 typedef struct struct_partition_control partition_control; !BCC_EOS ! 27 typedef struct File_System_Control_Information FSCI; !BCC_EOS ! 28 typedef struct meta_information_format mif; !BCC_EOS ! 29 typedef struct tag_record tag_record; !BCC_EOS ! 30 typedef struct lsfs_file lsfs_file; !BCC_EOS ! 31 ! 32 typedef enum Table_Entry_Kind ! 33 { ! 34 ! 35 ENTRY_EMPTY = 0, ! 36 ENTRY_FILE = 1, ! 37 ENTRY_DIRECTORY = 2, ! 38 } Table_Entry_Kind; !BCC_EOS ! 39 ! 40 typedef enum Service_Action ! 41 { ! 42 SERIVCE_LOAD_DISK = 1, ! 43 SERVICE_FIND_ENTRY = 2, ! 44 SERIVCE_READ_DATA = 3, ! 45 SERIVCE_WRITE_DATA = 4, ! 46 ! 47 } Service_Action; !BCC_EOS ! 48 ! 49 int number_low; !BCC_EOS ! 50 int selector; !BCC_EOS ! 51 ! 52 struct Struct_Table_Entry ! 53 { ! 54 char filename[256]; !BCC_EOS ! 55 long file_id[2]; !BCC_EOS ! 56 long file_size[2]; !BCC_EOS ! 57 void* ext_file_data_low; !BCC_EOS ! 58 void* ext_file_data_high; !BCC_EOS ! 59 long number_sector_s; !BCC_EOS ! 60 short entry_kind; !BCC_EOS ! 61 short extra_control_bits1; !BCC_EOS ! 62 short extra_control_bits2; !BCC_EOS ! 63 short extra_control_bits3; !BCC_EOS ! 64 long table_entry_sector_index[2]; !BCC_EOS ! 65 long data_pointer[27 * 2]; !BCC_EOS ! 66 }; !BCC_EOS ! 67 ! 68 struct File_System_Control_Information ! 69 { ! 70 char filesystem_information[256]; !BCC_EOS ! 71 long master_table_index[2]; !BCC_EOS ! 72 long this_partition_offset_on_disk[2]; !BCC_EOS ! 73 long next_free_sector[2]; !BCC_EOS ! 74 long next_uniqe_id[2]; !BCC_EOS ! 75 long next_sector_reuse_pointer[2]; !BCC_EOS ! 76 long last_sector_index_on_partition[2]; !BCC_EOS ! 77 long maximum_sectors_on_disk[2]; !BCC_EOS ! 78 long sector_size_on_disk[2]; !BCC_EOS ! 79 long not_used[48]; !BCC_EOS ! 80 ! 81 }; !BCC_EOS ! 82 ! 83 typedef struct Directory_Table ! 84 { ! 85 Table_Entry entries[16 ]; !BCC_EOS ! 86 ! 87 }; !BCC_EOS ! 88 ! 89 ! 90 void print(string); !BCC_EOS ! 91 ! 92 int main(selector, parameter_struct) ! 93 int selector; export _main _main: !BCC_EOS ! 94 void* parameter ! 94 _struct; !BCC_EOS ! 95 { ! 96 ! 97 ! 98 ! 99 FSCI fsci; !BCC_EOS ! 100 Service_Action service_action; !BCC_EOS ! 101 Directory_Table current_table; !BCC_EOS ! 102 int local_segment = 0x7e0; push bp mov bp,sp push di push si add sp,#-$2204 ! Debug: eq int = const $7E0 to int local_segment = [S+$220A-$220A] (used reg = ) mov ax,#$7E0 mov -$2208[bp],ax !BCC_EOS ! 103 int stack_segment = 0x8fc0; dec sp dec sp ! Debug: eq unsigned int = const $8FC0 to int stack_segment = [S+$220C-$220C] (used reg = ) mov ax,#$8FC0 mov -$220A[bp],ax !BCC_EOS ! 104 long index_as_long; !BCC_EOS ! 105 ! 106 char local_path[256]; !BCC_EOS ! 107 service_action = selector; add sp,#-$104 ! Debug: eq int selector = [S+$2310+2] to int service_action = [S+$2310-$208] (used reg = ) mov ax,4[bp] mov -$206[bp],ax !BCC_EOS ! 108 ! 109 switch (service_action) mov ax,-$206[bp] ! 110 { br .3 ! 111 case SERIVCE_LOAD_DISK: ! 112 { .4: ! 113 ! 114 ! 115 ! 116 ! 117 index_as_long = parameter_struct; ! Debug: eq * void parameter_struct = [S+$2310+4] to long index_as_long = [S+$2310-$2210] (used reg = ) mov ax,6[bp] xor bx,bx mov -$220E[bp],ax mov -$220C[bp],bx !BCC_EOS ! 118 disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment); ! Debug: list int stack_segment = [S+$2310-$220C] (used reg = ) push -$220A[bp] ! Debug: list * struct File_System_Control_Information fsci = S+$2312-$206 (used reg = ) lea bx,-$204[bp] push bx ! Debug: list int = const 1 (used reg = ) mov ax,*1 push ax ! Debug: list long index_as_long = [S+$2316-$2210] (used reg = ) push -$220C[bp] push -$220E[bp] ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = ) call _disk_service_read_data_from_disk add sp,*$A !BCC_EOS ! 119 print("File System has been loaded: "); ! Debug: list * char = .5+0 (used reg = ) mov bx,#.5 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS ! 120 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS ! 121 print_stack(fsci.filesystem_information); ! Debug: list * char fsci = S+$2310-$206 (used reg = ) lea bx,-$204[bp] push bx ! Debug: func () void = print_stack+0 (used reg = ) call _print_stack inc sp inc sp !BCC_EOS ! 122 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS ! 123 } break; br .1 !BCC_EOS ! 124 case SERVICE_FIND_ENTRY: ! 125 { .6: ! 126 disk_service_read_data_from_disk(fsci.master_table_index[0], 16 , ¤t_table, stack_segment); ! Debug: list int stack_segment = [S+$2310-$220C] (used reg = ) push -$220A[bp] ! Debug: list * struct Directory_Table current_table = S+$2312-$2208 (used reg = ) lea bx,-$2206[bp] push bx ! Debug: list int = const $10 (used reg = ) mov ax,*$10 push ax ! Debug: list long fsci = [S+$2316-$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 !BCC_EOS ! 127 print("Current table: "); ! Debug: list * char = .7+0 (used reg = ) mov bx,#.7 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS ! 128 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS ! 129 print_stack(current_table.entries[0].filename); ! Debug: list * char current_table = S+$2310-$2208 (used reg = ) lea bx,-$2206[bp] push bx ! Debug: func () void = print_stack+0 (used reg = ) call _print_stack inc sp inc sp !BCC_EOS ! 130 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS ! 131 print_stack(current_table.entries[1].filename); ! Debug: list * char current_table = S+$2310-$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 ! 132 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS ! 133 print_stack(current_table.entries[2].filename); ! Debug: list * char current_table = S+$2310-$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 ! 134 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS ! 135 } break; jmp .1 !BCC_EOS ! 136 case SERIVCE_READ_DATA: ! 137 { .8: ! 138 print("Hit READ case"); ! Debug: list * char = .9+0 (used reg = ) mov bx,#.9 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS ! 139 } break; jmp .1 !BCC_EOS ! 140 case SERIVCE_WRITE_DATA: ! 141 { .A: ! 142 print("Hit WRITE case"); ! Debug: list * char = .B+0 (used reg = ) mov bx,#.B push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS ! 143 } break; jmp .1 !BCC_EOS ! 144 default: ! 145 { .C: ! 146 print("Default case"); ! Debug: list * char = .D+0 (used reg = ) mov bx,#.D push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS ! 147 } ! 148 } ! 149 ! 150 return 0; jmp .1 .3: sub ax,*1 beq .4 sub ax,*1 beq .6 sub ax,*1 je .8 sub ax,*1 je .A jmp .C .1: ..FFFF = -$2310 xor ax,ax lea sp,-4[bp] pop si pop di pop bp ret !BCC_EOS ! 151 ! 152 } ! 153 # 157 ! 157 void print(string) ! Register BX used in function main ! 158 char* string; export _print _print: !BCC_EOS ! 159 { ! 160 #asm !BCC_ASM _print.string set 2 push bp mov bp,sp mov si,4[bp] call 0x0000:0x7C47 pop bp ! 166 endasm !BCC_ENDASM ! 167 } ret ! 168 ! 169 void print_stack(argument) ! 170 { export _print_stack _print_stack: ! 171 #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 ! 185 endasm !BCC_ENDASM ! 186 } ret ! 187 ! 188 dump_ax_return(input) ! 189 void* input; export _dump_ax_return _dump_ax_return: !BCC_EOS ! 190 { ! 191 return input; push bp mov bp,sp push di push si mov ax,4[bp] pop si pop di pop bp ret !BCC_EOS ! 192 } ! 193 ! 194 void dump_ax(input) ! 195 void* input; export _dump_ax _dump_ax: !BCC_EOS ! 196 { ! 197 ! 198 dump_ax_return(input) push bp mov bp,sp push di push si ! 199 #asm ! Debug: list * void input = [S+6+2] (used reg = ) push 4[bp] ! Debug: func () int = 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 ! 204 endasm !BCC_ENDASM !BCC_EOS ! 205 } pop si pop di pop bp ret ! 206 ! 207 void print_newline() ! 208 { export _print_newline _print_newline: ! 209 #asm !BCC_ASM printCRLF: mov ah, #0xE mov al, #13 int #0x10 mov al, #10 int #0x10 ret ! 217 endasm !BCC_ENDASM ! 218 # 217 ! 217 } ret ! 218 .D: .E: .ascii "Default case" .byte 0 .B: .F: .ascii "Hit WRITE case" .byte 0 .9: .10: .ascii "Hit READ case" .byte 0 .7: .11: .ascii "Current table: " .byte 0 .5: .12: .ascii "File System has been loaded: " .byte 0 .bss .comm _selector,2 .comm _number_low,2 ! 0 errors detected