Browse Source

Fixed some hardcoded things

master
Jørn Guldberg 3 years ago
parent
commit
0a6c743d81
2 changed files with 168 additions and 124 deletions
  1. +10
    -5
      main.c
  2. +158
    -119
      main.s

+ 10
- 5
main.c View File

@ -1,6 +1,5 @@
#include "main.h"
int main(selector, pointer_parameter_segment, pointer_parameter_struct)
int selector;
void* pointer_parameter_segment;
@ -13,7 +12,7 @@ void* pointer_parameter_struct;
Service_Action service_action;
Directory_Table current_table;
Parameter_Struct parameter_struct;
int local_segment = 0x7e0;
int* local_segment; /* = 0x7e0; */
unsigned int heap_start = 0x2200;
unsigned int heap_end = 0xffff;
int stack_segment = 0x8fc0;
@ -21,7 +20,7 @@ void* pointer_parameter_struct;
long index_as_long = 0;
char *local_path = 0;
FSCI *fsci = 0x2000;
FSCI *fsci = global_heap_start - 0x200;
service_action = selector;
switch (service_action)
@ -32,13 +31,19 @@ void* pointer_parameter_struct;
What do we need to know:
Index of FSCI
*/
memcpy(&parameter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct));
/*fsci = parameter_struct.buffer_segment; */
local_segment = parameter_struct.buffer_segment;
heap_start = parameter_struct.buffer_address + 0x200;
heap_end = parameter_struct.buffer_size;
index_as_long = parameter_struct.data_length;
set_heap_settings(heap_start, heap_end);
index_as_long = pointer_parameter_struct;
fsci = global_heap_start - 0x200;
disk_service_read_data_from_disk(index_as_long, (long) 1, fsci, local_segment);
print("File System has been loaded: ");
print_newline();
print(fsci->filesystem_information);
print("16-bit implementation ");
print("16-bit implementation v0.2.1");
print_newline();
} break;
case SERVICE_FIND_ENTRY:

+ 158
- 119
main.s View File

