Save work
This commit is contained in:
1 parent
c7ad92b3b2
commit
e12768398d
4 files changed
+277
-159
No files matched your search
+44
-10
@@ -1,6 +1,40 @@
|
||||
void strcpy (destination, destination_segment, source, source_segment );
|
||||
int strlen (source, source_segment);
|
||||
void memcpy (destination, destination_segment, source, source_segment, num_bytes );
|
||||
|
||||
int strlen (source, source_segment)
|
||||
{
|
||||
#asm
|
||||
#define strlen_SOURCE 4[bp];
|
||||
#define strlen_SOURCE_SEGMENT 6[bp];
|
||||
push bp
|
||||
mov bp,sp
|
||||
push ds
|
||||
push bx
|
||||
|
||||
mov ax, strlen_SOURCE_SEGMENT
|
||||
mov ds, ax
|
||||
|
||||
mov bx, strlen_SOURCE
|
||||
|
||||
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
|
||||
#endasm
|
||||
}
|
||||
|
||||
void strcpy (destination, destination_segment, source, source_segment )
|
||||
char *destination;
|
||||
int destination_segment;
|
||||
@@ -20,7 +54,7 @@ int source_segment;
|
||||
|
||||
push bp
|
||||
mov bp,sp
|
||||
stringcompare:
|
||||
label_strcpy:
|
||||
push ax
|
||||
push bx
|
||||
push di
|
||||
@@ -36,13 +70,13 @@ int source_segment;
|
||||
mov ax, SOURCE_SEGMENT;
|
||||
mov ds, ax
|
||||
mov cx, 0x050 // TODO(Jørn) Hardcded number of bytes to copy
|
||||
.loop:
|
||||
.label_strcpy_loop:
|
||||
movsb
|
||||
cmp cx, 0x0
|
||||
je .end
|
||||
je .label_strcpy_end
|
||||
dec cx
|
||||
jmp .loop
|
||||
.end:
|
||||
jmp .label_strcpy_loop
|
||||
.label_strcpy_end:
|
||||
pop ds
|
||||
pop si
|
||||
pop es
|
||||
@@ -75,7 +109,7 @@ int num_bytes;
|
||||
|
||||
push bp
|
||||
mov bp,sp
|
||||
memcpy:
|
||||
label_memcpy:
|
||||
push ax
|
||||
push bx
|
||||
push di
|
||||
@@ -91,13 +125,13 @@ int num_bytes;
|
||||
mov ax, SOURCE_SEGMENT;
|
||||
mov ds, ax
|
||||
mov cx, NUM_BYTES
|
||||
.memcpy_loop:
|
||||
.label_memcpy_loop:
|
||||
movsb
|
||||
cmp cx, 0x0
|
||||
je .end
|
||||
je .label_memcpy_end
|
||||
dec cx
|
||||
jmp .loop
|
||||
.memcpy_end:
|
||||
jmp .label_memcpy_loop
|
||||
.label_memcpy_end:
|
||||
pop ds
|
||||
pop si
|
||||
pop es
|
||||
|
||||
Reference in new issue
Block a user