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

+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 memcpy (destination, destination_segment, source, source_segment, num_bytes );
void strcpy (destination, destination_segment, source, source_segment )
char *destination;
@@ -52,3 +53,58 @@ int source_segment;
#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
}