@ -2577,62 +2577,57 @@ ret
!BCC_EOS
! 271
! 272 }
! 273 # 4 "main.c"
! 4 int main(selector, pointer_parameter_segment, pointer_parameter_struct)
! 273 # 3 "main.c"
! 3 int main(selector, pointer_parameter_segment, pointer_parameter_struct)
! Register BX used in function lsfs_disk_read_data_from_file
! 5 int selector;
! 4 int selector;
export _main
_main:
!BCC_EOS
! 6 void* pointer_parameter_segment;
! 5 void* pointer_parameter_segment;
!BCC_EOS
! 7 void* pointer_parameter_struct;
! 6 void* pointer_parameter_struct;
!BCC_EOS
! 8 {
! 7 {
! 8
! 9
! 10
! 11
! 12
! 13 Service_Action service_action;
! 12 Service_Action service_action;
!BCC_EOS
! 14 Directory_Table current_table;
! 13 Directory_Table current_table;
!BCC_EOS
! 15 Parameter_Struct parameter_struct;
! 14 Parameter_Struct parameter_struct;
!BCC_EOS
! 16 int local_segment = 0x7e0;
! 15 int* local_segment;
!BCC_EOS
! 16 unsigned int heap_start = 0x2200;
push bp
mov bp,sp
push di
push si
add sp,#-$1014
! Debug: eq int = const $7E0 to int local_segment = [S+$101A-$101A] (used reg = )
mov ax,#$7E0
mov -$1018[bp],ax
!BCC_EOS
! 17 unsigned int heap_start = 0x2200;
dec sp
dec sp
add sp,#-$1016
! Debug: eq int = const $2200 to unsigned int heap_start = [S+$101C-$101C] (used reg = )
mov ax,#$2200
mov -$101A[bp],ax
!BCC_EOS
! 18 unsigned int heap_end = 0xffff;
! 17 unsigned int heap_end = 0xffff;
dec sp
dec sp
! Debug: eq unsigned int = const $FFFF to unsigned int heap_end = [S+$101E-$101E] (used reg = )
mov ax,#$FFFF
mov -$101C[bp],ax
!BCC_EOS
! 19 int stack_segment = 0x8fc0;
! 18 int stack_segment = 0x8fc0;
dec sp
dec sp
! Debug: eq unsigned int = const $8FC0 to int stack_segment = [S+$1020-$1020] (used reg = )
mov ax,#$8FC0
mov -$101E[bp],ax
!BCC_EOS
! 20 int path_length;
! 19 int path_length;
!BCC_EOS
! 21 long index_as_long = 0;
! 20 long index_as_long = 0;
add sp,*-6
! Debug: eq int = const 0 to long index_as_long = [S+$1026-$1026] (used reg = )
xor ax,ax
@ -2640,39 +2635,83 @@ xor bx,bx
mov -$1024[bp],ax
mov -$1022[bp],bx
!BCC_EOS
! 22
! 23 char *local_path = 0;
! 21
! 22 char *local_path = 0;
dec sp
dec sp
! Debug: eq int = const 0 to * char local_path = [S+$1028-$1028] (used reg = )
xor ax,ax
mov -$1026[bp],ax
!BCC_EOS
! 24 FSCI *fsci = 0x2000;
! 23 FSCI *fsci = global_heap_start - 0x200;
dec sp
dec sp
! Debug: eq int = const $2000 to * struct File_System_Control_Information fsci = [S+$102A-$102A] (used reg = )
mov ax,#$2000
! Debug: sub int = const $200 to unsigned int = [global_heap_start+0] (used reg = )
mov ax,[_global_heap_start]
! Debug: eq unsigned int = ax-$200 to * struct File_System_Control_Information fsci = [S+$102A-$102A] (used reg = )
add ax,#-$200
mov -$1028[bp],ax
!BCC_EOS
! 25 service_action = selector;
! 24 service_action = selector;
! Debug: eq int selector = [S+$102A+2] to int service_action = [S+$102A-8] (used reg = )
mov ax,4[bp]
mov -6[bp],ax
!BCC_EOS
! 26
! 27 switch (service_action)
! 25
! 26 switch (service_action)
mov ax,-6[bp]
! 28 {
! 27 {
br .5B
! 29 case SERIVCE_LOAD_DISK:
! 30 {
! 28 case SERIVCE_LOAD_DISK:
! 29 {
.5C:
! 30
! 31
! 32
! 33
! 34
! 35 set_heap_settings(heap_start, heap_end);
! 33
! 34 memcpy(&parameter_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+$102C+4] (used reg = )
push 6[bp]
! Debug: list * void pointer_parameter_struct = [S+$102E+6] (used reg = )
push 8[bp]
! Debug: list int stack_segment = [S+$1030-$1020] (used reg = )
push -$101E[bp]
! Debug: list * struct Parameter_Struct parameter_struct = S+$1032-$1018 (used reg = )
lea bx,-$1016[bp]
push bx
! Debug: func () void = memcpy+0 (used reg = )
call _memcpy
add sp,*$A
!BCC_EOS
! 35
! 36 local_segment = parameter_struct.buffer_segment;
! Debug: eq unsigned int parameter_struct = [S+$102A-$1014] to * int local_segment = [S+$102A-$101A] (used reg = )
mov bx,-$1012[bp]
mov -$1018[bp],bx
!BCC_EOS
! 37 heap_start = parameter_struct.buffer_address + 0x200;
! Debug: add int = const $200 to unsigned int parameter_struct = [S+$102A-$1012] (used reg = )
mov ax,-$1010[bp]
! Debug: eq unsigned int = ax+$200 to unsigned int heap_start = [S+$102A-$101C] (used reg = )
add ax,#$200
mov -$101A[bp],ax
!BCC_EOS
! 38 heap_end = parameter_struct.buffer_size;
! Debug: eq unsigned int parameter_struct = [S+$102A-$1010] to unsigned int heap_end = [S+$102A-$101E] (used reg = )
mov ax,-$100E[bp]
mov -$101C[bp],ax
!BCC_EOS
! 39 index_as_long = parameter_struct.data_length;
! Debug: eq unsigned int parameter_struct = [S+$102A-$100E] to long index_as_long = [S+$102A-$1026] (used reg = )
mov ax,-$100C[bp]
xor bx,bx
mov -$1024[bp],ax
mov -$1022[bp],bx
!BCC_EOS
! 40 set_heap_settings(heap_start, heap_end);
! Debug: list unsigned int heap_end = [S+$102A-$101E] (used reg = )
push -$101C[bp]
! Debug: list unsigned int heap_start = [S+$102C-$101C] (used reg = )
@ -2681,15 +2720,15 @@ push -$101A[bp]
call _set_heap_settings
add sp,*4
!BCC_EOS
! 36 index_as_long = pointer_parameter_struct;
! Debug: eq * void pointer_parameter_struct = [S+$102A+6] to long index_as_long = [S+$102A-$1026] (used reg = )
mov ax,8[bp]
xor bx,bx
mov -$1024[bp],ax
mov -$1022[bp],bx
! 41 fsci = global_heap_start - 0x200;
! Debug: sub int = const $200 to unsigned int = [global_heap_start+0] (used reg = )
mov ax,[_global_heap_start]
! Debug: eq unsigned int = ax-$200 to * struct File_System_Control_Information fsci = [S+$102A-$102A] (used reg = )
add ax,#-$200
mov -$1028[bp],ax
!BCC_EOS
! 37 disk_service_read_data_from_disk(index_as_long, (long) 1, fsci, local_segment);
! Debug: list int local_segment = [S+$102A-$101A] (used reg = )
! 42 disk_service_read_data_from_disk(index_as_long, (long) 1, fsci, local_segment);
! Debug: list * int local_segment = [S+$102A-$101A] (used reg = )
push -$1018[bp]
! Debug: list * struct File_System_Control_Information fsci = [S+$102C-$102A] (used reg = )
push -$1028[bp]
@ -2705,7 +2744,7 @@ push -$1024[bp]
call _disk_service_read_data_from_disk
add sp,*$C
!BCC_EOS
! 38 print("File System has been loaded: ");
! 43 print("File System has been loaded: ");
! Debug: list * char = .5D+0 (used reg = )
mov bx,#.5D
push bx
@ -2714,11 +2753,11 @@ call _print
inc sp
inc sp
!BCC_EOS
! 39 print_newline();
! 44 print_newline();
! Debug: func () void = print_newline+0 (used reg = )
call _print_newline
!BCC_EOS
! 40 print(fsci->filesystem_information);
! 45 print(fsci->filesystem_information);
! Debug: cast * char = const 0 to [$100] char fsci = [S+$102A-$102A] (used reg = )
! Debug: list * char fsci = [S+$102A-$102A] (used reg = )
push -$1028[bp]
@ -2727,7 +2766,8 @@ call _print
inc sp
inc sp
!BCC_EOS
! 41 print("16-bit implementation ");
! 46 p
! 46 rint("16-bit implementation v0.2.1");
! Debug: list * char = .5E+0 (used reg = )
mov bx,#.5E
push bx
@ -2736,23 +2776,23 @@ call _print
inc sp
inc sp
!BCC_EOS
! 42 print_newline();
! 47 print_newline();
! Debug: func () void = print_newline+0 (used reg = )
call _print_newline
!BCC_EOS
! 43 } break;
! 48 } break;
br .59
!BCC_EOS
! 44 case SERVICE_FIND_ENTRY:
! 45 {
! 49 case SERVICE_FIND_ENTRY:
! 50 {
.5F:
! 46 String_Array *path_array;
! 51 String_Array *path_array;
!BCC_EOS
! 47 lsfs_file* find_file;
! 52 lsfs_file* find_file;
!BCC_EOS
! 48 int i;
! 53 int i;
!BCC_EOS
! 49 disk_service_read_data_from_disk(fsci->master_table_index[0], (long) 8 , &current_table, stack_segment);
! 54 disk_service_read_data_from_disk(fsci->master_table_index[0], (long) 8 , &current_table, stack_segment);
! Debug: list int stack_segment = [S+$1030-$1020] (used reg = )
push -$101E[bp]
! Debug: list * struct Directory_Table current_table = S+$1032-$1008 (used reg = )
@ -2772,11 +2812,10 @@ push $100[bx]
call _disk_service_read_data_from_disk
add sp,*$C
!BCC_EOS
! 50 # 59
! 59
! 60
! 61 memcpy(&parameter_struct
! 61 , stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct));
! 55 # 64
! 64
! 65
! 66 memcpy(&parameter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct));
! Debug: list int = const $10 (used reg = )
mov ax,*$10
push ax
@ -2793,7 +2832,7 @@ push bx
call _memcpy
add sp,*$A
!BCC_EOS
! 62 path_length = strlen(parameter_struct.path, pointer_parameter_segment);
! 67 path_length = strlen(parameter_struct.path, pointer_parameter_segment);
! Debug: list * void pointer_parameter_segment = [S+$1030+4] (used reg = )
push 6[bp]
! Debug: list * char parameter_struct = [S+$1032-$1018] (used reg = )
@ -2804,7 +2843,7 @@ add sp,*4
! Debug: eq int = ax+0 to int path_length = [S+$1030-$1022] (used reg = )
mov -$1020[bp],ax
!BCC_EOS
! 63 local_path = malloc(256);
! 68 local_path = malloc(256);
! Debug: list int = const $100 (used reg = )
mov ax,#$100
push ax
@ -2815,14 +2854,14 @@ inc sp
! Debug: eq * void = ax+0 to * char local_path = [S+$1030-$1028] (used reg = )
mov -$1026[bp],ax
!BCC_EOS
! 64 memcpy(local_path, local_segment, parameter_struct.path, pointer_parameter_segment, path_length);
! 69 memcpy(local_path, local_segment, parameter_struct.path, pointer_parameter_segment, path_length);
! Debug: list int path_length = [S+$1030-$1022] (used reg = )
push -$1020[bp]
! Debug: list * void pointer_parameter_segment = [S+$1032+4] (used reg = )
push 6[bp]
! Debug: list * char parameter_struct = [S+$1034-$1018] (used reg = )
push -$1016[bp]
! Debug: list int local_segment = [S+$1036-$101A] (used reg = )
! Debug: list * int local_segment = [S+$1036-$101A] (used reg = )
push -$1018[bp]
! Debug: list * char local_path = [S+$1038-$1028] (used reg = )
push -$1026[bp]
@ -2830,7 +2869,7 @@ push -$1026[bp]
call _memcpy
add sp,*$A
!BCC_EOS
! 65 local_path[path_length] = 0;
! 70 local_path[path_length] = 0;
! Debug: ptradd int path_length = [S+$1030-$1022] to * char local_path = [S+$1030-$1028] (used reg = )
mov ax,-$1020[bp]
add ax,-$1026[bp]
@ -2839,7 +2878,7 @@ mov bx,ax
xor al,al
mov [bx],al
!BCC_EOS
! 66 print("Read file: ");
! 71 print("Read file: ");
! Debug: list * char = .60+0 (used reg = )
mov bx,#.60
push bx
@ -2848,7 +2887,7 @@ call _print
inc sp
inc sp
!BCC_EOS
! 67 print(local_path);
! 72 print(local_path);
! Debug: list * char local_path = [S+$1030-$1028] (used reg = )
push -$1026[bp]
! Debug: func () void = print+0 (used reg = )
@ -2856,12 +2895,12 @@ call _print
inc sp
inc sp
!BCC_EOS
! 68 print_newline();
! 73 print_newline();
! Debug: func () void = print_newline+0 (used reg = )
call _print_newline
!BCC_EOS
! 69
! 70 path_array = string_split_c(local_path, '/', 0);
! 74
! 75 path_array = string_split_c(local_path, '/', 0);
! Debug: list int = const 0 (used reg = )
xor ax,ax
push ax
@ -2876,8 +2915,8 @@ add sp,*6
! Debug: eq * struct String_Array = ax+0 to * struct String_Array path_array = [S+$1030-$102C] (used reg = )
mov -$102A[bp],ax
!BCC_EOS
! 71
! 72 find_file = calloc(sizeof(lsfs_file), 1);
! 76
! 77 find_file = calloc(sizeof(lsfs_file), 1);
! Debug: list int = const 1 (used reg = )
mov ax,*1
push ax
@ -2890,7 +2929,7 @@ add sp,*4
! Debug: eq * void = ax+0 to * struct lsfs_file find_file = [S+$1030-$102E] (used reg = )
mov -$102C[bp],ax
!BCC_EOS
! 73 if ( !lsfs_disk_getattr(find_file, local_path, fsci) )
! 78 if ( !lsfs_disk_getattr(find_file, local_path, fsci) )
! Debug: list * struct File_System_Control_Information fsci = [S+$1030-$102A] (used reg = )
push -$1028[bp]
! Debug: list * char local_path = [S+$1032-$1028] (used reg = )
@ -2903,8 +2942,8 @@ add sp,*6
test ax,ax
jne .61
.62:
! 74 {
! 75 print("File not found");
! 79 {
! 80 print("File not found");
! Debug: list * char = .63+0 (used reg = )
mov bx,#.63
push bx
@ -2913,16 +2952,16 @@ call _print
inc sp
inc sp
!BCC_EOS
! 76 print_newline();
! 81 print_newline();
! Debug: func () void = print_newline+0 (used reg = )
call _print_newline
!BCC_EOS
! 77 }
! 78 else
! 79 {
! 82 }
! 83 else
! 84 {
jmp .64
.61:
! 80 print("File has been read");
! 85 print("File has been read");
! Debug: list * char = .65+0 (used reg = )
mov bx,#.65
push bx
@ -2931,14 +2970,14 @@ call _print
inc sp
inc sp
!BCC_EOS
! 81 print_newline();
! 86 print_newline();
! Debug: func () void = print_newline+0 (used reg = )
call _print_newline
!BCC_EOS
! 82 }
! 83 # 90
! 90
! 91 lsfs_disk_read_data_from_file(find_file, parameter_struct.buffer_size, parameter_struct.buffer_address, (long) 0x0, parameter_struct.buffer_segment);
! 87 }
! 88 # 95
! 95
! 96 lsfs_disk_read_data_from_file(find_file, parameter_struct.buffer_size, parameter_struct.buffer_address, (long) 0x0, parameter_struct.buffer_segment);
.64:
! Debug: list unsigned int parameter_struct = [S+$1030-$1014] (used reg = )
push -$1012[bp]
@ -2957,17 +2996,17 @@ push -$102C[bp]
call _lsfs_disk_read_data_from_file
add sp,*$C
!BCC_EOS
! 92
! 93
! 94 } break;
! 97
! 98
! 99 } break;
jmp .59
!BCC_EOS
! 95 case SERIVCE_READ_DATA:
! 96 {
! 100 case SERIVCE_READ_DATA:
! 101 {
.66:
! 97 # 105
! 105
! 106 print("Hit READ case");
! 102 # 110
! 110
! 111 print("Hit READ case");
! Debug: list * char = .67+0 (used reg = )
mov bx,#.67
push bx
@ -2976,13 +3015,13 @@ call _print
inc sp
inc sp
!BCC_EOS
! 107 } break;
! 112 } break;
jmp .59
!BCC_EOS
! 108 case SERIVCE_WRITE_DATA:
! 109 {
! 113 case SERIVCE_WRITE_DATA:
! 114 {
.68:
! 110 print("Hit WRITE case");
! 115 print("Hit WRITE case");
! Debug: list * char = .69+0 (used reg = )
mov bx,#.69
push bx
@ -2991,14 +3030,14 @@ call _print
inc sp
inc sp
!BCC_EOS
! 111 } break;
! 116 } break;
jmp .59
!BCC_EOS
! 112 case SERIVCE_WRITE_FS_INFO:
! 113 {
! 117 case SERIVCE_WRITE_FS_INFO:
! 118 {
.6A:
! 114
! 115 print(fsci->filesystem_information);
! 119
! 120 print(fsci->filesystem_information);
! Debug: cast * char = const 0 to [$100] char fsci = [S+$102A-$102A] (used reg = )
! Debug: list * char fsci = [S+$102A-$102A] (used reg = )
push -$1028[bp]
@ -3007,15 +3046,15 @@ call _print
inc sp
inc sp
!BCC_EOS
! 116
! 117 } break;
! 121
! 122 } break;
jmp .59
!BCC_EOS
! 118
! 119 default:
! 120 {
! 123
! 124 default:
! 125 {
.6B:
! 121 print("Default case: ");
! 126 print("Default case: ");
! Debug: list * char = .6C+0 (used reg = )
mov bx,#.6C
push bx
@ -3024,7 +3063,7 @@ call _print
inc sp
inc sp
!BCC_EOS
! 122 dump_ax(service_action);
! 127 dump_ax(service_action);
! Debug: list int service_action = [S+$102A-8] (used reg = )
push -6[bp]
! Debug: func () void = dump_ax+0 (used reg = )
@ -3032,10 +3071,10 @@ call _dump_ax
inc sp
inc sp
!BCC_EOS
! 123 }
! 124 }
! 125
! 126 return 0;
! 128 }
! 129 }
! 130
! 131 return 0;
jmp .59
.5B:
add sp,*-6
@ -3060,9 +3099,9 @@ pop di
pop bp
ret
!BCC_EOS
! 127
! 128 }
! 129
! 132
! 133 }
! 134
! Register BX used in function main
.6C:
.6D:
@ -3090,7 +3129,7 @@ ret
.byte 0
.5E:
.73:
.ascii "16-bit implementation "
.ascii "16-bit implementation v0.2.1"
.byte 0
.5D:
.74:

Loading…
Cancel
Save