Big changes, starting to divided up i .c and .h files

This commit is contained in:
Jørn Guldberg committed 2019-06-29 11:00:43 +00:00
1 parent d5bc5e8958
commit ec61cd8b8a
11 files changed
+2669 -1327

No files matched your search

+26
View File
@@ -3,6 +3,7 @@ unsigned int global_heap_end = 0;
unsigned int global_heap_next = 0;
void* malloc(num_bytes);
void* calloc(number_elements, size);
int set_heap_settings(param_start, param_end);
unsigned int get_heap_next();
@@ -19,6 +20,31 @@ int num_bytes;
return allocated_pointer;
}
void* calloc(number_elements, size)
unsigned int number_elements;
unsigned int size;
{
int i;
char* temp_pointer;
unsigned int num_bytes = number_elements * size;
void* 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 */
}
/* Since this is calloc, we set the memory to zero */
temp_pointer = allocated_pointer;
for (i = 0; i < num_bytes; ++i)
{
*temp_pointer = 0;
temp_pointer++;
}
return allocated_pointer;
}
int set_heap_settings(param_start, param_end)
unsigned int param_start;
unsigned int param_end;
+4 -6
View File
@@ -1,5 +1,4 @@
typedef struct Length_String {
short dynamic;
unsigned int length;
@@ -15,7 +14,7 @@ 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.
/* 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);
@@ -92,7 +91,7 @@ int source_segment;
mov si, ax
mov ax, SOURCE_SEGMENT;
mov ds, ax
mov cx, 0x050 // TODO(Jørn) Hardcded number of bytes to copy
mov cx, 0x050 ;TODO(Jørn) Hardcded number of bytes to copy
.label_strcpy_loop:
movsb
cmp cx, 0x0
@@ -186,8 +185,7 @@ char *chars;
{
Length_String *legth_string = malloc(sizeof(Length_String));
char *copy = malloc(length + 1); // Space for null terminator
char *copy = malloc(length + 1); /* Space for null terminator */
memcpy(copy, 0x7e0, chars, 0x7e0, length);
copy[length] = '\0';
@@ -272,7 +270,7 @@ char *chars;
{
Length_String *legth_string = malloc(sizeof(Length_String));
char *copy = malloc(length + 1); // Space for null terminator
char *copy = malloc(length + 1); /* Space for null terminator */
memcpy(copy, 0x7e0, chars, 0x7e0, length);
copy[length] = '\0';