diff --git a/disk.out b/disk.out index c4415f7..ebbd0b7 100644 Binary files a/disk.out and b/disk.out differ diff --git a/driver/disk.h b/driver/disk.h index a6054c7..ccd6b81 100644 --- a/driver/disk.h +++ b/driver/disk.h @@ -19,25 +19,17 @@ unsigned int data_buffer_segment; pusha lsfs_load_data: mov ax, index - call 0x0000:0x7C2A mov WORD [DAPACK.lba_addr_dw_low], ax mov bx, number_sectors - mov ax, bx - call 0x0000:0x7C2A mov WORD [DAPACK.blkcnt], bx mov cx, data_buffer_segment - mov ax, cx - call 0x0000:0x7C2A mov WORD [DAPACK.db_addr_segment], cx mov dx, data_buffer; - mov ax, dx - call 0x0000:0x7C2A mov WORD [DAPACK.db_addr_offset], dx mov si, #DAPACK ; address of mov ah, #0x42 ; READ mov dl, [global_disk_identifier] int #0x13 - ;call 0x0000:0x7C2A popa pop bp ret diff --git a/implementation/lsfs.c b/implementation/lsfs.c index 0d26cc1..5cfad1b 100644 --- a/implementation/lsfs.c +++ b/implementation/lsfs.c @@ -91,7 +91,6 @@ unsigned int data_segment; int data_pointer_index = 0; /* start at first data pointer. */ - dump_ax(file->size); if (data_length > buffer_size) { data_length = buffer_size; @@ -121,7 +120,6 @@ unsigned int data_segment; } disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], DEFAULT_DATA_POINTER_SIZE, tmp_buffer, 0x7e0); print_newline(); - dump_ax(file->data_pointer[data_pointer_index]); print_newline(); memcpy((data + amount_read), data_segment, tmp_buffer, 0x7e0, amount_to_read); data_length -= amount_to_read; diff --git a/main.c b/main.c index e7a5a59..7e0bcd2 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,3 @@ -/* Adress to dump ax, 7C2A*/ -/* Address to print 7C47*/ -/* */ -/* */ #include "main.h" @@ -43,7 +39,6 @@ void* pointer_parameter_struct; print_newline(); print(fsci->filesystem_information); print_newline(); - dump_ax(fsci->master_table_index[0]); print_newline(); } break; case SERVICE_FIND_ENTRY: @@ -51,8 +46,8 @@ void* pointer_parameter_struct; String_Array *path_array; lsfs_file* find_file; int i; - dump_ax(fsci->master_table_index[0]); disk_service_read_data_from_disk(fsci->master_table_index[0], (long) DEFAULT_TABLE_SIZE, ¤t_table, stack_segment); + /* print("Current table: "); print_newline(); print_stack(current_table.entries[0].filename); @@ -61,11 +56,10 @@ void* pointer_parameter_struct; print_newline(); print_stack(current_table.entries[2].filename); print_newline(); - + */ memcpy(¶meter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct)); path_length = strlen(parameter_struct.path, pointer_parameter_segment); - dump_ax(path_length); local_path = malloc(256); memcpy(local_path, local_segment, parameter_struct.path, pointer_parameter_segment, path_length); local_path[path_length] = 0; @@ -90,13 +84,10 @@ void* pointer_parameter_struct; print(find_file->filename); print_newline(); print("Kernel file id: "); - dump_ax(find_file->file_id[0]); print_newline(); print("Kernel file size: "); - dump_ax(find_file->size[0]); print_newline(); print("Kernel first data pointer: "); - dump_ax(find_file->data_pointer[0]); lsfs_disk_read_data_from_file(find_file, 0xffff, 0x00, (long) 0x0, 0x50); diff --git a/main.s b/main.s index 5432cd2..1a879c3 100644 --- a/main.s +++ b/main.s @@ -28,18 +28,34 @@ _print.string set 2 push bp mov bp,sp mov si,4[bp] - call 0x0000:0x7C47 + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + new_print_print: + ; Prints string in si + ; IN si: zero terminated string to print + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov ah, #0xE ; Specify 'int 0x10' 'teletype output' function + ; [AL = Character, BH = Page Number, BL = Colour (in graphics mode)] + .new_print_printchar: + lodsb ; Load byte at address SI into AL, and increment SI + test al, al + jz .new_print_done ; If the character is zero (NUL), stop writing the string + int #0x10 ; Otherwise, print the character via 'int 0x10' + jmp .new_print_printchar ; Repeat for the next character + .new_print_done: + pop bp -! 13 endasm +! 28 endasm !BCC_ENDASM -! 14 } +! 29 } ret -! 15 -! 16 void print_stack(argument) -! 17 { +! 30 +! 31 +! 32 void print_stack(argument) +! 33 { export _print_stack _print_stack: -! 18 #asm +! 34 #asm !BCC_ASM _print_stack.argument set 2 @@ -51,23 +67,37 @@ _print_stack.argument set 2 mov ax, ss mov ds, ax mov si,4[bp] - call 0x0000:0x7C47 + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + print_stack_print: + ; Prints string in si + ; IN si: zero terminated string to print + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov ah, #0xE ; Specify 'int 0x10' 'teletype output' function + ; [AL = Character, BH = Page Number, BL = Colour (in graphics mode)] + .print_stack_printchar: + lodsb ; Load byte at address SI into AL, and increment SI + test al, al + jz .print_stack_done ; If the character is zero (NUL), stop writing the string + int #0x10 ; Otherwise, print the character via 'int 0x10' + jmp .print_stack_printchar ; Repeat for the next character + .print_stack_done: pop ax pop ds pop bp -! 32 endasm +! 61 endasm !BCC_ENDASM -! 33 } +! 62 } ret -! 34 -! 35 void* dump_ax_return(input) -! 36 void* input; +! 63 +! 64 void* dump_ax_return(input) +! 65 void* input; export _dump_ax_return _dump_ax_return: !BCC_EOS -! 37 { -! 38 return input; +! 66 { +! 67 return +! 67 input; push bp mov bp,sp push di @@ -78,20 +108,20 @@ pop di pop bp ret !BCC_EOS -! 39 } -! 40 -! 41 void dump_ax(input) -! 42 void* input; +! 68 } +! 69 +! 70 void dump_ax(input) +! 71 void* input; export _dump_ax _dump_ax: !BCC_EOS -! 43 { -! 44 dump_ax_return(input) +! 72 { +! 73 dump_ax_return(input) push bp mov bp,sp push di push si -! 45 #asm +! 74 #asm ! Debug: list * void input = [S+6+2] (used reg = ) push 4[bp] ! Debug: func () * void = dump_ax_return+0 (used reg = ) @@ -104,22 +134,41 @@ _dump_ax.input set 8 .dump_ax.input set 4 push bp mov bp,sp - call 0x000:0x7C2A + + pusha ; save registers + mov bx, ax + mov ah, #0xE ; Teletype output + + mov cx, #4 ; 4 nipples in a 16 bit word + .dump_ax_loop: + rol bx, #4 ; rotate to next nipple + mov al, bl ; we copy to al because we need to mask only the low 4 bits + and al, #%1111 ; Do the masking + add al, #48 ; convert to ASCII + cmp al, #57 ; If we are greater than 9 ascii, we add 7 to make digit 10 be represented as 'A' + jbe .dump_ax_skip ; -|- + add al, #7 ; -|- + .dump_ax_skip: ; -|- + int #0x10 ; BIOS call 'output' + loop .dump_ax_loop + + popa ; restore registers + pop bp -! 50 endasm +! 98 endasm !BCC_ENDASM !BCC_EOS -! 51 } +! 99 } pop si pop di pop bp ret -! 52 -! 53 void print_newline() -! 54 { +! 100 +! 101 void print_newline() +! 102 { export _print_newline _print_newline: -! 55 #asm +! 103 #asm !BCC_ASM printCRLF: @@ -129,11 +178,11 @@ _print_newline: mov al, #10 int #0x10 ret -! 63 endasm +! 111 endasm !BCC_ENDASM -! 64 } +! 112 } ret -! 65 # 1 "std_singos/stdlib.h" +! 113 # 1 "std_singos/stdlib.h" ! 1 unsigned int global_heap_start = 0; export _global_heap_start _global_heap_start: @@ -340,7 +389,8 @@ push si mov ax,4[bp] mov [_global_heap_start],ax !BCC_EOS -! 53 global_heap_next = param_start; +! 53 global +! 53 _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 @@ -377,8 +427,7 @@ ret ! 61 # 19 "main.h" ! 19 } ! 20 # 2 "std_singos/string.h" -! 2 type -! 2 def struct Length_String { +! 2 typedef struct Length_String { ! 3 short dynamic; !BCC_EOS ! 4 unsigned int length; @@ -780,7 +829,8 @@ ret !BCC_EOS ! 238 } ! 239 -! 240 Length_String *make_length_string(length, chars) +! 240 Length_S +! 240 tring *make_length_string(length, chars) ! 241 unsigned int length; export _make_length_string _make_length_string: @@ -806,10 +856,9 @@ inc sp ! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = ) mov -6[bp],ax !BCC_EOS -! 246 char *copy = malloc(length +! 246 char *copy = malloc(length + 1); dec sp dec sp -! 246 + 1); ! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = ) mov ax,4[bp] ! Debug: list unsigned int = ax+1 (used reg = ) @@ -1317,7 +1366,8 @@ xor al,al mov [bx],al !BCC_EOS ! 334 -! 335 legth_string->dynamic = 1; +! 335 legth_ +! 335 string->dynamic = 1; mov bx,-6[bp] ! Debug: eq int = const 1 to short = [bx+0] (used reg = ) mov ax,*1 @@ -1347,9 +1397,8 @@ ret ! 340 # 21 "main.h" ! 21 } ! 22 # 1 "driver/disk.h" -! 1 int data_from_disk(index +! 1 int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); ! Register BX SI used in function create_length_string -! 1 , number_sectors, data_buffer, data_buffer_segment); !BCC_EOS ! 2 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); !BCC_EOS @@ -1383,25 +1432,17 @@ _disk_service_read_data_from_disk.index set 2 pusha lsfs_load_data: mov ax, 4[bp]; - call 0x0000:0x7C2A mov WORD [DAPACK.lba_addr_dw_low], ax mov bx, 8[bp]; - mov ax, bx - call 0x0000:0x7C2A mov WORD [DAPACK.blkcnt], bx mov cx, 14[bp]; - mov ax, cx - call 0x0000:0x7C2A mov WORD [DAPACK.db_addr_segment], cx mov dx, 12[bp]; ; - mov ax, dx - call 0x0000:0x7C2A mov WORD [DAPACK.db_addr_offset], dx mov si, #DAPACK ; address of mov ah, #0x42 ; READ mov dl, [global_disk_identifier] int #0x13 - ;call 0x0000:0x7C2A popa pop bp ret @@ -1418,11 +1459,11 @@ _disk_service_read_data_from_disk.index set 2 global_disk_identifier: db 0x80 -! 57 endasm +! 49 endasm !BCC_ENDASM -! 58 } +! 50 } ret -! 59 # 24 "main.h" +! 51 # 24 "main.h" ! 24 void dump_ax(input); !BCC_EOS ! 25 void print_stack(argument); @@ -1460,10 +1501,10 @@ ret !BCC_EOS ! 48 long this_partition_offset_on_disk[2]; !BCC_EOS -! 49 long next_free_sector[2]; +! 49 long next_free_sector[2 +! 49 ]; !BCC_EOS -! 50 long -! 50 next_uniqe_id[2]; +! 50 long next_uniqe_id[2]; !BCC_EOS ! 51 long next_sector_reuse_pointer[2]; !BCC_EOS @@ -1640,10 +1681,10 @@ mov -$A[bp],bx !BCC_EOS ! 83 ! 84 -! 85 Directory_Table *dir_table = lsfs_find_directory(path, 1 , fsc +! 85 Directory_Table *dir_table = lsfs_find_directory(pa dec sp dec sp -! 85 i); +! 85 th, 1 , fsci); ! Debug: list * struct File_System_Control_Information fsci = [S+$E+6] (used reg = ) push 8[bp] ! Debug: list int = const 1 (used reg = ) @@ -2113,8 +2154,8 @@ mov -8[bp],ax ! 150 { br .3C .3D: -! 151 for (j -! 151 = 0; j < 16 ; ++j) +! 151 +! 151 for (j = 0; j < 16 ; ++j) ! Debug: eq int = const 0 to int j = [S+$10-$C] (used reg = ) xor ax,ax mov -$A[bp],ax @@ -2496,8 +2537,8 @@ add sp,*4 ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 227 next_data = -! 227 data + amount_read; +! 227 +! 227 next_data = data + amount_read; ! Debug: ptradd unsigned int amount_read = [S+$1A-$10] to * char data = [S+$1A+6] (used reg = ) mov ax,-$E[bp] add ax,8[bp] @@ -2739,29 +2780,29 @@ ret !BCC_EOS ! 277 ! 278 } -! 279 # 8 "main.c" -! 8 int main(selector, pointer_parameter_segment, pointer_parameter_struct) +! 279 # 4 "main.c" +! 4 int main(selector, pointer_parameter_segment, pointer_parameter_struct) ! Register BX used in function lsfs_disk_read_data_from_file -! 9 int selector; +! 5 int selector; export _main _main: !BCC_EOS -! 10 void* pointer_parameter_segment; +! 6 void* pointer_parameter_segment; !BCC_EOS -! 11 void* pointer_parameter_struct; +! 7 void* pointer_parameter_struct; !BCC_EOS -! 12 { -! 13 -! 14 -! 15 -! 16 -! 17 Service_Action service_action; +! 8 { +! 9 +! 10 +! 11 +! 12 +! 13 Service_Action service_action; !BCC_EOS -! 18 Directory_Table current_table; +! 14 Directory_Table current_table; !BCC_EOS -! 19 Parameter_Struct parameter_struct; +! 15 Parameter_Struct parameter_struct; !BCC_EOS -! 20 int local_segment = 0x7e0; +! 16 int local_segment = 0x7e0; push bp mov bp,sp push di @@ -2771,30 +2812,30 @@ add sp,#-$2014 mov ax,#$7E0 mov -$2018[bp],ax !BCC_EOS -! 21 unsigned int heap_start = 0x2200; +! 17 unsigned int heap_start = 0x2200; dec sp dec sp ! Debug: eq int = const $2200 to unsigned int heap_start = [S+$201C-$201C] (used reg = ) mov ax,#$2200 mov -$201A[bp],ax !BCC_EOS -! 22 unsigned int heap_end = 0xffff; +! 18 unsigned int heap_end = 0xffff; dec sp dec sp ! Debug: eq unsigned int = const $FFFF to unsigned int heap_end = [S+$201E-$201E] (used reg = ) mov ax,#$FFFF mov -$201C[bp],ax !BCC_EOS -! 23 int stack_segment = 0x8fc0; +! 19 int stack_segment = 0x8fc0; dec sp dec sp ! Debug: eq unsigned int = const $8FC0 to int stack_segment = [S+$2020-$2020] (used reg = ) mov ax,#$8FC0 mov -$201E[bp],ax !BCC_EOS -! 24 int path_length; +! 20 int path_length; !BCC_EOS -! 25 long index_as_long = 0; +! 21 long index_as_long = 0; add sp,*-6 ! Debug: eq int = const 0 to long index_as_long = [S+$2026-$2026] (used reg = ) xor ax,ax @@ -2802,40 +2843,40 @@ xor bx,bx mov -$2024[bp],ax mov -$2022[bp],bx !BCC_EOS -! 26 -! 27 char *local_path = 0; +! 22 +! 23 char *local_path = 0; dec sp dec sp ! Debug: eq int = const 0 to * char local_path = [S+$2028-$2028] (used reg = ) xor ax,ax mov -$2026[bp],ax !BCC_EOS -! 28 FSCI *fsci = 0x2000; +! 24 FSCI *fsci = 0x2000; dec sp dec sp ! Debug: eq int = const $2000 to * struct File_System_Control_Information fsci = [S+$202A-$202A] (used reg = ) mov ax,#$2000 mov -$2028[bp],ax !BCC_EOS -! 29 service_action = selector; +! 25 service_action = selector; ! Debug: eq int selector = [S+$202A+2] to int service_action = [S+$202A-8] (used reg = ) mov ax,4[bp] mov -6[bp],ax !BCC_EOS -! 30 -! 31 switch (service_action) +! 26 +! 27 switch (service_action) mov ax,-6[bp] -! 32 { +! 28 { br .5E -! 33 case SERIV -! 33 CE_LOAD_DISK: -! 34 { +! 29 +! 29 case SERIVCE_LOAD_DISK: +! 30 { .5F: -! 35 -! 36 -! 37 -! 38 -! 39 set_heap_settings(heap_start, heap_end); +! 31 +! 32 +! 33 +! 34 +! 35 set_heap_settings(heap_start, heap_end); ! Debug: list unsigned int heap_end = [S+$202A-$201E] (used reg = ) push -$201C[bp] ! Debug: list unsigned int heap_start = [S+$202C-$201C] (used reg = ) @@ -2844,14 +2885,14 @@ push -$201A[bp] call _set_heap_settings add sp,*4 !BCC_EOS -! 40 index_as_long = pointer_parameter_struct; +! 36 index_as_long = pointer_parameter_struct; ! Debug: eq * void pointer_parameter_struct = [S+$202A+6] to long index_as_long = [S+$202A-$2026] (used reg = ) mov ax,8[bp] xor bx,bx mov -$2024[bp],ax mov -$2022[bp],bx !BCC_EOS -! 41 disk_service_read_data_from_disk(index_as_long, (long) 1, fsci, local_segment); +! 37 disk_service_read_data_from_disk(index_as_long, (long) 1, fsci, local_segment); ! Debug: list int local_segment = [S+$202A-$201A] (used reg = ) push -$2018[bp] ! Debug: list * struct File_System_Control_Information fsci = [S+$202C-$202A] (used reg = ) @@ -2868,7 +2909,7 @@ push -$2024[bp] call _disk_service_read_data_from_disk add sp,*$C !BCC_EOS -! 42 print("File System has been loaded: "); +! 38 print("File System has been loaded: "); ! Debug: list * char = .60+0 (used reg = ) mov bx,#.60 push bx @@ -2877,11 +2918,11 @@ call _print inc sp inc sp !BCC_EOS -! 43 print_newline(); +! 39 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 44 print(fsci->filesystem_information); +! 40 print(fsci->filesystem_information); ! Debug: cast * char = const 0 to [$100] char fsci = [S+$202A-$202A] (used reg = ) ! Debug: list * char fsci = [S+$202A-$202A] (used reg = ) push -$2028[bp] @@ -2890,47 +2931,27 @@ call _print inc sp inc sp !BCC_EOS -! 45 print_newline(); +! 41 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 46 dump_ax(fsci->master_table_index[0]); -mov bx,-$2028[bp] -! Debug: ptradd int = const 0 to [2] long = bx+$100 (used reg = ) -! Debug: list long = [bx+$100] (used reg = ) -push $102[bx] -push $100[bx] -! Debug: func () void = dump_ax+0 (used reg = ) -call _dump_ax -add sp,*4 -!BCC_EOS -! 47 print_newline(); +! 42 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 48 } break; +! 43 } break; br .5C !BCC_EOS -! 49 case SERVICE_FIND_ENTRY: -! 50 { +! 44 case SERVICE_FIND_ENTRY: +! 45 { .61: -! 51 String_Array *path_array; -!BCC_EOS -! 52 lsfs_file* find_file; +! 46 String_Array *path_array; !BCC_EOS -! 53 int i; +! 47 lsfs_file* find_file; !BCC_EOS -! 54 dump_ax(fsci->master_table_index[0]); -mov bx,-$2028[bp] -! Debug: ptradd int = const 0 to [2] long = bx+$100 (used reg = ) -! Debug: list long = [bx+$100] (used reg = ) -push $102[bx] -push $100[bx] -! Debug: func () void = dump_ax+0 (used reg = ) -call _dump_ax -add sp,*4 +! 48 int i; !BCC_EOS -! 55 disk_service_read_data_from_disk(fsci->master_table_index[0], (long) 16 , ¤t_table, stack_segment); +! 49 disk_service_read_data_from_disk(fsci->master_table_index[0], (long) 16 , ¤t_table, stack_segment); ! Debug: list int stack_segment = [S+$2030-$2020] (used reg = ) push -$201E[bp] ! Debug: list * struct Directory_Table current_table = S+$2032-$2008 (used reg = ) @@ -2950,61 +2971,10 @@ push $100[bx] call _disk_service_read_data_from_disk add sp,*$C !BCC_EOS -! 56 print("Current table: "); -! Debug: list * char = .62+0 (used reg = ) -mov bx,#.62 -push bx -! Debug: func () void = print+0 (used reg = ) -call _print -inc sp -inc sp -!BCC_EOS -! 57 print_newline(); -! Debug: func () void = print_newline+0 (used reg = ) -call _print_newline -!BCC_EOS -! 58 print_stack(current_table.entries[0].filename); -! Debug: list * char current_table = S+$2030-$2008 (used reg = ) -lea bx,-$2006[bp] -push bx -! Debug: func () void = print_stack+0 (used reg = ) -call _print_stack -inc sp -inc sp -!BCC_EOS -! 59 print_newline(); -! Debug: func () void = print_newline+0 (used reg = ) -call _print_newline -!BCC_EOS -! 60 print_stack(current_table.entries[1].filename); -! Debug: list * char current_table = S+$2030-$1E08 (used reg = ) -lea bx,-$1E06[bp] -push bx -! Debug: func () void = print_stack+0 (used reg = ) -call _print_stack -inc sp -inc sp -!BCC_EOS -! 61 print_newline(); -! Debug: func () void = print_newline+0 (used reg = ) -call _print_newline -!BCC_EOS -! 62 print_stack(current_table.entries[2].filename); -! Debug: list * char current_table = S+$2030-$1C08 (used reg = ) -lea bx,-$1C06[bp] -push bx -! Debug: func () void = print_stack+0 (used reg = ) -call _print_stack -inc sp -inc sp -!BCC_EOS -! 63 print_newline(); -! Debug: func () void = print_newline+0 (used reg = ) -call _print_newline -!BCC_EOS -! 64 -! 65 -! 66 memcpy(¶meter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct)); +! 50 # 59 +! 59 +! 60 +! 61 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 @@ -3021,7 +2991,7 @@ push bx call _memcpy add sp,*$A !BCC_EOS -! 67 path_length = strlen(parameter_struct.path, pointer_parameter_segment); +! 62 path_length = strlen(parameter_struct.path, pointer_parameter_segment); ! Debug: list * void pointer_parameter_segment = [S+$2030+4] (used reg = ) push 6[bp] ! Debug: list * char parameter_struct = [S+$2032-$2018] (used reg = ) @@ -3032,15 +3002,7 @@ add sp,*4 ! Debug: eq int = ax+0 to int path_length = [S+$2030-$2022] (used reg = ) mov -$2020[bp],ax !BCC_EOS -! 68 dump_ax(path_length); -! Debug: list int path_length = [S+$2030-$2022] (used reg = ) -push -$2020[bp] -! Debug: func () void = dump_ax+0 (used reg = ) -call _dump_ax -inc sp -inc sp -!BCC_EOS -! 69 local_path = malloc(256); +! 63 local_path = malloc(256); ! Debug: list int = const $100 (used reg = ) mov ax,#$100 push ax @@ -3051,7 +3013,7 @@ inc sp ! Debug: eq * void = ax+0 to * char local_path = [S+$2030-$2028] (used reg = ) mov -$2026[bp],ax !BCC_EOS -! 70 memcpy(local_path, local_segment, parameter_struct.path, pointer_parameter_segment, path_length); +! 64 memcpy(local_path, local_segment, parameter_struct.path, pointer_parameter_segment, path_length); ! Debug: list int path_length = [S+$2030-$2022] (used reg = ) push -$2020[bp] ! Debug: list * void pointer_parameter_segment = [S+$2032+4] (used reg = ) @@ -3066,7 +3028,7 @@ push -$2026[bp] call _memcpy add sp,*$A !BCC_EOS -! 71 local_path[path_length] = 0; +! 65 local_path[path_length] = 0; ! Debug: ptradd int path_length = [S+$2030-$2022] to * char local_path = [S+$2030-$2028] (used reg = ) mov ax,-$2020[bp] add ax,-$2026[bp] @@ -3075,7 +3037,7 @@ mov bx,ax xor al,al mov [bx],al !BCC_EOS -! 72 print(local_path); +! 66 print(local_path); ! Debug: list * char local_path = [S+$2030-$2028] (used reg = ) push -$2026[bp] ! Debug: func () void = print+0 (used reg = ) @@ -3083,8 +3045,8 @@ call _print inc sp inc sp !BCC_EOS -! 73 -! 74 path_array = string_split_c(local_path, '/', 0); +! 67 +! 68 path_array = string_split_c(local_path, '/', 0); ! Debug: list int = const 0 (used reg = ) xor ax,ax push ax @@ -3099,25 +3061,25 @@ add sp,*6 ! Debug: eq * struct String_Array = ax+0 to * struct String_Array path_array = [S+$2030-$202C] (used reg = ) mov -$202A[bp],ax !BCC_EOS -! 75 -! 76 print_newline(); +! 69 +! 70 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 77 print_newline(); +! 71 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 78 for (i = 0; i < path_array->length; ++i) +! 72 for (i = 0; i < path_array->length; ++i) ! Debug: eq int = const 0 to int i = [S+$2030-$2030] (used reg = ) xor ax,ax mov -$202E[bp],ax !BCC_EOS !BCC_EOS -! 79 { -jmp .65 -.66: -! 80 print(path_array->strings[i]->chars); +! 73 { +jmp .64 +.65: +! 74 print(path_array->strings[i]->chars); mov bx,-$202A[bp] ! Debug: ptradd int i = [S+$2030-$2030] to * * struct Length_String = [bx+2] (used reg = ) mov ax,-$202E[bp] @@ -3132,34 +3094,34 @@ call _print inc sp inc sp !BCC_EOS -! 81 print_newline(); +! 75 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 82 } -! 83 print_newline(); -.64: +! 76 } +! 77 print_newline(); +.63: ! Debug: preinc int i = [S+$2030-$2030] (used reg = ) mov ax,-$202E[bp] inc ax mov -$202E[bp],ax -.65: +.64: mov bx,-$202A[bp] ! Debug: lt unsigned int = [bx+0] to int i = [S+$2030-$2030] (used reg = ) mov ax,-$202E[bp] cmp ax,[bx] -jb .66 -.67: -.63: +jb .65 +.66: +.62: ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 84 print_newline(); +! 78 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 85 -! 86 find_file = calloc(sizeof(lsfs_file), 1); +! 79 +! 80 find_file = calloc(sizeof(lsfs_file), 1); ! Debug: list int = const 1 (used reg = ) mov ax,*1 push ax @@ -3172,8 +3134,7 @@ add sp,*4 ! Debug: eq * void = ax+0 to * struct lsfs_file find_file = [S+$2030-$202E] (used reg = ) mov -$202C[bp],ax !BCC_EOS -! 87 lsf -! 87 s_disk_getattr(find_file, local_path, fsci); +! 81 lsfs_disk_getattr(find_file, local_path, fsci); ! Debug: list * struct File_System_Control_Information fsci = [S+$2030-$202A] (used reg = ) push -$2028[bp] ! Debug: list * char local_path = [S+$2032-$2028] (used reg = ) @@ -3184,20 +3145,20 @@ push -$202C[bp] call _lsfs_disk_getattr add sp,*6 !BCC_EOS -! 88 print_newline(); +! 82 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 89 print("Loding SingOS kernel: "); -! Debug: list * char = .68+0 (used reg = ) -mov bx,#.68 +! 83 print("Loding SingOS kernel: "); +! Debug: list * char = .67+0 (used reg = ) +mov bx,#.67 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 90 print(find_file->filename); +! 84 print(find_file->filename); mov bx,-$202C[bp] ! Debug: list * char = [bx+$12] (used reg = ) push $12[bx] @@ -3206,77 +3167,48 @@ call _print inc sp inc sp !BCC_EOS -! 91 print_newline(); +! 85 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 92 print("Kernel file id: "); -! Debug: list * char = .69+0 (used reg = ) -mov bx,#.69 +! 86 print("Kernel file id: "); +! Debug: list * char = .68+0 (used reg = ) +mov bx,#.68 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 93 dump_ax(find_file->file_id[0]); -! Debug: ptradd int = const 0 to [2] unsigned long find_file = [S+$2030-$202E] (used reg = ) -mov bx,-$202C[bp] -! Debug: list unsigned long = [bx+0] (used reg = ) -push 2[bx] -push [bx] -! Debug: func () void = dump_ax+0 (used reg = ) -call _dump_ax -add sp,*4 -!BCC_EOS -! 94 print_newline(); +! 87 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 95 print("Kernel file size: "); -! Debug: list * char = .6A+0 (used reg = ) -mov bx,#.6A +! 88 print("Kernel file size: "); +! Debug: list * char = .69+0 (used reg = ) +mov bx,#.69 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 96 dump_ax(find_file->size[0]); -mov bx,-$202C[bp] -! Debug: ptradd int = const 0 to [2] unsigned long = bx+$18 (used reg = ) -! Debug: list unsigned long = [bx+$18] (used reg = ) -push $1A[bx] -push $18[bx] -! Debug: func () void = dump_ax+0 (used reg = ) -call _dump_ax -add sp,*4 -!BCC_EOS -! 97 print_newline(); +! 89 print_newline(); ! Debug: func () void = print_newline+0 (used reg = ) call _print_newline !BCC_EOS -! 98 print("Kernel first data pointer: "); -! Debug: list * char = .6B+0 (used reg = ) -mov bx,#.6B +! 90 print("Kernel first data pointer: "); +! Debug: list * char = .6A+0 (used reg = ) +mov bx,#.6A push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 99 dump_ax(find_file->data_pointer[0]); -mov bx,-$202C[bp] -! Debug: ptradd int = const 0 to [$36] long = bx+$44 (used reg = ) -! Debug: list long = [bx+$44] (used reg = ) -push $46[bx] -push $44[bx] -! Debug: func () void = dump_ax+0 (used reg = ) -call _dump_ax -add sp,*4 -!BCC_EOS -! 100 -! 101 lsfs_disk_read_data_from_file(find_file, 0xffff, 0x00, (long) 0x0, 0x50); +! 91 +! 92 lsfs_disk_read_data_from_file(find_file, 0xffff, 0x +! 92 00, (long) 0x0, 0x50); ! Debug: list int = const $50 (used reg = ) mov ax,*$50 push ax @@ -3297,59 +3229,59 @@ push -$202C[bp] call _lsfs_disk_read_data_from_file add sp,*$C !BCC_EOS -! 102 -! 103 -! 104 } break; +! 93 +! 94 +! 95 } break; jmp .5C !BCC_EOS -! 105 case SERIVCE_READ_DATA: -! 106 { -.6C: -! 107 # 115 -! 115 -! 116 print("Hit READ case"); -! Debug: list * char = .6D+0 (used reg = ) -mov bx,#.6D +! 96 case SERIVCE_READ_DATA: +! 97 { +.6B: +! 98 # 106 +! 106 +! 107 print("Hit READ case"); +! Debug: list * char = .6C+0 (used reg = ) +mov bx,#.6C push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 117 } break; +! 108 } break; jmp .5C !BCC_EOS -! 118 case SERIVCE_WRITE_DATA: -! 119 { -.6E: -! 120 print("Hit WRITE case"); -! Debug: list * char = .6F+0 (used reg = ) -mov bx,#.6F +! 109 case SERIVCE_WRITE_DATA: +! 110 { +.6D: +! 111 print("Hit WRITE case"); +! Debug: list * char = .6E+0 (used reg = ) +mov bx,#.6E push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 121 } break; +! 112 } break; jmp .5C !BCC_EOS -! 122 default: -! 123 { -.70: -! 124 print("Default case"); -! Debug: list * char = .71+0 (used reg = ) -mov bx,#.71 +! 113 default: +! 114 { +.6F: +! 115 print("Default case"); +! Debug: list * char = .70+0 (used reg = ) +mov bx,#.70 push bx ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS -! 125 } -! 126 } -! 127 -! 128 return 0; +! 116 } +! 117 } +! 118 +! 119 return 0; jmp .5C .5E: add sp,*-6 @@ -3358,10 +3290,10 @@ beq .5F sub ax,*1 beq .61 sub ax,*1 -je .6C +je .6B sub ax,*1 -je .6E -jmp .70 +je .6D +jmp .6F .5C: ..FFFF = -$2030 add sp,*6 @@ -3372,56 +3304,52 @@ pop di pop bp ret !BCC_EOS -! 129 -! 130 } -! 131 +! 120 +! 121 } +! 122 ! Register BX used in function main +.70: .71: -.72: .ascii "Default case" .byte 0 -.6F: -.73: +.6E: +.72: .ascii "Hit WRITE case" .byte 0 -.6D: -.74: +.6C: +.73: .ascii "Hit READ case" .byte 0 -.6B: -.75: +.6A: +.74: .ascii "Kernel first data pointer: " .byte 0 -.6A: -.76: +.69: +.75: .ascii "Kernel file size: " .byte 0 -.69: -.77: +.68: +.76: .ascii "Kernel file id: " .byte 0 -.68: -.78: +.67: +.77: .ascii "Loding SingOS kernel: " .byte 0 -.62: -.79: -.ascii "Current table: " -.byte 0 .60: -.7A: +.78: .ascii "File System has been loaded: " .byte 0 .43: -.7B: +.79: .ascii "vs " .byte 0 .42: -.7C: +.7A: .ascii "New: " .byte 0 .2E: -.7D: +.7B: .ascii "Size of table_entry: " .byte 0 .bss diff --git a/std_singos/stdio.h b/std_singos/stdio.h index d27fb20..62cb7f6 100644 --- a/std_singos/stdio.h +++ b/std_singos/stdio.h @@ -8,11 +8,27 @@ char* string; push bp mov bp,sp mov si,4[bp] - call 0x0000:0x7C47 + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + new_print_print: + ; Prints string in si + ; IN si: zero terminated string to print + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov ah, #0xE ; Specify 'int 0x10' 'teletype output' function + ; [AL = Character, BH = Page Number, BL = Colour (in graphics mode)] + .new_print_printchar: + lodsb ; Load byte at address SI into AL, and increment SI + test al, al + jz .new_print_done ; If the character is zero (NUL), stop writing the string + int #0x10 ; Otherwise, print the character via 'int 0x10' + jmp .new_print_printchar ; Repeat for the next character + .new_print_done: + pop bp #endasm } + void print_stack(argument) { #asm @@ -24,7 +40,20 @@ void print_stack(argument) mov ax, ss mov ds, ax mov si,4[bp] - call 0x0000:0x7C47 + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + print_stack_print: + ; Prints string in si + ; IN si: zero terminated string to print + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov ah, #0xE ; Specify 'int 0x10' 'teletype output' function + ; [AL = Character, BH = Page Number, BL = Colour (in graphics mode)] + .print_stack_printchar: + lodsb ; Load byte at address SI into AL, and increment SI + test al, al + jz .print_stack_done ; If the character is zero (NUL), stop writing the string + int #0x10 ; Otherwise, print the character via 'int 0x10' + jmp .print_stack_printchar ; Repeat for the next character + .print_stack_done: pop ax pop ds @@ -45,7 +74,26 @@ void* input; #asm push bp mov bp,sp - call 0x000:0x7C2A + + pusha ; save registers + mov bx, ax + mov ah, #0xE ; Teletype output + + mov cx, #4 ; 4 nipples in a 16 bit word + .dump_ax_loop: + rol bx, #4 ; rotate to next nipple + mov al, bl ; we copy to al because we need to mask only the low 4 bits + and al, #%1111 ; Do the masking + add al, #48 ; convert to ASCII + cmp al, #57 ; If we are greater than 9 ascii, we add 7 to make digit 10 be represented as 'A' + jbe .dump_ax_skip ; -|- + add al, #7 ; -|- + .dump_ax_skip: ; -|- + int #0x10 ; BIOS call 'output' + loop .dump_ax_loop + + popa ; restore registers + pop bp #endasm }