push bp mov bp,sp push 12[bp] push 10[bp] push 8[bp] push 6[bp] call _main add sp, #0x8 pop bp retf ! 1 ! 1 # 1 "main.c" ! 1 # 1 "std_singos/string.h" ! 1 void strcpy (destination, destination_segment, source, source_segment ); !BCC_EOS ! 2 ! 3 void strcpy (destination, destination_segment, source, source_segment ) ! 4 char *destination; export _strcpy _strcpy: !BCC_EOS ! 5 int destination_segment; !BCC_EOS ! 6 char *source; !BCC_EOS ! 7 int source_segment; !BCC_EOS ! 8 { ! 9 #asm !BCC_ASM _strcpy.source set 6 _strcpy.destination set 2 _strcpy.source_segment set 8 _strcpy.destination_segment set 4 ; copy two strings ; IN si: the first (zero terminated) string ; IN di: the second (zero terminated) string ; OUT SF and ZF (same semantics as cmp) ! 15 19 push bp mov bp,sp stringcompare: push ax push bx push di push es push si push ds mov ax, 4[bp]; ; mov di, ax mov ax, 6[bp]; ; mov es, ax mov ax, 8[bp]; ; mov si, ax mov ax, 10[bp]; ; mov ds, ax mov cx, 0x050 .loop: movsb cmp cx, 0x0 je .end dec cx jmp .loop .end: pop ds pop si pop es pop di pop bx pop ax pop bp ! 53 endasm !BCC_ENDASM ! 54 } ret ! 55 # 1 "driver/disk.h" ! 1 int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment); !BCC_EOS ! 2 int sec_stub(); !BCC_EOS ! 3 int stub(index, number_sectors, data_buffer, data_buffer_segment); !BCC_EOS ! 4 ! 5 int stub(index, number_sectors, data_buffer, data_buffer_segment) ! 6 long* index; export _stub _stub: !BCC_EOS ! 7 long number_sectors; !BCC_EOS ! 8 void* data_buffer; !BCC_EOS ! 9 int data_buffer_segment; !BCC_EOS ! 10 { ! 11 ! 12 #asm !BCC_ASM _stub.data_buffer set 8 _stub.number_sectors set 4 _stub.data_buffer_segment set $A _stub.index set 2 ! 13 17 push bp mov bp,sp pusha mov ax, #DAPACK call 0x0000:0x7C2A lsfs_load_data: mov ax, 4[bp]; mov WORD [DAPACK.lba_addr_dw_low], ax mov bx, 6[bp]; mov WORD [DAPACK.blkcnt], bx mov cx, 10[bp]; mov WORD [DAPACK.db_addr_segment], cx mov dx, 8[bp]; ; mov WORD [DAPACK.db_addr_offset], dx mov si, #DAPACK ; address of mov ah, #0x42 ; READ mov dl, [global_disk_identifier] int #0x13 call 0x0000:0x7C2A popa pop bp ret DAPACK: DAPACK.dap_Size: db 0x10 DAPACK.rev_byte: db 0x0 DAPACK.blkcnt: dw 0x0 DAPACK.db_addr_offset: dw 0x0 DAPACK.db_addr_segment: dw 0x0 DAPACK.lba_addr_dw_low: dd 0x0 DAPACK.lba_addr_dw_high: dd 0x0 global_disk_identifier: db 0x80 ! 58 endasm !BCC_ENDASM ! 59 } ret ! 60 ! 61 int sec_stub() ! 62 { export _sec_stub _sec_stub: ! 63 return 42; push bp mov bp,sp push di push si mov ax,*$2A pop si pop di pop bp ret !BCC_EOS ! 64 # 7 "main.c" ! 7 } ! 8 ! 9 ! 10 #define SPACE_VBR_RECORD 2048 ! 11 ! 12 #define DEFAULT_ENTRY_SIZE 1 ! 13 ! 14 #define NUMBER_OF_MBR_PARTITIONS 4 ! 15 ! 16 #define DEFAULT_DATA_POINTER_SIZE 4 ! 17 ! 18 ! 19 ! 20 void dump_ax(input); !BCC_EOS ! 21 void print_stack(argument); !BCC_EOS ! 22 ! 23 typedef struct Directory_Table Directory_Table; !BCC_EOS ! 24 typedef struct struct_table_entry struct_table_entry; !BCC_EOS ! 25 typedef struct struct_partition_control partition_control; !BCC_EOS ! 26 typedef struct File_System_Control_Information FSCI; !BCC_EOS ! 27 typedef struct meta_information_format mif; !BCC_EOS ! 28 typedef struct tag_record tag_record; !BCC_EOS ! 29 typedef struct lsfs_file lsfs_file; !BCC_EOS ! 30 ! 31 typedef enum Table_Entry_Kind ! 32 { ! 33 ! 34 ENTRY_EMPTY = 0, ! 35 ENTRY_FILE = 1, ! 36 ENTRY_DIRECTORY = 2, ! 37 } Table_Entry_Kind; !BCC_EOS ! 38 ! 39 int number_low; !BCC_EOS ! 40 int selector; !BCC_EOS ! 41 ! 42 struct File_System_Control_Information ! 43 { ! 44 char filesystem_information[256]; !BCC_EOS ! 45 long master_table_index[2]; !BCC_EOS ! 46 long this_partition_offset_on_disk[2]; !BCC_EOS ! 47 long next_free_sector[2]; !BCC_EOS ! 48 long next_uniqe_id[2]; !BCC_EOS ! 49 long next_sector_reuse_pointer[2]; !BCC_EOS ! 50 long last_sector_index_on_partition[2]; !BCC_EOS ! 51 long maximum_sectors_on_disk[2]; !BCC_EOS ! 52 long sector_size_on_disk[2]; !BCC_EOS ! 53 long not_used[48]; !BCC_EOS ! 54 ! 55 }; !BCC_EOS ! 56 ! 57 struct test ! 58 { ! 59 char* first; !BCC_EOS ! 60 char* second; !BCC_EOS ! 61 }; !BCC_EOS ! 62 ! 63 int argument; !BCC_EOS ! 64 void print(argument); !BCC_EOS ! 65 ! 66 int main(selector, path, path_segment, fsci_lba_index) ! 67 int path_segment; export _main _main: !BCC_EOS ! 68 int fsci_lba_index; !BCC_EOS ! 69 char path[256]; !BCC_EOS ! 70 { ! 71 ! 72 ! 73 ! 74 ! 75 int local_segment = 0x7e0; push bp mov bp,sp push di push si dec sp dec sp ! Debug: eq int = const $7E0 to int local_segment = [S+8-8] (used reg = ) mov ax,#$7E0 mov -6[bp],ax !BCC_EOS ! 76 char* local_path = "Hello world"; dec sp dec sp ! Debug: eq [$40] char = .1+0 to * char local_path = [S+$A-$A] (used reg = ) mov bx,#.1 mov -8[bp],bx !BCC_EOS ! 77 struct test my_struct; !BCC_EOS ! 78 char *fs_info; !BCC_EOS ! 79 char *hello = "LessSimpleFileSystem_Hello"; add sp,*-8 ! Debug: eq [$1B] char = .2+0 to * char hello = [S+$12-$12] (used reg = ) mov bx,#.2 mov -$10[bp],bx !BCC_EOS ! 80 char *yes = "Read file: "; dec sp dec sp ! Debug: eq [$C] char = .3+0 to * char yes = [S+$14-$14] (used reg = ) mov bx,#.3 mov -$12[bp],bx !BCC_EOS ! 81 int nubmer; !BCC_EOS ! 82 ! 83 ! 84 my_struct.first = hello; dec sp dec sp ! Debug: eq * char hello = [S+$16-$12] to * char my_struct = [S+$16-$E] (used reg = ) mov bx,-$10[bp] mov -$C[bp],bx !BCC_EOS ! 85 my_struct.second = yes; ! Debug: eq * char yes = [S+$16-$14] to * char my_struct = [S+$16-$C] (used reg = ) mov bx,-$12[bp] mov -$A[bp],bx !BCC_EOS ! 86 ! 87 if (selector == 1) ! Debug: logeq int = const 1 to int selector = [S+$16+2] (used reg = ) mov ax,4[bp] cmp ax,*1 jne .4 .5: ! 88 { ! 89 ! 90 FSCI fsci; !BCC_EOS ! 91 print(my_struct.first); add sp,#-$200 ! Debug: list * char my_struct = [S+$216-$E] (used reg = ) push -$C[bp] ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS ! 92 print(my_struct.second); ! Debug: list * char my_struct = [S+$216-$C] (used reg = ) push -$A[bp] ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS ! 93 ! 94 print(local_path); ! Debug: list * char local_path = [S+$216-$A] (used reg = ) push -8[bp] ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS ! 95 fsci.master_table_index[0] = 42; ! Debug: eq int = const $2A to long fsci = [S+$216-$116] (used reg = ) mov ax,*$2A xor bx,bx mov -$114[bp],ax mov -$112[bp],bx !BCC_EOS ! 96 nubmer = 0x55; ! Debug: eq int = const $55 to int nubmer = [S+$216-$16] (used reg = ) mov ax,*$55 mov -$14[bp],ax !BCC_EOS ! 97 ! 98 ! 99 ! 100 fsci.filesy ! 100 stem_information[0] = 'i'; ! Debug: eq int = const $69 to char fsci = [S+$216-$216] (used reg = ) mov al,*$69 mov -$214[bp],al !BCC_EOS ! 101 fsci.filesystem_information[1] = ''; ! Debug: eq int = const 0 to char fsci = [S+$216-$215] (used reg = ) xor al,al mov -$213[bp],al !BCC_EOS ! 102 dump_ax(fsci_lba_index); ! Debug: list int fsci_lba_index = [S+$216+8] (used reg = ) push $A[bp] ! Debug: func () void = dump_ax+0 (used reg = ) call _dump_ax inc sp inc sp !BCC_EOS ! 103 stub(fsci_lba_index, 1, &fsci, 0x8fc0); ! Debug: list unsigned int = const $8FC0 (used reg = ) mov ax,#$8FC0 push ax ! Debug: list * struct File_System_Control_Information fsci = S+$218-$216 (used reg = ) lea bx,-$214[bp] push bx ! Debug: list int = const 1 (used reg = ) mov ax,*1 push ax ! Debug: list int fsci_lba_index = [S+$21C+8] (used reg = ) push $A[bp] ! Debug: func () int = stub+0 (used reg = ) call _stub add sp,*8 !BCC_EOS ! 104 ! 105 ! 106 print_stack(fsci.filesystem_information); ! Debug: list * char fsci = S+$216-$216 (used reg = ) lea bx,-$214[bp] push bx ! Debug: func () void = print_stack+0 (used reg = ) call _print_stack inc sp inc sp !BCC_EOS ! 107 dump_ax(fsci.master_table_index[0]); ! Debug: list long fsci = [S+$216-$116] (used reg = ) push -$112[bp] push -$114[bp] ! Debug: func () void = dump_ax+0 (used reg = ) call _dump_ax add sp,*4 !BCC_EOS ! 108 } add sp,#$200 ! 109 else ! 110 { jmp .6 .4: ! 111 print(my_struct.first); ! Debug: list * char my_struct = [S+$16-$E] (used reg = ) push -$C[bp] ! Debug: func () void = print+0 (used reg = ) call _print inc sp inc sp !BCC_EOS ! 112 return 0; xor ax,ax add sp,*$10 pop si pop di pop bp ret !BCC_EOS ! 113 } ! 114 ! 115 return 0; .6: xor ax,ax add sp,*$10 pop si pop di pop bp ret !BCC_EOS ! 116 ! 117 } ! 118 ! 119 void print(argument) ! Register BX used in function main ! 120 { export _print _print: ! 121 #asm !BCC_ASM _print.argument set 2 push bp mov bp,sp mov si,4[bp] call 0x0000:0x7C47 pop bp ! 127 endasm !BCC_ENDASM ! 128 } ret ! 129 ! 130 void print_stack(argument) ! 131 { export _print_stack _print_stack: ! 132 #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 ! 146 endasm !BCC_ENDASM ! 147 } ret ! 148 ! 149 dump_ax_return(input) ! 150 void* input; export _dump_ax_return _dump_ax_return: !BCC_EOS ! 151 { ! 152 return input; push bp mov bp,sp push di push si mov ax,4[bp] pop si pop di pop bp ret !BCC_EOS ! 153 } ! 154 ! 155 void dump_ax(input) ! 156 void* input; export _dump_ax _dump_ax: !BCC_EOS ! 157 { ! 158 ! 159 dump_ax_return(input) push bp mov bp,sp push di push si ! 160 #asm ! Debug: list * void input = [S+6+2] (used reg = ) push 4[bp] ! Debug: func () int = dump_ax_return+0 (used reg = ) call _dump_ax_return inc sp inc sp !BCC_EOS !BCC_ASM _dump_ax.input set 8 .dump_ax.input set 4 push bp mov bp,sp call 0x000:0x7C2A pop bp ! 165 endasm !BCC_ENDASM !BCC_EOS ! 166 } pop si pop di pop bp ret ! 167 .3: .7: .ascii "Read file: " .byte 0 .2: .8: .ascii "LessSimpleFileSystem_Hello" .byte 0 .1: .9: .ascii "Hello world" .byte 0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0 .byte 0,0 .byte 0 .bss .comm _argument,2 .comm _selector,2 .comm _number_low,2 ! 0 errors detected