diff --git a/debug.txt b/debug.txt new file mode 100644 index 0000000..a9ba56a --- /dev/null +++ b/debug.txt @@ -0,0 +1,749 @@ +std_singos/string.h:257.6: error: need '{' +std_singos/string.h:257.17: error: size_t undeclared +std_singos/string.h:257.17: error: need ';' +std_singos/string.h:263.16: error: NULL undeclared +std_singos/string.h:263.16: error: compiler bug? - botched implicit cast +std_singos/string.h:267.14: error: bad expression +std_singos/string.h:267.32: error: need ';' +std_singos/string.h:267.40: error: length undeclared +std_singos/string.h:267.47: error: chars undeclared +std_singos/string.h:268.8: error: need ';' +std_singos/string.h:268.8: error: bad expression +std_singos/string.h:268.12: error: need ';' +std_singos/string.h:268.12: error: bad expression +std_singos/string.h:268.19: error: need ';' +std_singos/string.h:269.4: error: bad expression +std_singos/string.h:281.16: error: compiler bug? - botched implicit cast +std_singos/stdio.h:1.4: error: bad expression +std_singos/stdio.h:1.10: error: need ';' +std_singos/stdio.h:1.18: error: string undeclared +std_singos/stdio.h:3.4: error: bad expression +std_singos/stdio.h:3.10: error: need ';' +std_singos/stdio.h:4.4: error: need ';' +std_singos/stdio.h:4.4: error: bad expression +std_singos/stdio.h:15.4: error: bad expression +std_singos/stdio.h:15.16: error: need ';' +std_singos/stdio.h:15.26: error: argument undeclared +std_singos/stdio.h:16.1: error: need ';' +std_singos/stdio.h:34.21: error: input undeclared +std_singos/stdio.h:35.4: error: need ';' +std_singos/stdio.h:35.4: error: bad expression +std_singos/stdio.h:37.17: error: compiler bug? - botched implicit cast +std_singos/stdio.h:40.4: error: bad expression +std_singos/stdio.h:40.12: error: need ';' +std_singos/stdio.h:41.4: error: need ';' +std_singos/stdio.h:41.4: error: bad expression +std_singos/stdio.h:53.4: error: bad expression +std_singos/stdio.h:53.18: error: need ';' +std_singos/stdio.h:54.1: error: need ';' +driver/disk.h:1.3: error: bad expression +driver/disk.h:1.18: error: need ';' +driver/disk.h:1.25: error: index undeclared +driver/disk.h:1.41: error: number_sectors undeclared +driver/disk.h:1.54: error: data_buffer undeclared +driver/disk.h:1.75: error: data_buffer_segment undeclared +driver/disk.h:2.3: error: bad expression +driver/disk.h:2.36: error: need ';' +driver/disk.h:4.3: error: bad expression +driver/disk.h:4.36: error: need ';' +driver/disk.h:5.4: error: need ';' +driver/disk.h:5.4: error: bad expression +driver/disk.h:6.4: error: bad expression +driver/disk.h:6.19: error: need ';' +driver/disk.h:7.4: error: bad expression +driver/disk.h:8.3: error: bad expression +driver/disk.h:8.23: error: need ';' +main.c:21.4: error: bad expression +main.c:21.12: error: need ';' +main.c:22.4: error: bad expression +main.c:22.16: error: need ';' +main.c:23.4: error: bad expression +main.c:23.18: error: need ';' +main.c:25.7: error: bad expression +main.c:25.14: error: need ';' +main.c:25.14: error: bad expression +main.c:25.30: error: need ';' +main.c:25.46: error: Directory_Table undeclared +main.c:25.46: error: need ';' +main.c:26.7: error: bad expression +main.c:26.14: error: need ';' +main.c:26.14: error: bad expression +main.c:26.33: error: need ';' +main.c:26.45: error: Struct_Table_Entry undeclared +main.c:26.45: error: need ';' +main.c:26.46: error: Table_Entry undeclared +main.c:27.7: error: bad expression +main.c:27.14: error: need ';' +main.c:27.14: error: bad expression +main.c:27.39: error: need ';' +main.c:27.57: error: struct_partition_control undeclared +main.c:27.57: error: need ';' +main.c:27.58: error: partition_control undeclared +main.c:28.7: error: bad expression +main.c:28.14: error: need ';' +main.c:28.14: error: bad expression +main.c:28.46: error: need ';' +main.c:28.51: error: File_System_Control_Information undeclared +main.c:28.51: error: need ';' +main.c:28.52: error: FSCI undeclared +main.c:29.7: error: bad expression +main.c:29.14: error: need ';' +main.c:29.14: error: bad expression +main.c:29.38: error: need ';' +main.c:29.42: error: meta_information_format undeclared +main.c:29.42: error: need ';' +main.c:29.43: error: mif undeclared +main.c:30.7: error: bad expression +main.c:30.14: error: need ';' +main.c:30.14: error: bad expression +main.c:30.25: error: need ';' +main.c:30.36: error: tag_record undeclared +main.c:30.36: error: need ';' +main.c:31.7: error: bad expression +main.c:31.14: error: need ';' +main.c:31.14: error: bad expression +main.c:31.24: error: need ';' +main.c:31.34: error: lsfs_file undeclared +main.c:31.34: error: need ';' +main.c:32.7: error: bad expression +main.c:32.14: error: need ';' +main.c:32.14: error: bad expression +main.c:32.31: error: need ';' +main.c:32.48: error: Parameter_Struct undeclared +main.c:32.48: error: need ';' +main.c:34.7: error: bad expression +main.c:34.12: error: need ';' +main.c:34.12: error: bad expression +main.c:34.29: error: need ';' +main.c:35.1: error: Table_Entry_Kind undeclared +main.c:35.1: error: need ';' +main.c:37.17: error: ENTRY_EMPTY undeclared +main.c:38.16: error: ENTRY_FILE undeclared +main.c:39.21: error: ENTRY_DIRECTORY undeclared +main.c:40.1: error: bad expression +main.c:40.18: error: need ';' +main.c:42.7: error: bad expression +main.c:42.12: error: need ';' +main.c:42.12: error: bad expression +main.c:42.27: error: need ';' +main.c:43.1: error: Service_Action undeclared +main.c:43.1: error: need ';' +main.c:44.24: error: SERIVCE_LOAD_DISK undeclared +main.c:45.24: error: SERVICE_FIND_ENTRY undeclared +main.c:46.24: error: SERIVCE_READ_DATA undeclared +main.c:47.24: error: SERIVCE_WRITE_DATA undeclared +main.c:49.1: error: bad expression +main.c:49.16: error: need ';' +main.c:51.6: error: bad expression +main.c:51.25: error: need ';' +main.c:52.1: error: need ';' +main.c:67.6: error: bad expression +main.c:67.38: error: need ';' +main.c:68.1: error: need ';' +main.c:82.7: error: bad expression +main.c:82.14: error: need ';' +main.c:82.14: error: bad expression +main.c:82.30: error: need ';' +main.c:83.1: error: need ';' +main.c:84.23: error: need ';' +main.c:84.24: error: entries undeclared +main.c:84.29: error: illegal indirection +main.c:88.6: error: bad expression +main.c:88.23: error: need ';' +main.c:89.1: error: need ';' +main.c:97.31: error: need ';' +main.c:97.32: error: entry_kind undeclared +main.c:100.3: error: bad expression +main.c:100.8: error: need ';' +main.c:100.18: error: selector undeclared +main.c:100.45: error: pointer_parameter_segment undeclared +main.c:100.71: error: pointer_parameter_struct undeclared +main.c:101.3: error: need ';' +main.c:101.3: error: bad expression +main.c:101.12: error: need ';' +main.c:102.4: error: bad expression +main.c:103.4: error: bad expression +main.c:108.13: error: need ';' +main.c:108.14: error: fsci undeclared +main.c:109.33: error: need ';' +main.c:109.34: error: service_action undeclared +main.c:110.33: error: need ';' +main.c:110.34: error: current_table undeclared +main.c:111.37: error: need ';' +main.c:111.38: error: parameter_struct undeclared +main.c:112.7: error: bad expression +main.c:112.21: error: need ';' +main.c:112.23: error: local_segment undeclared +main.c:113.7: error: bad expression +main.c:113.21: error: need ';' +main.c:113.23: error: stack_segment undeclared +main.c:114.7: error: bad expression +main.c:114.19: error: need ';' +main.c:114.20: error: path_length undeclared +main.c:115.8: error: bad expression +main.c:115.22: error: need ';' +main.c:115.23: error: index_as_long undeclared +main.c:117.8: error: bad expression +main.c:117.19: error: need ';' +main.c:117.20: error: local_path undeclared +main.c:117.24: error: illegal indirection +main.c:122.31: error: constant expression required +main.c:132.51: error: undefined structure element +main.c:135.32: error: constant expression required +main.c:140.35: error: illegal indirection +main.c:143.71: error: illegal indirection +main.c:146.48: error: illegal indirection +main.c:146.59: error: compiler bug? - taking address of non-lvalue +main.c:148.48: error: illegal indirection +main.c:148.59: error: compiler bug? - taking address of non-lvalue +main.c:150.48: error: illegal indirection +main.c:150.59: error: compiler bug? - taking address of non-lvalue +main.c:153.31: error: constant expression required +main.c:166.32: error: constant expression required +main.c:176.10: error: duplicate case in switch +main.c:176.10: error: duplicate case in switch +main.c:176.10: error: duplicate case in switch +main.c:176.13: error: compiler bug? - botched implicit cast +main.c:eof: error: need '}' +main.c:eof: error: need '}' +main.c:eof: error: need '}' +01923 .fail 209 errors detected +***** junk after operands...............................^ +00006 000C E8 0000 call _main +***** unbound label..................................^ +***** relocation impossible...............................^ +00339 0119 E8 0000 call _malloc +***** unbound label.....................................^ +***** relocation impossible....................................^ +00610 0242 E8 0000 call _lsfs_create_string +***** unbound label.....................................^ +***** relocation impossible................................................^ +00688 02B1 E8 0000 call _lsfs_create_string +***** unbound label.....................................^ +***** relocation impossible................................................^ +00736 fail! std_singos/string.h:257.6: error: need '{' +***** user-generated error..........................^ +00741 fail! std_singos/string.h:257.17: error: size_t undeclared +***** user-generated error..........................^ +00743 fail! std_singos/string.h:257.17: error: need ';' +***** user-generated error..........................^ +00751 fail! std_singos/string.h:263.16: error: NULL undeclared +***** user-generated error..........................^ +00752 fail! std_singos/string.h:263.16: error: compiler bug? - botched implicit cast +***** user-generated error..........................^ +00769 fail! std_singos/string.h:267.14: error: bad expression +***** user-generated error..........................^ +00771 fail! std_singos/string.h:267.32: error: need ';' +***** user-generated error..........................^ +00772 fail! std_singos/string.h:267.40: error: length undeclared +***** user-generated error..........................^ +00773 fail! std_singos/string.h:267.47: error: chars undeclared +***** user-generated error..........................^ +00783 031F E8 0000 call _lsfs_create_string +***** unbound label.....................................^ +***** relocation impossible................................................^ +00788 fail! std_singos/string.h:268.8: error: need ';' +***** user-generated error..........................^ +00789 fail! std_singos/string.h:268.8: error: bad expression +***** user-generated error..........................^ +00791 fail! std_singos/string.h:268.12: error: need ';' +***** user-generated error..........................^ +00792 fail! std_singos/string.h:268.12: error: bad expression +***** user-generated error..........................^ +00794 fail! std_singos/string.h:268.19: error: need ';' +***** user-generated error..........................^ +00797 fail! std_singos/string.h:269.4: error: bad expression +***** user-generated error..........................^ +00815 fail! std_singos/string.h:281.16: error: compiler bug? - botched implicit cast +***** user-generated error..........................^ +00832 fail! std_singos/stdio.h:1.4: error: bad expression +***** user-generated error..........................^ +00834 fail! std_singos/stdio.h:1.10: error: need ';' +***** user-generated error..........................^ +00835 fail! std_singos/stdio.h:1.18: error: string undeclared +***** user-generated error..........................^ +00839 0348 E8 0000 call _print +***** relocation impossible...................................^ +***** unbound label.....................................^ +00845 fail! std_singos/stdio.h:3.4: error: bad expression +***** user-generated error..........................^ +00847 fail! std_singos/stdio.h:3.10: error: need ';' +***** user-generated error..........................^ +00852 0351 E8 0000 call _print +***** unbound label.....................................^ +***** relocation impossible...................................^ +00856 fail! std_singos/stdio.h:4.4: error: need ';' +***** user-generated error..........................^ +00857 fail! std_singos/stdio.h:4.4: error: bad expression +***** user-generated error..........................^ +00880 fail! std_singos/stdio.h:15.4: error: bad expression +***** user-generated error..........................^ +00882 fail! std_singos/stdio.h:15.16: error: need ';' +***** user-generated error..........................^ +00883 fail! std_singos/stdio.h:15.26: error: argument undeclared +***** user-generated error..........................^ +00888 036B E8 0000 call _print_stack +***** unbound label.....................................^ +***** relocation impossible.........................................^ +00892 fail! std_singos/stdio.h:16.1: error: need ';' +***** user-generated error..........................^ +00917 fail! std_singos/stdio.h:34.21: error: input undeclared +***** user-generated error..........................^ +00922 0388 E8 0000 call _dump_ax_return +***** unbound label.....................................^ +***** relocation impossible............................................^ +00926 fail! std_singos/stdio.h:35.4: error: need ';' +***** user-generated error..........................^ +00927 fail! std_singos/stdio.h:35.4: error: bad expression +***** user-generated error..........................^ +00935 fail! std_singos/stdio.h:37.17: error: compiler bug? - botched implicit cast +***** user-generated error..........................^ +00951 fail! std_singos/stdio.h:40.4: error: bad expression +***** user-generated error..........................^ +00953 fail! std_singos/stdio.h:40.12: error: need ';' +***** user-generated error..........................^ +00958 03AB E8 0000 call _dump_ax +***** relocation impossible.....................................^ +***** unbound label.....................................^ +00962 fail! std_singos/stdio.h:41.4: error: need ';' +***** user-generated error..........................^ +00963 fail! std_singos/stdio.h:41.4: error: bad expression +***** user-generated error..........................^ +00976 03B9 E8 0000 call _dump_ax_return +***** unbound label.....................................^ +***** relocation impossible............................................^ +00993 fail! std_singos/stdio.h:53.4: error: bad expression +***** user-generated error..........................^ +00995 fail! std_singos/stdio.h:53.18: error: need ';' +***** user-generated error..........................^ +00998 03C7 E8 0000 call _print_newline +***** relocation impossible...........................................^ +***** unbound label.....................................^ +01000 fail! std_singos/stdio.h:54.1: error: need ';' +***** user-generated error..........................^ +01019 fail! driver/disk.h:1.3: error: bad expression +***** user-generated error..........................^ +01021 fail! driver/disk.h:1.18: error: need ';' +***** user-generated error..........................^ +01022 fail! driver/disk.h:1.25: error: index undeclared +***** user-generated error..........................^ +01023 fail! driver/disk.h:1.41: error: number_sectors undeclared +***** user-generated error..........................^ +01024 fail! driver/disk.h:1.54: error: data_buffer undeclared +***** user-generated error..........................^ +01025 fail! driver/disk.h:1.75: error: data_buffer_segment undeclared +***** user-generated error..........................^ +01035 03E5 E8 0000 call _data_from_disk +***** unbound label.....................................^ +***** relocation impossible............................................^ +01039 fail! driver/disk.h:2.3: error: bad expression +***** user-generated error..........................^ +01041 fail! driver/disk.h:2.36: error: need ';' +***** user-generated error..........................^ +01051 03FB E8 0000 call _disk_service_read_data_from_disk +***** unbound label.....................................^ +***** relocation impossible..............................................................^ +01056 fail! driver/disk.h:4.3: error: bad expression +***** user-generated error..........................^ +01059 fail! driver/disk.h:4.36: error: need ';' +***** user-generated error..........................^ +01070 0411 E8 0000 call _disk_service_read_data_from_disk +***** unbound label.....................................^ +***** relocation impossible..............................................................^ +01073 fail! driver/disk.h:5.4: error: need ';' +***** user-generated error..........................^ +01074 fail! driver/disk.h:5.4: error: bad expression +***** user-generated error..........................^ +01081 fail! driver/disk.h:6.4: error: bad expression +***** user-generated error..........................^ +01083 fail! driver/disk.h:6.19: error: need ';' +***** user-generated error..........................^ +01086 fail! driver/disk.h:7.4: error: bad expression +***** user-generated error..........................^ +01093 fail! driver/disk.h:8.3: error: bad expression +***** user-generated error..........................^ +01095 fail! driver/disk.h:8.23: error: need ';' +***** user-generated error..........................^ +01159 fail! main.c:21.4: error: bad expression +***** user-generated error..........................^ +01161 fail! main.c:21.12: error: need ';' +***** user-generated error..........................^ +01165 0463 E8 0000 call _dump_ax +***** relocation impossible.....................................^ +***** unbound label.....................................^ +01170 fail! main.c:22.4: error: bad expression +***** user-generated error..........................^ +01172 fail! main.c:22.16: error: need ';' +***** user-generated error..........................^ +01176 046C E8 0000 call _print_stack +***** unbound label.....................................^ +***** relocation impossible.........................................^ +01181 fail! main.c:23.4: error: bad expression +***** user-generated error..........................^ +01183 fail! main.c:23.18: error: need ';' +***** user-generated error..........................^ +01185 0471 E8 0000 call _print_newline +***** unbound label.....................................^ +***** relocation impossible...........................................^ +01189 fail! main.c:25.7: error: bad expression +***** user-generated error..........................^ +01191 fail! main.c:25.14: error: need ';' +***** user-generated error..........................^ +01192 fail! main.c:25.14: error: bad expression +***** user-generated error..........................^ +01194 fail! main.c:25.30: error: need ';' +***** user-generated error..........................^ +01195 fail! main.c:25.46: error: Directory_Table undeclared +***** user-generated error..........................^ +01197 fail! main.c:25.46: error: need ';' +***** user-generated error..........................^ +01200 fail! main.c:26.7: error: bad expression +***** user-generated error..........................^ +01202 fail! main.c:26.14: error: need ';' +***** user-generated error..........................^ +01203 fail! main.c:26.14: error: bad expression +***** user-generated error..........................^ +01205 fail! main.c:26.33: error: need ';' +***** user-generated error..........................^ +01206 fail! main.c:26.45: error: Struct_Table_Entry undeclared +***** user-generated error..........................^ +01208 fail! main.c:26.45: error: need ';' +***** user-generated error..........................^ +01209 fail! main.c:26.46: error: Table_Entry undeclared +***** user-generated error..........................^ +01212 fail! main.c:27.7: error: bad expression +***** user-generated error..........................^ +01214 fail! main.c:27.14: error: need ';' +***** user-generated error..........................^ +01215 fail! main.c:27.14: error: bad expression +***** user-generated error..........................^ +01217 fail! main.c:27.39: error: need ';' +***** user-generated error..........................^ +01218 fail! main.c:27.57: error: struct_partition_control undeclared +***** user-generated error..........................^ +01220 fail! main.c:27.57: error: need ';' +***** user-generated error..........................^ +01221 fail! main.c:27.58: error: partition_control undeclared +***** user-generated error..........................^ +01224 fail! main.c:28.7: error: bad expression +***** user-generated error..........................^ +01226 fail! main.c:28.14: error: need ';' +***** user-generated error..........................^ +01227 fail! main.c:28.14: error: bad expression +***** user-generated error..........................^ +01229 fail! main.c:28.46: error: need ';' +***** user-generated error..........................^ +01230 fail! main.c:28.51: error: File_System_Control_Information undeclared +***** user-generated error..........................^ +01232 fail! main.c:28.51: error: need ';' +***** user-generated error..........................^ +01233 fail! main.c:28.52: error: FSCI undeclared +***** user-generated error..........................^ +01236 fail! main.c:29.7: error: bad expression +***** user-generated error..........................^ +01238 fail! main.c:29.14: error: need ';' +***** user-generated error..........................^ +01239 fail! main.c:29.14: error: bad expression +***** user-generated error..........................^ +01241 fail! main.c:29.38: error: need ';' +***** user-generated error..........................^ +01242 fail! main.c:29.42: error: meta_information_format undeclared +***** user-generated error..........................^ +01244 fail! main.c:29.42: error: need ';' +***** user-generated error..........................^ +01245 fail! main.c:29.43: error: mif undeclared +***** user-generated error..........................^ +01248 fail! main.c:30.7: error: bad expression +***** user-generated error..........................^ +01250 fail! main.c:30.14: error: need ';' +***** user-generated error..........................^ +01251 fail! main.c:30.14: error: bad expression +***** user-generated error..........................^ +01253 fail! main.c:30.25: error: need ';' +***** user-generated error..........................^ +01254 fail! main.c:30.36: error: tag_record undeclared +***** user-generated error..........................^ +01256 fail! main.c:30.36: error: need ';' +***** user-generated error..........................^ +01259 fail! main.c:31.7: error: bad expression +***** user-generated error..........................^ +01261 fail! main.c:31.14: error: need ';' +***** user-generated error..........................^ +01262 fail! main.c:31.14: error: bad expression +***** user-generated error..........................^ +01264 fail! main.c:31.24: error: need ';' +***** user-generated error..........................^ +01265 fail! main.c:31.34: error: lsfs_file undeclared +***** user-generated error..........................^ +01267 fail! main.c:31.34: error: need ';' +***** user-generated error..........................^ +01270 fail! main.c:32.7: error: bad expression +***** user-generated error..........................^ +01272 fail! main.c:32.14: error: need ';' +***** user-generated error..........................^ +01273 fail! main.c:32.14: error: bad expression +***** user-generated error..........................^ +01275 fail! main.c:32.31: error: need ';' +***** user-generated error..........................^ +01276 fail! main.c:32.48: error: Parameter_Struct undeclared +***** user-generated error..........................^ +01278 fail! main.c:32.48: error: need ';' +***** user-generated error..........................^ +01282 fail! main.c:34.7: error: bad expression +***** user-generated error..........................^ +01284 fail! main.c:34.12: error: need ';' +***** user-generated error..........................^ +01285 fail! main.c:34.12: error: bad expression +***** user-generated error..........................^ +01287 fail! main.c:34.29: error: need ';' +***** user-generated error..........................^ +01289 fail! main.c:35.1: error: Table_Entry_Kind undeclared +***** user-generated error..........................^ +01291 fail! main.c:35.1: error: need ';' +***** user-generated error..........................^ +01294 fail! main.c:37.17: error: ENTRY_EMPTY undeclared +***** user-generated error..........................^ +01296 fail! main.c:38.16: error: ENTRY_FILE undeclared +***** user-generated error..........................^ +01298 fail! main.c:39.21: error: ENTRY_DIRECTORY undeclared +***** user-generated error..........................^ +01300 fail! main.c:40.1: error: bad expression +***** user-generated error..........................^ +01311 fail! main.c:40.18: error: need ';' +***** user-generated error..........................^ +01315 fail! main.c:42.7: error: bad expression +***** user-generated error..........................^ +01317 fail! main.c:42.12: error: need ';' +***** user-generated error..........................^ +01318 fail! main.c:42.12: error: bad expression +***** user-generated error..........................^ +01320 fail! main.c:42.27: error: need ';' +***** user-generated error..........................^ +01322 fail! main.c:43.1: error: Service_Action undeclared +***** user-generated error..........................^ +01324 fail! main.c:43.1: error: need ';' +***** user-generated error..........................^ +01326 fail! main.c:44.24: error: SERIVCE_LOAD_DISK undeclared +***** user-generated error..........................^ +01328 fail! main.c:45.24: error: SERVICE_FIND_ENTRY undeclared +***** user-generated error..........................^ +01330 fail! main.c:46.24: error: SERIVCE_READ_DATA undeclared +***** user-generated error..........................^ +01332 fail! main.c:47.24: error: SERIVCE_WRITE_DATA undeclared +***** user-generated error..........................^ +01335 fail! main.c:49.1: error: bad expression +***** user-generated error..........................^ +01349 fail! main.c:49.16: error: need ';' +***** user-generated error..........................^ +01353 fail! main.c:51.6: error: bad expression +***** user-generated error..........................^ +01355 fail! main.c:51.25: error: need ';' +***** user-generated error..........................^ +01358 fail! main.c:52.1: error: need ';' +***** user-generated error..........................^ +01388 fail! main.c:67.6: error: bad expression +***** user-generated error..........................^ +01390 fail! main.c:67.38: error: need ';' +***** user-generated error..........................^ +01393 fail! main.c:68.1: error: need ';' +***** user-generated error..........................^ +01419 fail! main.c:82.7: error: bad expression +***** user-generated error..........................^ +01421 fail! main.c:82.14: error: need ';' +***** user-generated error..........................^ +01422 fail! main.c:82.14: error: bad expression +***** user-generated error..........................^ +01424 fail! main.c:82.30: error: need ';' +***** user-generated error..........................^ +01427 fail! main.c:83.1: error: need ';' +***** user-generated error..........................^ +01430 fail! main.c:84.23: error: need ';' +***** user-generated error..........................^ +01431 fail! main.c:84.24: error: entries undeclared +***** user-generated error..........................^ +01432 fail! main.c:84.29: error: illegal indirection +***** user-generated error..........................^ +01439 fail! main.c:88.6: error: bad expression +***** user-generated error..........................^ +01441 fail! main.c:88.23: error: need ';' +***** user-generated error..........................^ +01444 fail! main.c:89.1: error: need ';' +***** user-generated error..........................^ +01462 fail! main.c:97.31: error: need ';' +***** user-generated error..........................^ +01463 fail! main.c:97.32: error: entry_kind undeclared +***** user-generated error..........................^ +01470 fail! main.c:100.3: error: bad expression +***** user-generated error..........................^ +01472 fail! main.c:100.8: error: need ';' +***** user-generated error..........................^ +01473 fail! main.c:100.18: error: selector undeclared +***** user-generated error..........................^ +01474 fail! main.c:100.45: error: pointer_parameter_segment undeclared +***** user-generated error..........................^ +01475 fail! main.c:100.71: error: pointer_parameter_struct undeclared +***** user-generated error..........................^ +01484 04AF E8 0000 call _main +***** relocation impossible..................................^ +***** unbound label.....................................^ +01487 fail! main.c:101.3: error: need ';' +***** user-generated error..........................^ +01488 fail! main.c:101.3: error: bad expression +***** user-generated error..........................^ +01490 fail! main.c:101.12: error: need ';' +***** user-generated error..........................^ +01493 fail! main.c:102.4: error: bad expression +***** user-generated error..........................^ +01500 fail! main.c:103.4: error: bad expression +***** user-generated error..........................^ +01512 fail! main.c:108.13: error: need ';' +***** user-generated error..........................^ +01513 fail! main.c:108.14: error: fsci undeclared +***** user-generated error..........................^ +01517 fail! main.c:109.33: error: need ';' +***** user-generated error..........................^ +01518 fail! main.c:109.34: error: service_action undeclared +***** user-generated error..........................^ +01522 fail! main.c:110.33: error: need ';' +***** user-generated error..........................^ +01523 fail! main.c:110.34: error: current_table undeclared +***** user-generated error..........................^ +01527 fail! main.c:111.37: error: need ';' +***** user-generated error..........................^ +01528 fail! main.c:111.38: error: parameter_struct undeclared +***** user-generated error..........................^ +01531 fail! main.c:112.7: error: bad expression +***** user-generated error..........................^ +01533 fail! main.c:112.21: error: need ';' +***** user-generated error..........................^ +01534 fail! main.c:112.23: error: local_segment undeclared +***** user-generated error..........................^ +01540 fail! main.c:113.7: error: bad expression +***** user-generated error..........................^ +01542 fail! main.c:113.21: error: need ';' +***** user-generated error..........................^ +01543 fail! main.c:113.23: error: stack_segment undeclared +***** user-generated error..........................^ +01549 fail! main.c:114.7: error: bad expression +***** user-generated error..........................^ +01551 fail! main.c:114.19: error: need ';' +***** user-generated error..........................^ +01552 fail! main.c:114.20: error: path_length undeclared +***** user-generated error..........................^ +01555 fail! main.c:115.8: error: bad expression +***** user-generated error..........................^ +01557 fail! main.c:115.22: error: need ';' +***** user-generated error..........................^ +01558 fail! main.c:115.23: error: index_as_long undeclared +***** user-generated error..........................^ +01562 fail! main.c:117.8: error: bad expression +***** user-generated error..........................^ +01564 fail! main.c:117.19: error: need ';' +***** user-generated error..........................^ +01565 fail! main.c:117.20: error: local_path undeclared +***** user-generated error..........................^ +01566 fail! main.c:117.24: error: illegal indirection +***** user-generated error..........................^ +01579 fail! main.c:122.31: error: constant expression required +***** user-generated error..........................^ +01603 04ED E8 0000 call _disk_service_read_data_from_disk +***** unbound label.....................................^ +***** relocation impossible..............................................................^ +01611 04F7 E8 0000 call _print +***** relocation impossible...................................^ +***** unbound label.....................................^ +01617 04FC E8 0000 call _print_newline +***** unbound label.....................................^ +***** relocation impossible...........................................^ +01620 fail! main.c:132.51: error: undefined structure element +***** user-generated error..........................^ +01624 0503 E8 0000 call _print_stack +***** relocation impossible.........................................^ +***** unbound label.....................................^ +01630 0508 E8 0000 call _print_newline +***** unbound label.....................................^ +***** relocation impossible...........................................^ +01636 fail! main.c:135.32: error: constant expression required +***** user-generated error..........................^ +01684 fail! main.c:140.35: error: illegal indirection +***** user-generated error..........................^ +01690 0557 E8 0000 call _print_stack +***** relocation impossible.........................................^ +***** unbound label.....................................^ +01696 055C E8 0000 call _print_newline +***** unbound label.....................................^ +***** relocation impossible...........................................^ +01699 fail! main.c:143.71: error: illegal indirection +***** user-generated error..........................^ +01712 056E E8 0000 call _disk_service_read_data_from_disk +***** unbound label.....................................^ +***** relocation impossible..............................................................^ +01720 0578 E8 0000 call _print +***** relocation impossible...................................^ +***** unbound label.....................................^ +01726 057D E8 0000 call _print_newline +***** unbound label.....................................^ +***** relocation impossible...........................................^ +01729 fail! main.c:146.48: error: illegal indirection +***** user-generated error..........................^ +01730 fail! main.c:146.59: error: compiler bug? - taking address of non-lvalue +***** user-generated error..........................^ +01734 0584 E8 0000 call _print_stack +***** relocation impossible.........................................^ +***** unbound label.....................................^ +01740 0589 E8 0000 call _print_newline +***** unbound label.....................................^ +***** relocation impossible...........................................^ +01743 fail! main.c:148.48: error: illegal indirection +***** user-generated error..........................^ +01744 fail! main.c:148.59: error: compiler bug? - taking address of non-lvalue +***** user-generated error..........................^ +01748 0590 E8 0000 call _print_stack +***** relocation impossible.........................................^ +***** unbound label.....................................^ +01754 0595 E8 0000 call _print_newline +***** unbound label.....................................^ +***** relocation impossible...........................................^ +01757 fail! main.c:150.48: error: illegal indirection +***** user-generated error..........................^ +01758 fail! main.c:150.59: error: compiler bug? - taking address of non-lvalue +***** user-generated error..........................^ +01762 059C E8 0000 call _print_stack +***** relocation impossible.........................................^ +***** unbound label.....................................^ +01768 05A1 E8 0000 call _print_newline +***** unbound label.....................................^ +***** relocation impossible...........................................^ +01774 fail! main.c:153.31: error: constant expression required +***** user-generated error..........................^ +01784 05AA E8 0000 call _print +***** relocation impossible...................................^ +***** unbound label.....................................^ +01792 fail! main.c:166.32: error: constant expression required +***** user-generated error..........................^ +01800 05B5 E8 0000 call _print +***** unbound label.....................................^ +***** relocation impossible...................................^ +01815 05C0 E8 0000 call _print +***** unbound label.....................................^ +***** relocation impossible...................................^ +01825 fail! main.c:176.10: error: duplicate case in switch +***** user-generated error..........................^ +01826 fail! main.c:176.10: error: duplicate case in switch +***** user-generated error..........................^ +01827 fail! main.c:176.10: error: duplicate case in switch +***** user-generated error..........................^ +01839 fail! main.c:176.13: error: compiler bug? - botched implicit cast +***** user-generated error..........................^ +01852 fail! main.c:eof: error: need '}' +***** user-generated error..........................^ +01853 fail! main.c:eof: error: need '}' +***** user-generated error..........................^ +01854 fail! main.c:eof: error: need '}' +***** user-generated error..........................^ +01923 .fail 209 errors detected +***** junk after operands...............................^ +***** user-generated error..............................^ + +00287 errors +00000 warnings diff --git a/disk.out b/disk.out index d02cc43..815d07b 100644 Binary files a/disk.out and b/disk.out differ diff --git a/main.c b/main.c index 32b45a6..68081ff 100644 --- a/main.c +++ b/main.c @@ -2,9 +2,10 @@ // Address to print 7C47 // // +#include "std_singos/stdio.h" +#include "std_singos/stdlib.h" #include "std_singos/string.h" -#include "std_singos/stdio.h" #include "driver/disk.h" #define SPACE_MBR_RECORD 2048 // Sectors @@ -106,15 +107,18 @@ void* pointer_parameter_struct; // 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_end = 0xffff; int stack_segment = 0x8fc0; int path_length; long index_as_long; - char local_path[256]; + char *local_path = 0; service_action = selector; switch (service_action) @@ -129,16 +133,33 @@ void* pointer_parameter_struct; disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment); print("File System has been loaded: "); print_newline(); + set_heap_settings(heap_start, heap_end); print_stack(fsci.filesystem_information); print_newline(); } break; case SERVICE_FIND_ENTRY: { + String_Array *path_array; + int i; memcpy(¶meter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct)); path_length = strlen(parameter_struct.path, pointer_parameter_segment); - memcpy(local_path, stack_segment, parameter_struct.path, pointer_parameter_segment, path_length); + local_path = malloc(256); + memcpy(local_path, local_segment, parameter_struct.path, pointer_parameter_segment, path_length); local_path[path_length] = 0; - print_stack(local_path); + print(local_path); + + path_array = string_split_c(local_path, '/', 0); + + print_newline(); + print_newline(); + for (i = 0; i < path_array->length; ++i) + { + print(path_array->strings[i]->chars); + print_newline(); + } + print_newline(); + print_newline(); + print_newline(); disk_service_read_data_from_disk(fsci.master_table_index[0], DEFAULT_TABLE_SIZE, ¤t_table, stack_segment); print("Current table: "); @@ -149,6 +170,7 @@ void* pointer_parameter_struct; print_newline(); print_stack(current_table.entries[2].filename); print_newline(); + } break; case SERIVCE_READ_DATA: { diff --git a/main.s b/main.s index 467662c..98b5b66 100644 --- a/main.s +++ b/main.s @@ -9,19 +9,312 @@ pop bp retf ! 1 ! 1 # 1 "main.c" -! 1 # 1 "std_singos/string.h" -! 1 void strcpy (destination, destination_segment, source, source_segment ); +! 1 # 5 +! 5 #include "std_singos/stdio.h" +! 1 +! 1 void print(string); !BCC_EOS -! 2 int strlen (source, source_segment); +! 2 void* dump_ax_return(input); !BCC_EOS -! 3 void memcpy (destination, destination_segment, source, source_segment, num_bytes ); +! 3 +! 4 void print(string) +! 5 char* string; +export _print +_print: !BCC_EOS -! 4 -! 5 int strlen (source, source_segment) ! 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 +! 6 # 1 "std_singos/stdlib.h" +! 1 unsigned int global_heap_start = 0; +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 int set_heap_settings(param_start, param_end); +!BCC_EOS +! 7 unsigned int get_heap_next(); +!BCC_EOS +! 8 +! 9 void* malloc(num_bytes) +! 10 int num_bytes; +.text +export _malloc +_malloc: +!BCC_EOS +! 11 { +! 12 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 +! 13 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 +! 14 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: +! 15 { +! 16 return 0; +xor ax,ax +inc sp +inc sp +pop si +pop di +pop bp +ret +!BCC_EOS +! 17 } +! 18 +! 19 return allocated_pointer; +.1: +mov ax,-6[bp] +inc sp +inc sp +pop si +pop di +pop bp +ret +!BCC_EOS +! 20 } +! 21 +! 22 int set_heap_settings(param_start, param_end) +! 23 unsigned int param_start; +export _set_heap_settings +_set_heap_settings: +!BCC_EOS +! 24 unsigned int param_end; +!BCC_EOS +! 25 { +! 26 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 +! 27 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 +! 28 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 +! 29 return 0; +xor ax,ax +pop si +pop di +pop bp +ret +!BCC_EOS +! 30 } +! 31 +! 32 unsigned int get_heap_next() +! 33 { +export _get_heap_next +_get_heap_next: +! 34 return global_heap_next; +push bp +mov bp,sp +push di +push si +mov ax,[_global_heap_next] +pop si +pop di +pop bp +ret +!BCC_EOS +! 35 # 6 "main.c" +! 6 } +! 7 # 3 "std_singos/string.h" +! 3 typedef struct Length_String { +! 4 short dynamic; +!BCC_EOS +! 5 unsigned int length; +!BCC_EOS +! 6 char *chars; +!BCC_EOS +! 7 } Length_String; +!BCC_EOS +! 8 +! 9 typedef struct String_Array { +! 10 unsigned int length; +!BCC_EOS +! 11 Length_String **strings; +!BCC_EOS +! 12 } String_Array; +!BCC_EOS +! 13 +! 14 void strcpy (destination, destination_segment, source, source_segment ); +!BCC_EOS +! 15 int strlen (source, source_segment); +!BCC_EOS +! 16 void memcpy (destination, destination_segment, source, source_segment, num_bytes ); +!BCC_EOS +! 17 +! 18 +! 19 String_Array *string_split_c(string, delim, keep_delim); +!BCC_EOS +! 20 Length_String *make_length_string(length, chars); +!BCC_EOS +! 21 Length_String *make_length_string_c(cstring); +!BCC_EOS +! 22 String_Array *length_string_split(string, delim, keep_delim); +!BCC_EOS +! 23 String_Array *create_length_string_array(array_size); +!BCC_EOS +! 24 Length_String *create_length_string(length, chars); +!BCC_EOS +! 25 +! 26 +! 27 +! 28 int strlen (source, source_segment) +! 29 { export _strlen _strlen: -! 7 #asm +! 30 #asm !BCC_ASM _strlen.source set 2 _strlen.source_segment set 4 @@ -52,24 +345,24 @@ push bp pop bx pop ds pop bp -! 35 endasm +! 58 endasm !BCC_ENDASM -! 36 } +! 59 } ret -! 37 -! 38 void strcpy (destination, destination_segment, source, source_segment ) -! 39 char *destination; +! 60 +! 61 void strcpy (destination, destination_segment, source, source_segment ) +! 62 char *destination; export _strcpy _strcpy: !BCC_EOS -! 40 int destination_segment; +! 63 int destination_segment; !BCC_EOS -! 41 char *source; +! 64 char *source; !BCC_EOS -! 42 int source_segment; +! 65 int source_segment; !BCC_EOS -! 43 { -! 44 #asm +! 66 { +! 67 #asm !BCC_ASM _strcpy.source set 6 _strcpy.destination set 2 @@ -80,7 +373,7 @@ _strcpy.destination_segment set 4 ; IN di: the second (zero terminated) string ; OUT SF and ZF (same semantics as cmp) -! 50 54 +! 73 77 push bp mov bp,sp @@ -115,26 +408,26 @@ _strcpy.destination_segment set 4 pop ax pop bp -! 88 endasm +! 111 endasm !BCC_ENDASM -! 89 } +! 112 } ret -! 90 -! 91 void memcpy (destination, destination_segment, source, source_segment, num_bytes) -! 92 void *destination; +! 113 +! 114 void memcpy (destination, destination_segment, source, source_segment, num_bytes) +! 115 void *destination; export _memcpy _memcpy: !BCC_EOS -! 93 int destination_segment; +! 116 int destination_segment; !BCC_EOS -! 94 void *source; +! 117 void *source; !BCC_EOS -! 95 int source_segment; +! 118 int source_segment; !BCC_EOS -! 96 int num_bytes; +! 119 int num_bytes; !BCC_EOS -! 97 { -! 98 #asm +! 120 { +! 121 #asm !BCC_ASM _memcpy.source set 6 _memcpy.destination set 2 @@ -146,7 +439,7 @@ _memcpy.destination_segment set 4 ; IN di: the second (zero terminated) string ; OUT SF and ZF (same semantics as cmp) -! 104 109 +! 127 132 push bp mov bp,sp @@ -181,136 +474,656 @@ _memcpy.destination_segment set 4 pop ax pop bp -! 143 endasm +! 166 endasm !BCC_ENDASM -! 144 # 6 "main.c" -! 6 } +! 167 } ret -! 7 # 1 "std_singos/stdio.h" -! 1 void print(string); +! 168 +! 169 String_Array *string_split_c(string, delim, keep_delim) +! 170 char *string; +export _string_split_c +_string_split_c: +!BCC_EOS +! 171 char delim +! 171 ; +!BCC_EOS +! 172 short keep_delim; +!BCC_EOS +! 173 { +! 174 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 +! 175 } +! 176 +! 177 Length_String *make_length_string_c(cstring) +! 178 char *cstring; +export _make_length_string_c +_make_length_string_c: +!BCC_EOS +! 179 { +! 180 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 +! 181 } +! 182 +! 183 Length_String *make_length_string(length, chars) +! 184 unsigned int length; +export _make_length_string +_make_length_string: +!BCC_EOS +! 185 char *chars; +!BCC_EOS +! 186 { +! 187 +! 188 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 +! 189 +! 190 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 +! 191 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 +! 192 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] +mov bx,ax +! Debug: eq int = const 0 to char = [bx+0] (used reg = ) +xor al,al +mov [bx],al +!BCC_EOS +! 193 +! 194 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 +! 195 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 +! 196 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 +! 197 +! 198 return legth_string; +mov ax,-6[bp] +add sp,*4 +pop si +pop di +pop bp +ret +!BCC_EOS +! 199 } +! 200 +! 201 String_Array *length_string_split(string, delim, keep_delim) +! Register BX SI used in function make_length_string +! 202 Length_String *string; +export _length_string_split +_length_string_split: +!BCC_EOS +! 203 char delim; +!BCC_EOS +! 204 short keep_delim; +!BCC_EOS +! 205 { +! 206 unsigned int i; +!BCC_EOS +! 207 unsigned int last; +!BCC_EOS +! 208 +! 209 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 +! 210 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 -! 2 -! 3 void print(string) -! 4 char* string; -export _print -_print: +! 211 String_Array *result; !BCC_EOS -! 5 { -! 6 #asm -!BCC_ASM -_print.string set 2 - - push bp - mov bp,sp - mov si,4[bp] - call 0x0000:0x7C47 - pop bp -! 12 endasm -!BCC_ENDASM -! 13 } -ret -! 14 -! 15 void print_stack(argument) -! 16 { -export _print_stack -_print_stack: -! 17 #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 -! 31 endasm -!BCC_ENDASM -! 32 } +! 212 int k; +!BCC_EOS +! 213 +! 214 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 +! 215 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 +! 216 while(i < string->length) { +jmp .4 +.5: +! 217 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 .6 +.7: +! 218 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 .8 +.9: +! 219 ++count; +! Debug: preinc unsigned int count = [S+$12-$C] (used reg = ) +mov ax,-$A[bp] +inc ax +mov -$A[bp],ax +!BCC_EOS +! 220 } +! 221 last = i; +.8: +! 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 +! 222 } +! 223 ++i; +.6: +! Debug: preinc unsigned int i = [S+$12-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +!BCC_EOS +! 224 } +! 225 if (i > last+1) { +.4: +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 .5 +.A: +.3: +! 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 .B +.C: +! 226 ++count; +! Debug: preinc unsigned int count = [S+$12-$C] (used reg = ) +mov ax,-$A[bp] +inc ax +mov -$A[bp],ax +!BCC_EOS +! 227 } +! 228 +! 229 result = create_length_string_array(count); +.B: +! 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 +! 230 +! 231 if (keep_delim) +mov ax,8[bp] +test ax,ax +je .D +.E: +! 232 { +! 233 k = 0; +! Debug: eq int = const 0 to int k = [S+$12-$12] (used reg = ) +xor ax,ax +mov -$10[bp],ax +!BCC_EOS +! 234 } +! 235 else +! 236 { +jmp .F +.D: +! 237 k = 1; +! Debug: eq int = const 1 to int k = [S+$12-$12] (used reg = ) +mov ax,*1 +mov -$10[bp],ax +!BCC_EOS +! 238 } +! 239 +! 240 i = 0; +.F: +! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = ) +xor ax,ax +mov -6[bp],ax +!BCC_EOS +! 241 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 +! 242 while(i < string->length) { +jmp .11 +.12: +! 243 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 .13 +.14: +! 244 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 .15 +.16: +! 245 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 +! 246 } +! 247 last = i; +.15: +! 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 +! 248 } +! 249 ++i; +.13: +! Debug: preinc unsigned int i = [S+$12-8] (used reg = ) +mov ax,-6[bp] +inc ax +mov -6[bp],ax +!BCC_EOS +! 250 } +! 251 if (i > last+1) { +.11: +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 .12 +.17: +.10: +! 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: +! 252 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 +! 253 } +! 254 +! 255 return result; +.18: +mov ax,-$E[bp] +add sp,*$C +pop si +pop di +pop bp ret -! 33 -! 34 dump_ax_return(input) -! 35 void* input; -export _dump_ax_return -_dump_ax_return: !BCC_EOS -! 36 { -! 37 return input; +! 256 +! 257 } +! 258 +! 259 String_Array *create_length_string_array(array_size) +! Register BX SI used in function length_string_split +! 260 int array_size; +export _create_length_string_array +_create_length_string_array: +!BCC_EOS +! 261 { +! 262 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 +! 263 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 +! 264 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 +! 265 return result; +mov ax,-6[bp] +inc sp +inc sp pop si pop di pop bp ret !BCC_EOS -! 38 } -! 39 -! 40 void dump_ax(input) -! 41 void* input; -export _dump_ax -_dump_ax: -!BCC_EOS -! 42 { -! 43 -! 44 dump_ax_return(input) +! 266 } +! 267 +! 268 +! 269 Length_String *create_length_str +! Register BX used in function create_length_string_array +! 269 ing(length, chars) +! 270 unsigned int length; +export _create_length_string +_create_length_string: +!BCC_EOS +! 271 char *chars; +!BCC_EOS +! 272 { +! 273 +! 274 Length_String *legth_string = malloc(sizeof(Length_String)); 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 () int = dump_ax_return+0 (used reg = ) -call _dump_ax_return +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 -!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 +! 275 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 -! 51 } +! 276 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 +! 277 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] +mov bx,ax +! Debug: eq int = const 0 to char = [bx+0] (used reg = ) +xor al,al +mov [bx],al +!BCC_EOS +! 278 +! 279 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 +! 280 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 +! 281 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 +! 282 +! 283 return legth_string; +mov ax,-6[bp] +add sp,*4 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 "driver/disk.h" +!BCC_EOS +! 284 # 8 "main.c" +! 8 } +! 9 # 1 "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 @@ -377,167 +1190,168 @@ _disk_service_read_data_from_disk.index set 2 !BCC_ENDASM ! 52 } ret -! 53 # 11 "main.c" -! 11 #define SPACE_VBR_RECORD 2048 -! 12 -! 13 #define DEFAULT_ENTRY_SIZE 1 -! 14 -! 15 #define NUMBER_OF_MBR_PARTITIONS 4 -! 16 -! 17 #define DEFAULT_DATA_POINTER_SIZE 4 -! 18 +! 53 # 12 "main.c" +! 12 #define SPACE_VBR_RECORD 2048 +! 13 +! 14 #define DEFAULT_ENTRY_SIZE 1 +! 15 +! 16 #define NUMBER_OF_MBR_PARTITIONS 4 +! 17 +! 18 #define DEFAULT_DATA_POINTER_SIZE 4 ! 19 ! 20 -! 21 void dump_ax(input); +! 21 +! 22 void dump_ax(input); !BCC_EOS -! 22 void print_stack(argument); +! 23 void print_stack(argument); !BCC_EOS -! 23 void print_newline(); +! 24 void print_newline(); !BCC_EOS -! 24 -! 25 typedef struct Directory_Table Directory_Table; +! 25 +! 26 typedef struct Directory_Table Directory_Table; !BCC_EOS -! 26 typedef struct Struct_Table_Entry Table_Entry; +! 27 typedef struct Struct_Table_Entry Table_Entry; !BCC_EOS -! 27 typedef struct struct_partition_control partition_control; +! 28 typedef struct struct_partition_control partition_control; !BCC_EOS -! 28 typedef struct File_System_Control_Information FSCI; +! 29 typedef struct File_System_Control_ +! 29 Information FSCI; !BCC_EOS -! 29 typedef struct meta_information_format mif; +! 30 typedef struct meta_information_format mif; !BCC_EOS -! 30 typedef struct tag_record tag_record; +! 31 typedef struct tag_record tag_record; !BCC_EOS -! 31 typedef struct lsfs_file lsfs_file; +! 32 typedef struct lsfs_file lsfs_file; !BCC_EOS -! 32 typedef struct Parameter_Struct Parameter_Struct; +! 33 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; +! 34 +! 35 typedef enum Table_Entry_Kind +! 36 { +! 37 +! 38 ENTRY_EMPTY = 0, +! 39 ENTRY_FILE = 1, +! 40 ENTRY_DIRECTORY = 2, +! 41 } Table_Entry_Kind; !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; +! 42 +! 43 typedef enum Service_Action +! 44 { +! 45 SERIVCE_LOAD_DISK = 1, +! 46 SERVICE_FIND_ENTRY = 2, +! 47 SERIVCE_READ_DATA = 3, +! 48 SERIVCE_WRITE_DATA = 4, +! 49 +! 50 } Service_Action; !BCC_EOS -! 50 -! 51 struct Struct_Table_Entry -! 52 { -! 53 char filename[256]; +! 51 +! 52 struct Struct_Table_Entry +! 53 { +! 54 char filename[256]; !BCC_EOS -! 54 long file_id[2]; +! 55 long file_id[2]; !BCC_EOS -! 55 long file_size[2]; +! 56 long file_size[2]; !BCC_EOS -! 56 void* ext_file_data_low; +! 57 void* ext_file_data_low; !BCC_EOS -! 57 void* ext_file_data_high; +! 58 void* ext_file_data_high; !BCC_EOS -! 58 long number_sector_s; +! 59 long number_sector_s; !BCC_EOS -! 59 short entry_kind; +! 60 short entry_kind; !BCC_EOS -! 60 short extra_control_bits1; +! 61 short extra_control_bits1; !BCC_EOS -! 61 short extra_control_bits2; +! 62 short extra_control_bits2; !BCC_EOS -! 62 short extra_control_bits3; +! 63 short extra_control_bits3; !BCC_EOS -! 63 long table_entry_sector_index[2]; +! 64 long table_entry_sector_index[2]; !BCC_EOS -! 64 long data_pointer[27 * 2]; +! 65 long data_pointer[27 * 2]; !BCC_EOS -! 65 }; +! 66 }; !BCC_EOS -! 66 -! 67 struct File_System_Control_Information -! 68 { -! 69 char filesystem_information[256]; +! 67 +! 68 struct File_System_Control_Information +! 69 { +! 70 char filesystem_information[256]; !BCC_EOS -! 70 long master_table_index[2]; +! 71 long master_table_index[2]; !BCC_EOS -! 71 long this_partition_offset_on_disk[2]; +! 72 long this_partition_offset_on_disk[2]; !BCC_EOS -! 72 long next -! 72 _free_sector[2]; +! 73 long next_free_sector[2]; !BCC_EOS -! 73 long next_uniqe_id[2]; +! 74 long next_uniqe_id[2]; !BCC_EOS -! 74 long next_sector_reuse_pointer[2]; +! 75 long next_sector_reuse_pointer[2]; !BCC_EOS -! 75 long last_sector_index_on_partition[2]; +! 76 long last_sector_index_on_partition[2]; !BCC_EOS -! 76 long maximum_sectors_on_disk[2]; +! 77 long maximum_sectors_on_disk[2]; !BCC_EOS -! 77 long sector_size_on_disk[2]; +! 78 long sector_size_on_disk[2]; !BCC_EOS -! 78 long not_used[48]; +! 79 long not_used[48]; !BCC_EOS -! 79 -! 80 }; +! 80 +! 81 }; !BCC_EOS -! 81 -! 82 typedef struct Directory_Table -! 83 { -! 84 Table_Entry entries[16 ]; +! 82 +! 83 typedef struct Directory_Table +! 84 { +! 85 Table_Entry entries[16 ]; !BCC_EOS -! 85 -! 86 }; +! 86 +! 87 }; !BCC_EOS -! 87 -! 88 struct Parameter_Struct -! 89 { -! 90 char* path; +! 88 +! 89 struct Parameter_Struct +! 90 { +! 91 char* path; !BCC_EOS -! 91 char* new_path; +! 92 char* new_path; !BCC_EOS -! 92 int buffer_segment; +! 93 int buffer_segment; !BCC_EOS -! 93 int buffer_address; +! 94 int buffer_address; !BCC_EOS -! 94 int buffer_size; +! 95 int buffer_size; !BCC_EOS -! 95 int data_length; +! 96 int data_length; !BCC_EOS -! 96 int byte_offset_into_file; +! 97 int byte_offset_into_file; !BCC_EOS -! 97 Table_Entry_Kind entry_kind; +! 98 Table_Entry_Kind entry_kind; !BCC_EOS -! 98 }; +! 99 }; !BCC_EOS -! 99 -! 100 int main(selector, pointer_parameter_segment, pointer_parameter_struct) -! 101 int selector; +! 100 +! 101 int main(selector, pointer_parameter_segment, pointer_parameter_struct) +! 102 int selector; export _main _main: !BCC_EOS -! 102 void* pointer_parameter_segment; +! 103 void* pointer_parameter_segment; !BCC_EOS -! 103 void* pointer_parameter_struct; +! 104 void* pointer_parameter_struct; !BCC_EOS -! 104 { -! 105 +! 105 { ! 106 ! 107 -! 108 FSCI fsci; +! 108 +! 109 FSCI fsci; !BCC_EOS -! 109 Service_Action service_action; +! 110 +! 111 Service_Action service_action; !BCC_EOS -! 110 Directory_Table current_table; +! 112 Directory_Table current_table; !BCC_EOS -! 111 Parameter_Struct parameter_struct; +! 113 Parameter_Struct parameter_struct; !BCC_EOS -! 112 int local_segment = 0x7e0; +! 114 int local_segment = 0x7e0; push bp mov bp,sp push di @@ -547,76 +1361,103 @@ add sp,#-$2214 mov ax,#$7E0 mov -$2218[bp],ax !BCC_EOS -! 113 int stack_segment = 0x8fc0; +! 115 unsigned int heap_start = 0x2000; dec sp dec sp -! Debug: eq unsigned int = const $8FC0 to int stack_segment = [S+$221C-$221C] (used reg = ) -mov ax,#$8FC0 +! Debug: eq int = const $2000 to unsigned int heap_start = [S+$221C-$221C] (used reg = ) +mov ax,#$2000 mov -$221A[bp],ax !BCC_EOS -! 114 int path_length; +! 116 unsigned int heap_end = 0xffff; +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 +!BCC_EOS +! 117 int stack_segment = 0x8fc0; +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 +!BCC_EOS +! 118 int path_length; !BCC_EOS -! 115 long index_as_long; +! 119 long index_as_long; !BCC_EOS -! 116 -! 117 char local_path[256]; +! 120 +! 121 +! 121 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 !BCC_EOS -! 118 service_action = selector; -add sp,#-$106 -! Debug: eq int selector = [S+$2322+2] to int service_action = [S+$2322-$208] (used reg = ) +! 122 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 -! 119 -! 120 switch (service_action) +! 123 +! 124 switch (service_action) mov ax,-$206[bp] -! 121 { -br .3 -! 122 case SERIVCE_LOAD_DISK: -! 123 { -.4: -! 124 -! 125 -! 126 -! 127 -! 128 index_as_long = pointer_parameter_struct; -! Debug: eq * void pointer_parameter_struct = [S+$2322+6] to long index_as_long = [S+$2322-$2222] (used reg = ) +! 125 { +br .1C +! 126 case SERIVCE_LOAD_DISK: +! 127 { +.1D: +! 128 +! 129 +! 130 +! 131 +! 132 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 -$2220[bp],ax -mov -$221E[bp],bx +mov -$2224[bp],ax +mov -$2222[bp],bx !BCC_EOS -! 129 disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment); -! Debug: list int stack_segment = [S+$2322-$221C] (used reg = ) -push -$221A[bp] -! Debug: list * struct File_System_Control_Information fsci = S+$2324-$206 (used reg = ) +! 133 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] push bx ! Debug: list int = const 1 (used reg = ) mov ax,*1 push ax -! Debug: list long index_as_long = [S+$2328-$2222] (used reg = ) -push -$221E[bp] -push -$2220[bp] +! 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 !BCC_EOS -! 130 print("File System has been loaded: "); -! Debug: list * char = .5+0 (used reg = ) -mov bx,#.5 +! 134 print("File System has been loaded: "); +! Debug: list * char = .1E+0 (used reg = ) +mov bx,#.1E push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 131 print_newline(); +! 135 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 132 print_stack(fsci.filesystem_information); -! Debug: list * char fsci = S+$2322-$206 (used reg = ) +! 136 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 +!BCC_EOS +! 137 print_stack(fsci.filesystem_information); +! Debug: list * char fsci = S+$2228-$206 (used reg = ) lea bx,-$204[bp] push bx ! Debug: func () void = print_stack+0 (used reg = ) @@ -624,114 +1465,202 @@ call _print_stack inc sp inc sp !BCC_EOS -! 133 print_newline(); +! 138 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 134 } break; -br .1 +! 139 } break; +br .1A !BCC_EOS -! 135 case SERVICE_FIND_ENTRY: -! 136 { -.6: -! 137 memcpy(¶meter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct)); +! 140 case SERVICE_FIND_ENTRY: +! 141 { +.1F: +! 142 String_Array *path_array; +!BCC_EOS +! 143 int i; +!BCC_EOS +! 144 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+$2324+4] (used reg = ) +! Debug: list * void pointer_parameter_segment = [S+$222E+4] (used reg = ) push 6[bp] -! Debug: list * void pointer_parameter_struct = [S+$2326+6] (used reg = ) +! Debug: list * void pointer_parameter_struct = [S+$2230+6] (used reg = ) push 8[bp] -! Debug: list int stack_segment = [S+$2328-$221C] (used reg = ) -push -$221A[bp] -! Debug: list * struct Parameter_Struct parameter_struct = S+$232A-$2218 (used reg = ) +! 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] push bx ! Debug: func () void = memcpy+0 (used reg = ) call _memcpy add sp,*$A !BCC_EOS -! 138 path_length = strlen(parameter_struct.path, pointer_parameter_segment); -! Debug: list * void pointer_parameter_segment = [S+$2322+4] (used reg = ) +! 145 path_length = strlen(parameter_struct.path, pointer_parameter_segment); +! Debug: list * void pointer_parameter_segment = [S+$222C+4] (used reg = ) push 6[bp] -! Debug: list * char parameter_struct = [S+$2324-$2218] (used reg = ) +! Debug: list * char parameter_struct = [S+$222E-$2218] (used reg = ) push -$2216[bp] ! Debug: func () int = strlen+0 (used reg = ) call _strlen add sp,*4 -! Debug: eq int = ax+0 to int path_length = [S+$2322-$221E] (used reg = ) -mov -$221C[bp],ax +! Debug: eq int = ax+0 to int path_length = [S+$222C-$2222] (used reg = ) +mov -$2220[bp],ax !BCC_EOS -! 139 memcpy(local_path, stack_segment, parameter_struct.path, pointer_parameter_segment, path_length); -! Debug: list int path_length = [S+$2322-$221E] (used reg = ) -push -$221C[bp] -! Debug: list * void pointer_parameter_segment = [S+$2324+4] (used reg = ) +! 146 local_path = malloc(256); +! Debug: list int = const $100 (used reg = ) +mov ax,#$100 +push ax +! Debug: func () * void = malloc+0 (used reg = ) +call _malloc +inc sp +inc sp +! Debug: eq * void = ax+0 to * char local_path = [S+$222C-$2228] (used reg = ) +mov -$2226[bp],ax +!BCC_EOS +! 147 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 = ) push 6[bp] -! Debug: list * char parameter_struct = [S+$2326-$2218] (used reg = ) +! Debug: list * char parameter_struct = [S+$2230-$2218] (used reg = ) push -$2216[bp] -! Debug: list int stack_segment = [S+$2328-$221C] (used reg = ) -push -$221A[bp] -! Debug: list * char local_path = S+$232A-$2322 (used reg = ) -lea bx,-$2320[bp] -push bx +! 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: func () void = memcpy+0 (used reg = ) call _memcpy add sp,*$A !BCC_EOS -! 140 local_path[path_length] = 0; -! Debug: ptradd int path_length = [S+$2322-$221E] to [$100] char local_path = S+$2322-$2322 (used reg = ) -mov ax,-$221C[bp] -mov bx,bp -add bx,ax -! Debug: eq int = const 0 to char = [bx-$2320] (used reg = ) +! 148 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] +mov bx,ax +! Debug: eq int = const 0 to char = [bx+0] (used reg = ) xor al,al -mov -$2320[bx],al +mov [bx],al !BCC_EOS -! 141 print_stack(local_path); -! Debug: list * char local_path = S+$2322-$2322 (used reg = ) -lea bx,-$2320[bp] -push bx -! Debug: func () void = print_stack+0 (used reg = ) -call _print_stack +! 149 print(local_path); +! Debug: list * char local_path = [S+$222C-$2228] (used reg = ) +push -$2226[bp] +! Debug: func () void = print+0 (used reg = ) +call _print inc sp inc sp !BCC_EOS -! 142 print_newline(); +! 150 +! 151 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: 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 +!BCC_EOS +! 152 +! 153 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 154 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 143 disk_service_read_data_from_disk(fsci.master_table_index[0], 16 , ¤t_table, stack_segment); -! Debug: list int stack_segment = [S+$2322-$221C] (used reg = ) -push -$221A[bp] -! Debug: list * struct Directory_Table current_table = S+$2324-$2208 (used reg = ) +! 155 for (i = 0; i < path_array->length; ++i) +! Debug: eq int = const 0 to int i = [S+$222C-$222C] (used reg = ) +xor ax,ax +mov -$222A[bp],ax +!BCC_EOS +!BCC_EOS +! 156 { +jmp .22 +.23: +! 157 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] +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 } +! 160 print_newline(); +.21: +! Debug: preinc int i = [S+$222C-$222C] (used reg = ) +mov ax,-$222A[bp] +inc ax +mov -$222A[bp],ax +.22: +mov bx,-$2228[bp] +! Debug: lt unsigned int = [bx+0] to int i = [S+$222C-$222C] (used reg = ) +mov ax,-$222A[bp] +cmp ax,[bx] +jb .23 +.24: +.20: +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 161 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 162 +! 163 print_newline(); +! Debug: func () void = print_newline+0 (used reg = ) +call _print_newline +!BCC_EOS +! 164 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] push bx ! Debug: list int = const $10 (used reg = ) mov ax,*$10 push ax -! Debug: list long fsci = [S+$2328-$106] (used reg = ) +! 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 !BCC_EOS -! 144 print("Current table: "); -! Debug: list * char = .7+0 (used reg = ) -mov bx,#.7 +! 165 print("Current table: "); +! Debug: list * char = .25+0 (used reg = ) +mov bx,#.25 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 145 print_newline( -! 145 ); +! 166 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 146 print_stack(current_table.entries[0].filename); -! Debug: list * char current_table = S+$2322-$2208 (used reg = ) +! 167 print_stack(current_table.entries[0].filename); +! Debug: list * char current_table = S+$222C-$2208 (used reg = ) lea bx,-$2206[bp] push bx ! Debug: func () void = print_stack+0 (used reg = ) @@ -739,12 +1668,12 @@ call _print_stack inc sp inc sp !BCC_EOS -! 147 print_newline(); +! 168 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 148 print_stack(current_table.entries[1].filename); -! Debug: list * char current_table = S+$2322-$2008 (used reg = ) +! 169 print_stack(current_table.entries[1].filename); +! Debug: list * char current_table = S+$222C-$2008 (used reg = ) lea bx,-$2006[bp] push bx ! Debug: func () void = print_stack+0 (used reg = ) @@ -752,12 +1681,12 @@ call _print_stack inc sp inc sp !BCC_EOS -! 149 print_newline(); +! 170 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 150 print_stack(current_table.entries[2].filename); -! Debug: list * char current_table = S+$2322-$1E08 (used reg = ) +! 171 print_stack(current_table.entries[2].filename); +! Debug: list * char current_table = S+$222C-$1E08 (used reg = ) lea bx,-$1E06[bp] push bx ! Debug: func () void = print_stack+0 (used reg = ) @@ -765,74 +1694,78 @@ call _print_stack inc sp inc sp !BCC_EOS -! 151 print_newline(); +! 172 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 152 } break; -jmp .1 -!BCC_EOS -! 153 case SERIVCE_READ_DATA: -! 154 { -.8: -! 155 # 163 -! 163 -! 164 print("Hit READ case"); -! Debug: list * char = .9+0 (used reg = ) -mov bx,#.9 +! 173 +! 174 } break; +jmp .1A +!BCC_EOS +! 175 case SERIVCE_READ_DATA: +! 176 { +.26: +! 177 # 185 +! 185 +! 186 print("Hit READ case"); +! Debug: list * char = .27+0 (used reg = ) +mov bx,#.27 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 165 } break; -jmp .1 +! 187 } break; +jmp .1A !BCC_EOS -! 166 case SERIVCE_WRITE_DATA: -! 167 { -.A: -! 168 print("Hit WRITE case"); -! Debug: list * char = .B+0 (used reg = ) -mov bx,#.B +! 188 case SERI +! 188 VCE_WRITE_DATA: +! 189 { +.28: +! 190 print("Hit WRITE case"); +! Debug: list * char = .29+0 (used reg = ) +mov bx,#.29 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 169 } break; -jmp .1 +! 191 } break; +jmp .1A !BCC_EOS -! 170 default: -! 171 { -.C: -! 172 print("Default case"); -! Debug: list * char = .D+0 (used reg = ) -mov bx,#.D +! 192 default: +! 193 { +.2A: +! 194 print("Default case"); +! Debug: list * char = .2B+0 (used reg = ) +mov bx,#.2B push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 173 } -! 174 } -! 175 -! 176 return 0; -jmp .1 -.3: +! 195 } +! 196 } +! 197 +! 198 return 0; +jmp .1A +.1C: +add sp,*-4 sub ax,*1 -beq .4 +beq .1D sub ax,*1 -beq .6 +beq .1F sub ax,*1 -je .8 +je .26 sub ax,*1 -je .A -jmp .C -.1: -..FFFF = -$2322 +je .28 +jmp .2A +.1A: +..FFFF = -$222C +add sp,*4 xor ax,ax lea sp,-4[bp] pop si @@ -840,28 +1773,28 @@ pop di pop bp ret !BCC_EOS -! 177 -! 178 } -! 179 +! 199 +! 200 } +! 201 ! Register BX used in function main -.D: -.E: +.2B: +.2C: .ascii "Default case" .byte 0 -.B: -.F: +.29: +.2D: .ascii "Hit WRITE case" .byte 0 -.9: -.10: +.27: +.2E: .ascii "Hit READ case" .byte 0 -.7: -.11: +.25: +.2F: .ascii "Current table: " .byte 0 -.5: -.12: +.1E: +.30: .ascii "File System has been loaded: " .byte 0 .bss diff --git a/std_singos/stdio.h b/std_singos/stdio.h index 92f21fe..d27fb20 100644 --- a/std_singos/stdio.h +++ b/std_singos/stdio.h @@ -1,4 +1,5 @@ void print(string); +void* dump_ax_return(input); void print(string) char* string; @@ -31,7 +32,7 @@ void print_stack(argument) #endasm } -dump_ax_return(input) +void* dump_ax_return(input) void* input; { return input; @@ -40,7 +41,6 @@ void* input; void dump_ax(input) void* input; { - // Force the variable in ax dump_ax_return(input) #asm push bp diff --git a/std_singos/stdlib.h b/std_singos/stdlib.h new file mode 100644 index 0000000..e40eb7f --- /dev/null +++ b/std_singos/stdlib.h @@ -0,0 +1,35 @@ +unsigned int global_heap_start = 0; +unsigned int global_heap_end = 0; +unsigned int global_heap_next = 0; + +void* malloc(num_bytes); +int set_heap_settings(param_start, param_end); +unsigned int get_heap_next(); + +void* malloc(num_bytes) +int num_bytes; +{ + unsigned int allocated_pointer = global_heap_next; + global_heap_next = global_heap_next + num_bytes; + if (global_heap_next > global_heap_end) + { + return 0; /* No more memory */ + } + + return allocated_pointer; +} + +int set_heap_settings(param_start, param_end) +unsigned int param_start; +unsigned int param_end; +{ + global_heap_start = param_start; + global_heap_next = param_start; + global_heap_end = param_end; + return 0; +} + +unsigned int get_heap_next() +{ + return global_heap_next; +} \ No newline at end of file diff --git a/std_singos/string.h b/std_singos/string.h index 4fb57ba..683d7f8 100644 --- a/std_singos/string.h +++ b/std_singos/string.h @@ -1,7 +1,30 @@ + + +typedef struct Length_String { + short dynamic; + unsigned int length; + char *chars; +} Length_String; + +typedef struct String_Array { + unsigned int length; + Length_String **strings; +} String_Array; + void strcpy (destination, destination_segment, source, source_segment ); int strlen (source, source_segment); void memcpy (destination, destination_segment, source, source_segment, num_bytes ); +// Additionals to standard c lib. +String_Array *string_split_c(string, delim, keep_delim); +Length_String *make_length_string(length, chars); +Length_String *make_length_string_c(cstring); +String_Array *length_string_split(string, delim, keep_delim); +String_Array *create_length_string_array(array_size); +Length_String *create_length_string(length, chars); + + + int strlen (source, source_segment) { #asm @@ -141,4 +164,121 @@ int num_bytes; pop bp #endasm +} + +String_Array *string_split_c(string, delim, keep_delim) +char *string; +char delim; +short keep_delim; +{ + return length_string_split(make_length_string_c(string), delim, keep_delim); +} + +Length_String *make_length_string_c(cstring) +char *cstring; +{ + return make_length_string(strlen(cstring, 0x7e0), cstring); +} + +Length_String *make_length_string(length, chars) +unsigned int length; +char *chars; +{ + + Length_String *legth_string = malloc(sizeof(Length_String)); + + char *copy = malloc(length + 1); // Space for null terminator + memcpy(copy, 0x7e0, chars, 0x7e0, length); + copy[length] = '\0'; + + legth_string->dynamic = 0; + legth_string->length = length; + legth_string->chars = (char *)chars; + + return legth_string; +} + +String_Array *length_string_split(string, delim, keep_delim) +Length_String *string; +char delim; +short keep_delim; +{ + unsigned int i; + unsigned int last; + + unsigned int count = 0; + unsigned int insert_index = 0; + String_Array *result; + int k; + + i = 0; + last = 0; + while(i < string->length) { + if (string->chars[i] == delim) { + if (i > last+1) { + ++count; + } + last = i; + } + ++i; + } + if (i > last+1) { + ++count; + } + + result = create_length_string_array(count); + + if (keep_delim) + { + k = 0; + } + else + { + k = 1; + } + + i = 0; + last = 0; + while(i < string->length) { + if (string->chars[i] == delim) { + if (i > last+1) { + result->strings[insert_index++] = create_length_string(i-(last+k), string->chars+(last+k)); + } + last = i; + } + ++i; + } + if (i > last+1) { + result->strings[insert_index++] = create_length_string(i-(last+k), ((string->chars)+(last+k))); + } + + return result; + +} + +String_Array *create_length_string_array(array_size) +int array_size; +{ + String_Array *result = malloc(sizeof(String_Array)); + result->length = array_size; + result->strings = malloc(array_size * sizeof(Length_String)); + return result; +} + + +Length_String *create_length_string(length, chars) +unsigned int length; +char *chars; +{ + + Length_String *legth_string = malloc(sizeof(Length_String)); + char *copy = malloc(length + 1); // Space for null terminator + memcpy(copy, 0x7e0, chars, 0x7e0, length); + copy[length] = '\0'; + + legth_string->dynamic = 1; + legth_string->length = length; + legth_string->chars = copy; + + return legth_string; } \ No newline at end of file