-
Notifications
You must be signed in to change notification settings - Fork 0
/
blkcpy.asm
62 lines (54 loc) · 910 Bytes
/
blkcpy.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
.8086
.model small
.stack 100
.data
arr1 db "abcdefghijklmnopqrstuvwxyz", 0AH, 0DH, "$"
arr2 db "HelloWorld!", 0Ah, 0dh, "$"
.code
start:
mov ax, @data
mov ds, ax
mov es, ax
mov dx, offset arr1
mov ah, 09h
int 21H
mov dx, offset arr2
mov ah, 09h
int 21H
mov si, offset arr1
mov di, offset arr2
mov cx, 0AH
call memcpy
mov dx, offset arr1
mov ah, 09h
int 21H
mov dx, offset arr2
mov ah, 09h
int 21H
mov ah, 4ch
int 21H
;Assuming that starting address of source block, starting address of destination block and size of block is in si, di and cx
memcpy proc
pushf
push si
push di
push cx
CLD
cmp si, di
ja block_copy
;if si < di then start coping from final address of block else start coping from starting address of block
dec cx
add si, cx
add di, cx
inc cx
STD
block_copy:
movsb
LOOP block_copy
pop cx
pop di
pop si
popf
ret
endp
end start