Save stage

This commit is contained in:
Jørn Guldberg committed 2019-06-27 22:27:47 +00:00
1 parent f113cf57c9
commit c7ad92b3b2
6 files changed
+614 -421

No files matched your search

+2 -1
View File
@@ -1,10 +1,11 @@
bcc -S main.c bcc -S main.c
echo -e "push bp echo -e "push bp
mov bp,sp mov bp,sp
push 10[bp]
push 8[bp] push 8[bp]
push 6[bp] push 6[bp]
call _main call _main
add sp, #0x4 add sp, #0x6
pop bp pop bp
retf\n $(cat main.s)" > main.s retf\n $(cat main.s)" > main.s
sed -i '/.globl ___mkargv/d' ./main.s sed -i '/.globl ___mkargv/d' ./main.s
BIN
View File
Binary file not shown.
+23 -72
View File
@@ -4,6 +4,7 @@
// //
#include "std_singos/string.h" #include "std_singos/string.h"
#include "std_singos/stdio.h"
#include "driver/disk.h" #include "driver/disk.h"
#define SPACE_MBR_RECORD 2048 // Sectors #define SPACE_MBR_RECORD 2048 // Sectors
@@ -28,6 +29,7 @@ typedef struct File_System_Control_Information FSCI;
typedef struct meta_information_format mif; typedef struct meta_information_format mif;
typedef struct tag_record tag_record; typedef struct tag_record tag_record;
typedef struct lsfs_file lsfs_file; typedef struct lsfs_file lsfs_file;
typedef struct Parameter_Struct Parameter_Struct;
typedef enum Table_Entry_Kind typedef enum Table_Entry_Kind
{ {
@@ -46,9 +48,6 @@ typedef enum Service_Action
} Service_Action; } Service_Action;
int number_low;
int selector;
struct Struct_Table_Entry struct Struct_Table_Entry
{ {
char filename[256]; char filename[256];
@@ -86,12 +85,22 @@ typedef struct Directory_Table
}; };
struct Parameter_Struct
{
char* path;
char* new_path;
int buffer_segment;
int buffer_address;
int buffer_size;
int data_length;
int byte_offset_into_file;
Table_Entry_Kind entry_kind;
};
void print(string); int main(selector, pointer_parameter_segment, pointer_parameter_struct)
int main(selector, parameter_struct)
int selector; int selector;
void* parameter_struct; void* pointer_parameter_segment;
void* pointer_parameter_struct;
{ {
// selectot should be a "selector" for which disk service // selectot should be a "selector" for which disk service
// one wnats to use. // one wnats to use.
@@ -99,6 +108,7 @@ void* parameter_struct;
FSCI fsci; FSCI fsci;
Service_Action service_action; Service_Action service_action;
Directory_Table current_table; Directory_Table current_table;
Parameter_Struct parameter_struct;
int local_segment = 0x7e0; int local_segment = 0x7e0;
int stack_segment = 0x8fc0; int stack_segment = 0x8fc0;
long index_as_long; long index_as_long;
@@ -114,7 +124,7 @@ void* parameter_struct;
What do we need to know: What do we need to know:
Index of FSCI Index of FSCI
*/ */
index_as_long = parameter_struct; index_as_long = pointer_parameter_struct;
disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment); disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment);
print("File System has been loaded: "); print("File System has been loaded: ");
print_newline(); print_newline();
@@ -123,6 +133,9 @@ void* parameter_struct;
} break; } break;
case SERVICE_FIND_ENTRY: case SERVICE_FIND_ENTRY:
{ {
memcpy(&parameter_struct, stack_segment, pointer_parameter_struct, pointer_parameter_segment, sizeof(Parameter_Struct));
dump_ax(parameter_struct.buffer_size);
print_newline();
disk_service_read_data_from_disk(fsci.master_table_index[0], DEFAULT_TABLE_SIZE, &current_table, stack_segment); disk_service_read_data_from_disk(fsci.master_table_index[0], DEFAULT_TABLE_SIZE, &current_table, stack_segment);
print("Current table: "); print("Current table: ");
print_newline(); print_newline();
@@ -141,6 +154,8 @@ void* parameter_struct;
// Buffer: // Buffer:
destination_segment destination_segment
destination_address destination_address
buffer_size
offset_into_file
*/ */
print("Hit READ case"); print("Hit READ case");
} break; } break;
@@ -159,67 +174,3 @@ void* parameter_struct;
} }
//void load_ //void load_
void print(string)
char* string;
{
#asm
push bp
mov bp,sp
mov si,4[bp]
call 0x0000:0x7C47
pop bp
#endasm
}
void print_stack(argument)
{
#asm
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
#endasm
}
dump_ax_return(input)
void* input;
{
return input;
}
void dump_ax(input)
void* input;
{
// Force the variable in ax
dump_ax_return(input)
#asm
push bp
mov bp,sp
call 0x000:0x7C2A
pop bp
#endasm
}
void print_newline()
{
#asm
printCRLF:
mov ah, #0xE
mov al, #13
int #0x10
mov al, #10
int #0x10
ret
#endasm
}
+469 -348
View File
File diff suppressed because it is too large. Load diff
+64
View File
@@ -0,0 +1,64 @@
void print(string);
void print(string)
char* string;
{
#asm
push bp
mov bp,sp
mov si,4[bp]
call 0x0000:0x7C47
pop bp
#endasm
}
void print_stack(argument)
{
#asm
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
#endasm
}
dump_ax_return(input)
void* input;
{
return input;
}
void dump_ax(input)
void* input;
{
// Force the variable in ax
dump_ax_return(input)
#asm
push bp
mov bp,sp
call 0x000:0x7C2A
pop bp
#endasm
}
void print_newline()
{
#asm
printCRLF:
mov ah, #0xE
mov al, #13
int #0x10
mov al, #10
int #0x10
ret
#endasm
}
+56
View File
@@ -1,4 +1,5 @@
void strcpy (destination, destination_segment, source, source_segment ); void strcpy (destination, destination_segment, source, source_segment );
void memcpy (destination, destination_segment, source, source_segment, num_bytes );
void strcpy (destination, destination_segment, source, source_segment ) void strcpy (destination, destination_segment, source, source_segment )
char *destination; char *destination;
@@ -52,3 +53,58 @@ int source_segment;
#endasm #endasm
} }
void memcpy (destination, destination_segment, source, source_segment, num_bytes)
void *destination;
int destination_segment;
void *source;
int source_segment;
int num_bytes;
{
#asm
; 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)
#define DESTINATION 4[bp];
#define DESTINATION_SEGMENT 6[bp];
#define SOURCE 8[bp];
#define SOURCE_SEGMENT 10[bp];
#define NUM_BYTES 12[bp];
push bp
mov bp,sp
memcpy:
push ax
push bx
push di
push es
push si
push ds
mov ax, DESTINATION;
mov di, ax
mov ax, DESTINATION_SEGMENT;
mov es, ax
mov ax, SOURCE;
mov si, ax
mov ax, SOURCE_SEGMENT;
mov ds, ax
mov cx, NUM_BYTES
.memcpy_loop:
movsb
cmp cx, 0x0
je .end
dec cx
jmp .loop
.memcpy_end:
pop ds
pop si
pop es
pop di
pop bx
pop ax
pop bp
#endasm
}