You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3429 lines
79 KiB
3429 lines
79 KiB
push bp
|
|
mov bp,sp
|
|
push 10[bp]
|
|
push 8[bp]
|
|
push 6[bp]
|
|
call _main
|
|
add sp, #0x6
|
|
pop bp
|
|
retf
|
|
! 1
|
|
! 1 # 1 "main.c"
|
|
! 1 # 1 "std_singos/stdio.h"
|
|
! 1 void print(string);
|
|
!BCC_EOS
|
|
! 2 void* dump_ax_return(input);
|
|
!BCC_EOS
|
|
! 3
|
|
! 4 void print(string)
|
|
! 5 char* string;
|
|
export _print
|
|
_print:
|
|
!BCC_EOS
|
|
! 6 {
|
|
! 7 #asm
|
|
!BCC_ASM
|
|
_print.string set 2
|
|
|
|
push bp
|
|
mov bp,sp
|
|
mov si,4[bp]
|
|
call 0x0000:0x7C47
|
|
pop bp
|
|
! 13 endasm
|
|
!BCC_ENDASM
|
|
! 14 }
|
|
ret
|
|
! 15
|
|
! 16 void print_stack(argument)
|
|
! 17 {
|
|
export _print_stack
|
|
_print_stack:
|
|
! 18 #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
|
|
! 32 endasm
|
|
!BCC_ENDASM
|
|
! 33 }
|
|
ret
|
|
! 34
|
|
! 35 void* dump_ax_return(input)
|
|
! 36 void* input;
|
|
export _dump_ax_return
|
|
_dump_ax_return:
|
|
!BCC_EOS
|
|
! 37 {
|
|
! 38 return input;
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
mov ax,4[bp]
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 39 }
|
|
! 40
|
|
! 41 void dump_ax(input)
|
|
! 42 void* input;
|
|
export _dump_ax
|
|
_dump_ax:
|
|
!BCC_EOS
|
|
! 43 {
|
|
! 44 dump_ax_return(input)
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
! 45 #asm
|
|
! Debug: list * void input = [S+6+2] (used reg = )
|
|
push 4[bp]
|
|
! Debug: func () * void = 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
|
|
! 50 endasm
|
|
!BCC_ENDASM
|
|
!BCC_EOS
|
|
! 51 }
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
! 52
|
|
! 53 void print_newline()
|
|
! 54 {
|
|
export _print_newline
|
|
_print_newline:
|
|
! 55 #asm
|
|
!BCC_ASM
|
|
|
|
printCRLF:
|
|
mov ah, #0xE
|
|
mov al, #13
|
|
int #0x10
|
|
mov al, #10
|
|
int #0x10
|
|
ret
|
|
! 63 endasm
|
|
!BCC_ENDASM
|
|
! 64 }
|
|
ret
|
|
! 65 # 1 "std_singos/stdlib.h"
|
|
! 1 unsigned int global_heap_start = 0;
|
|
export _global_heap_start
|
|
_global_heap_start:
|
|
.word 0
|
|
!BCC_EOS
|
|
! 2 unsigned int global_heap_end = 0;
|
|
export _global_heap_end
|
|
_global_heap_end:
|
|
.word 0
|
|
!BCC_EOS
|
|
! 3 unsigned int global_heap_next = 0;
|
|
export _global_heap_next
|
|
_global_heap_next:
|
|
.word 0
|
|
!BCC_EOS
|
|
! 4
|
|
! 5 void* malloc(num_bytes);
|
|
!BCC_EOS
|
|
! 6 void* calloc(number_elements, size);
|
|
!BCC_EOS
|
|
! 7 int set_heap_settings(param_start, param_end);
|
|
!BCC_EOS
|
|
! 8 unsigned int get_heap_next();
|
|
!BCC_EOS
|
|
! 9
|
|
! 10 void* malloc(num_bytes)
|
|
! 11 int num_bytes;
|
|
.text
|
|
export _malloc
|
|
_malloc:
|
|
!BCC_EOS
|
|
! 12 {
|
|
! 13 unsigned int allocated_pointer = global_heap_next;
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
dec sp
|
|
dec sp
|
|
! Debug: eq unsigned int = [global_heap_next+0] to unsigned int allocated_pointer = [S+8-8] (used reg = )
|
|
mov ax,[_global_heap_next]
|
|
mov -6[bp],ax
|
|
!BCC_EOS
|
|
! 14 global_heap_next = global_heap_next + num_bytes;
|
|
! Debug: add int num_bytes = [S+8+2] to unsigned int = [global_heap_next+0] (used reg = )
|
|
mov ax,[_global_heap_next]
|
|
add ax,4[bp]
|
|
! Debug: eq unsigned int = ax+0 to unsigned int = [global_heap_next+0] (used reg = )
|
|
mov [_global_heap_next],ax
|
|
!BCC_EOS
|
|
! 15 if (global_heap_next > global_heap_end)
|
|
! Debug: gt unsigned int = [global_heap_end+0] to unsigned int = [global_heap_next+0] (used reg = )
|
|
mov ax,[_global_heap_next]
|
|
cmp ax,[_global_heap_end]
|
|
jbe .1
|
|
.2:
|
|
! 16 {
|
|
! 17 return 0;
|
|
xor ax,ax
|
|
inc sp
|
|
inc sp
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 18 }
|
|
! 19
|
|
! 20 return allocated_pointer;
|
|
.1:
|
|
mov ax,-6[bp]
|
|
inc sp
|
|
inc sp
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 21 }
|
|
! 22
|
|
! 23 void* calloc(number_elements, size)
|
|
! 24 unsigned int number_elements;
|
|
export _calloc
|
|
_calloc:
|
|
!BCC_EOS
|
|
! 25 unsigned int size;
|
|
!BCC_EOS
|
|
! 26 {
|
|
! 27 int i;
|
|
!BCC_EOS
|
|
! 28 char* temp_pointer;
|
|
!BCC_EOS
|
|
! 29 unsigned int num_bytes = number_elements * size;
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
add sp,*-6
|
|
! Debug: mul unsigned int size = [S+$C+4] to unsigned int number_elements = [S+$C+2] (used reg = )
|
|
mov ax,4[bp]
|
|
mov cx,6[bp]
|
|
imul cx
|
|
! Debug: eq unsigned int = ax+0 to unsigned int num_bytes = [S+$C-$C] (used reg = )
|
|
mov -$A[bp],ax
|
|
!BCC_EOS
|
|
! 30 void* allocated_pointer = global_heap_next;
|
|
dec sp
|
|
dec sp
|
|
! Debug: eq unsigned int = [global_heap_next+0] to * void allocated_pointer = [S+$E-$E] (used reg = )
|
|
mov bx,[_global_heap_next]
|
|
mov -$C[bp],bx
|
|
!BCC_EOS
|
|
! 31 global_heap_next = global_heap_next + num_bytes;
|
|
! Debug: add unsigned int num_bytes = [S+$E-$C] to unsigned int = [global_heap_next+0] (used reg = )
|
|
mov ax,[_global_heap_next]
|
|
add ax,-$A[bp]
|
|
! Debug: eq unsigned int = ax+0 to unsigned int = [global_heap_next+0] (used reg = )
|
|
mov [_global_heap_next],ax
|
|
!BCC_EOS
|
|
! 32 if (global_heap_next > global_heap_end)
|
|
! Debug: gt unsigned int = [global_heap_end+0] to unsigned int = [global_heap_next+0] (used reg = )
|
|
mov ax,[_global_heap_next]
|
|
cmp ax,[_global_heap_end]
|
|
jbe .3
|
|
.4:
|
|
! 33 {
|
|
! 34 return 0;
|
|
xor ax,ax
|
|
add sp,*8
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 35 }
|
|
! 36
|
|
! 37
|
|
! 38 temp_pointer = allocated_pointer;
|
|
.3:
|
|
! Debug: eq * void allocated_pointer = [S+$E-$E] to * char temp_pointer = [S+$E-$A] (used reg = )
|
|
mov bx,-$C[bp]
|
|
mov -8[bp],bx
|
|
!BCC_EOS
|
|
! 39 for (i = 0; i < num_bytes; ++i)
|
|
! Debug: eq int = const 0 to int i = [S+$E-8] (used reg = )
|
|
xor ax,ax
|
|
mov -6[bp],ax
|
|
!BCC_EOS
|
|
!BCC_EOS
|
|
! 40 {
|
|
jmp .7
|
|
.8:
|
|
! 41 *temp_pointer = 0;
|
|
mov bx,-8[bp]
|
|
! Debug: eq int = const 0 to char = [bx+0] (used reg = )
|
|
xor al,al
|
|
mov [bx],al
|
|
!BCC_EOS
|
|
! 42 temp_pointer++;
|
|
! Debug: postinc * char temp_pointer = [S+$E-$A] (used reg = )
|
|
mov bx,-8[bp]
|
|
inc bx
|
|
mov -8[bp],bx
|
|
!BCC_EOS
|
|
! 43 }
|
|
! 44
|
|
! 45 return allocated_pointer;
|
|
.6:
|
|
! Debug: preinc int i = [S+$E-8] (used reg = )
|
|
mov ax,-6[bp]
|
|
inc ax
|
|
mov -6[bp],ax
|
|
.7:
|
|
! Debug: lt unsigned int num_bytes = [S+$E-$C] to int i = [S+$E-8] (used reg = )
|
|
mov ax,-6[bp]
|
|
cmp ax,-$A[bp]
|
|
jb .8
|
|
.9:
|
|
.5:
|
|
mov ax,-$C[bp]
|
|
add sp,*8
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 46 }
|
|
! 47
|
|
! 48 int set_heap_settings(param_start, param_end)
|
|
! Register BX used in function calloc
|
|
! 49 unsigned int param_start;
|
|
export _set_heap_settings
|
|
_set_heap_settings:
|
|
!BCC_EOS
|
|
! 50 unsigned int param_end;
|
|
!BCC_EOS
|
|
! 51 {
|
|
! 52 global_heap_start = param_start;
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
! Debug: eq unsigned int param_start = [S+6+2] to unsigned int = [global_heap_start+0] (used reg = )
|
|
mov ax,4[bp]
|
|
mov [_global_heap_start],ax
|
|
!BCC_EOS
|
|
! 53 global_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
|
|
!BCC_EOS
|
|
! 54 global_heap_end = param_end;
|
|
! Debug: eq unsigned int param_end = [S+6+4] to unsigned int = [global_heap_end+0] (used reg = )
|
|
mov ax,6[bp]
|
|
mov [_global_heap_end],ax
|
|
!BCC_EOS
|
|
! 55 return 0;
|
|
xor ax,ax
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 56 }
|
|
! 57
|
|
! 58 unsigned int get_heap_next()
|
|
! 59 {
|
|
export _get_heap_next
|
|
_get_heap_next:
|
|
! 60 return global_heap_next;
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
mov ax,[_global_heap_next]
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 61 # 19 "main.h"
|
|
! 19 }
|
|
! 20 # 2 "std_singos/string.h"
|
|
! 2 type
|
|
! 2 def struct Length_String {
|
|
! 3 short dynamic;
|
|
!BCC_EOS
|
|
! 4 unsigned int length;
|
|
!BCC_EOS
|
|
! 5 char *chars;
|
|
!BCC_EOS
|
|
! 6 } Length_String;
|
|
!BCC_EOS
|
|
! 7
|
|
! 8 typedef struct String_Array {
|
|
! 9 unsigned int length;
|
|
!BCC_EOS
|
|
! 10 Length_String **strings;
|
|
!BCC_EOS
|
|
! 11 } String_Array;
|
|
!BCC_EOS
|
|
! 12
|
|
! 13 void strcpy (destination, destination_segment, source, source_segment );
|
|
!BCC_EOS
|
|
! 14 int strlen (source, source_segment);
|
|
!BCC_EOS
|
|
! 15 void memcpy (destination, destination_segment, source, source_segment, num_bytes );
|
|
!BCC_EOS
|
|
! 16
|
|
! 17
|
|
! 18 String_Array *string_split_c(string, delim, keep_delim);
|
|
!BCC_EOS
|
|
! 19 Length_String *make_length_string(length, chars);
|
|
!BCC_EOS
|
|
! 20 Length_String *make_length_string_c(cstring);
|
|
!BCC_EOS
|
|
! 21 String_Array *length_string_split(string, delim, keep_delim);
|
|
!BCC_EOS
|
|
! 22 String_Array *create_length_string_array(array_size);
|
|
!BCC_EOS
|
|
! 23 Length_String *create_length_string(length, chars);
|
|
!BCC_EOS
|
|
! 24
|
|
! 25
|
|
! 26
|
|
! 27 int strlen (source, source_segment)
|
|
! 28 {
|
|
export _strlen
|
|
_strlen:
|
|
! 29 #asm
|
|
!BCC_ASM
|
|
_strlen.source set 2
|
|
_strlen.source_segment set 4
|
|
|
|
|
|
push bp
|
|
mov bp,sp
|
|
push ds
|
|
push bx
|
|
|
|
mov ax, 6[bp];
|
|
mov ds, ax
|
|
|
|
mov bx, 4[bp];
|
|
|
|
label_strlen:
|
|
mov cx, #0x0 ; Set counte to zero
|
|
.label_strlen_loop:
|
|
mov BYTE al, [bx]
|
|
cmp al, #0x0
|
|
je .label_strlen_done
|
|
inc cx ; Count 1
|
|
inc bx ; Look at next char
|
|
jmp .label_strlen_loop
|
|
.label_strlen_done:
|
|
mov ax, cx
|
|
|
|
pop bx
|
|
pop ds
|
|
pop bp
|
|
! 57 endasm
|
|
!BCC_ENDASM
|
|
! 58 }
|
|
ret
|
|
! 59
|
|
! 60 void strcpy (destination, destination_segment, source, source_segment )
|
|
! 61 char *destination;
|
|
export _strcpy
|
|
_strcpy:
|
|
!BCC_EOS
|
|
! 62 int destination_segment;
|
|
!BCC_EOS
|
|
! 63 char *source;
|
|
!BCC_EOS
|
|
! 64 int source_segment;
|
|
!BCC_EOS
|
|
! 65 {
|
|
! 66 #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)
|
|
|
|
! 72 76
|
|
|
|
push bp
|
|
mov bp,sp
|
|
label_strcpy:
|
|
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 ;TODO(Jrn) Hardcded number of bytes to copy
|
|
.label_strcpy_loop:
|
|
movsb
|
|
cmp cx, 0x0
|
|
je .label_strcpy_end
|
|
dec cx
|
|
jmp .label_strcpy_loop
|
|
.label_strcpy_end:
|
|
pop ds
|
|
pop si
|
|
pop es
|
|
pop di
|
|
pop bx
|
|
pop ax
|
|
pop bp
|
|
|
|
! 110 endasm
|
|
!BCC_ENDASM
|
|
! 111 }
|
|
ret
|
|
! 112
|
|
! 113 void memcpy (destination, destination_segment, source, source_segment, num_bytes)
|
|
! 114 void *destination;
|
|
export _memcpy
|
|
_memcpy:
|
|
!BCC_EOS
|
|
! 115 int destination_segment;
|
|
!BCC_EOS
|
|
! 116 void *source;
|
|
!BCC_EOS
|
|
! 117 int source_segment;
|
|
!BCC_EOS
|
|
! 118 int num_bytes;
|
|
!BCC_EOS
|
|
! 119 {
|
|
! 120 #asm
|
|
!BCC_ASM
|
|
_memcpy.source set 6
|
|
_memcpy.destination set 2
|
|
_memcpy.num_bytes set $A
|
|
_memcpy.source_segment set 8
|
|
_memcpy.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)
|
|
|
|
! 126 131
|
|
|
|
push bp
|
|
mov bp,sp
|
|
label_memcpy:
|
|
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, 12[bp];
|
|
.label_memcpy_loop:
|
|
movsb
|
|
cmp cx, 0x0
|
|
je .label_memcpy_end
|
|
dec cx
|
|
jmp .label_memcpy_loop
|
|
.label_memcpy_end:
|
|
pop ds
|
|
pop si
|
|
pop es
|
|
pop di
|
|
pop bx
|
|
pop ax
|
|
pop bp
|
|
|
|
! 165 endasm
|
|
!BCC_ENDASM
|
|
! 166 }
|
|
ret
|
|
! 167
|
|
! 168 int strcmp(source_1, source_2)
|
|
! 169 char* source_1;
|
|
export _strcmp
|
|
_strcmp:
|
|
!BCC_EOS
|
|
! 170 char* source_2;
|
|
!BCC_EOS
|
|
! 171 {
|
|
! 172 int i;
|
|
!BCC_EOS
|
|
! 173 int count;
|
|
!BCC_EOS
|
|
! 174
|
|
! 175 count = strlen(source_1, 0x7e0);
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
add sp,*-4
|
|
! Debug: list int = const $7E0 (used reg = )
|
|
mov ax,#$7E0
|
|
push ax
|
|
! Debug: list * char source_1 = [S+$C+2] (used reg = )
|
|
push 4[bp]
|
|
! Debug: func () int = strlen+0 (used reg = )
|
|
call _strlen
|
|
add sp,*4
|
|
! Debug: eq int = ax+0 to int count = [S+$A-$A] (used reg = )
|
|
mov -8[bp],ax
|
|
!BCC_EOS
|
|
! 176 if (count != strlen(source_2, 0x7e0))
|
|
! Debug: list int = const $7E0 (used reg = )
|
|
mov ax,#$7E0
|
|
push ax
|
|
! Debug: list * char source_2 = [S+$C+4] (used reg = )
|
|
push 6[bp]
|
|
! Debug: func () int = strlen+0 (used reg = )
|
|
call _strlen
|
|
add sp,*4
|
|
! Debug: ne int = ax+0 to int count = [S+$A-$A] (used reg = )
|
|
! Debug: expression subtree swapping
|
|
cmp ax,-8[bp]
|
|
je .A
|
|
.B:
|
|
! 177 {
|
|
! 178 return -1;
|
|
mov ax,*-1
|
|
add sp,*4
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 179 }
|
|
! 180
|
|
! 181
|
|
! 182 for (i = 0; i < count; i++)
|
|
.A:
|
|
! Debug: eq int = const 0 to int i = [S+$A-8] (used reg = )
|
|
xor ax,ax
|
|
mov -6[bp],ax
|
|
!BCC_EOS
|
|
!BCC_EOS
|
|
! 183 {
|
|
jmp .E
|
|
.F:
|
|
! 184 if(source_1[i] != source_2[i])
|
|
! Debug: ptradd int i = [S+$A-8] to * char source_2 = [S+$A+4] (used reg = )
|
|
mov ax,-6[bp]
|
|
add ax,6[bp]
|
|
mov bx,ax
|
|
! Debug: ptradd int i = [S+$A-8] to * char source_1 = [S+$A+2] (used reg = bx)
|
|
mov ax,-6[bp]
|
|
add ax,4[bp]
|
|
mov si,ax
|
|
! Debug: ne char = [bx+0] to char = [si+0] (used reg = )
|
|
mov al,[si]
|
|
cmp al,[bx]
|
|
je .10
|
|
.11:
|
|
! 185 {
|
|
! 186 return -1;
|
|
mov ax,*-1
|
|
add sp,*4
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 187 }
|
|
! 188 }
|
|
.10:
|
|
! 189
|
|
! 190 return 0;
|
|
.D:
|
|
! Debug: postinc int i = [S+$A-8] (used reg = )
|
|
mov ax,-6[bp]
|
|
inc ax
|
|
mov -6[bp],ax
|
|
.E:
|
|
! Debug: lt int count = [S+$A-$A] to int i = [S+$A-8] (used reg = )
|
|
mov ax,-6[bp]
|
|
cmp ax,-8[bp]
|
|
jl .F
|
|
.12:
|
|
.C:
|
|
xor ax,ax
|
|
add sp,*4
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 191 # 223
|
|
! 223
|
|
! 224 }
|
|
! 225
|
|
! 226 String_Array *string_split_c(string, delim, keep_delim)
|
|
! Register BX SI used in function strcmp
|
|
! 227 char *string;
|
|
export _string_split_c
|
|
_string_split_c:
|
|
!BCC_EOS
|
|
! 228 char delim;
|
|
!BCC_EOS
|
|
! 229 short keep_delim;
|
|
!BCC_EOS
|
|
! 230 {
|
|
! 231 return length_string_split(make_length_string_c(string), delim, keep_delim);
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
! Debug: list short keep_delim = [S+6+6] (used reg = )
|
|
push 8[bp]
|
|
! Debug: list char delim = [S+8+4] (used reg = )
|
|
mov al,6[bp]
|
|
xor ah,ah
|
|
push ax
|
|
! Debug: list * char string = [S+$A+2] (used reg = )
|
|
push 4[bp]
|
|
! Debug: func () * struct Length_String = make_length_string_c+0 (used reg = )
|
|
call _make_length_string_c
|
|
inc sp
|
|
inc sp
|
|
! Debug: list * struct Length_String = ax+0 (used reg = )
|
|
push ax
|
|
! Debug: func () * struct String_Array = length_string_split+0 (used reg = )
|
|
call _length_string_split
|
|
add sp,*6
|
|
! Debug: cast * struct String_Array = const 0 to * struct String_Array = ax+0 (used reg = )
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 232 }
|
|
! 233
|
|
! 234 Length_String *make_length_string_c(cstring)
|
|
! 235 char *cstring;
|
|
export _make_length_string_c
|
|
_make_length_string_c:
|
|
!BCC_EOS
|
|
! 236 {
|
|
! 237 return make_length_string(strlen(cstring, 0x7e0), cstring);
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
! Debug: list * char cstring = [S+6+2] (used reg = )
|
|
push 4[bp]
|
|
! Debug: list int = const $7E0 (used reg = )
|
|
mov ax,#$7E0
|
|
push ax
|
|
! Debug: list * char cstring = [S+$A+2] (used reg = )
|
|
push 4[bp]
|
|
! Debug: func () int = strlen+0 (used reg = )
|
|
call _strlen
|
|
add sp,*4
|
|
! Debug: list int = ax+0 (used reg = )
|
|
push ax
|
|
! Debug: func () * struct Length_String = make_length_string+0 (used reg = )
|
|
call _make_length_string
|
|
add sp,*4
|
|
! Debug: cast * struct Length_String = const 0 to * struct Length_String = ax+0 (used reg = )
|
|
pop si
|
|
pop di
|
|
pop bp
|
|
ret
|
|
!BCC_EOS
|
|
! 238 }
|
|
! 239
|
|
! 240 Length_String *make_length_string(length, chars)
|
|
! 241 unsigned int length;
|
|
export _make_length_string
|
|
_make_length_string:
|
|
!BCC_EOS
|
|
! 242 char *chars;
|
|
!BCC_EOS
|
|
! 243 {
|
|
! 244
|
|
! 245 Length_String *legth_string = malloc(sizeof(Length_String));
|
|
push bp
|
|
mov bp,sp
|
|
push di
|
|
push si
|
|
dec sp
|
|
dec sp
|
|
! Debug: list int = const 6 (used reg = )
|
|
mov ax,*6
|
|
push ax
|
|
! Debug: func () * void = malloc+0 (used reg = )
|
|
call _malloc
|
|
inc sp
|
|
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
|
|
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 = )
|
|
inc ax
|
|
push ax
|
|
! Debug: func () * void = malloc+0 (used reg = )
|
|
call _malloc
|
|
inc sp
|
|
inc sp
|
|
! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = )
|
|
mov -8[bp],ax
|
|
!BCC_EOS
|
|
! 247 memcpy(copy, 0x7e0, chars, 0x7e0, length);
|
|
! Debug: list unsigned int length = [S+$A+2] (used reg = )
|
|
push 4[bp]
|
|
! Debug: list int = const $7E0 (used reg = )
|
|
mov ax,#$7E0
|
|
push ax
|
|
! Debug: list * char chars = [S+$E+4] (used reg = )
|
|
push 6[bp]
|
|
! Debug: list int = const $7E0 (used reg = )
|
|
mov ax,#$7E0
|
|
push ax
|
|
! Debug: list * char copy = [S+$12-$A] (used reg = )
|
|
push -8[bp]
|
|
! Debug: func () void = memcpy+0 (used reg = )
|
|
call _memcpy
|
|
add sp,*$A
|
|
!BCC_EOS
|
|
! 248 copy[length] = ' |