-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab#09__Task#1.asm
More file actions
63 lines (51 loc) · 903 Bytes
/
Lab#09__Task#1.asm
File metadata and controls
63 lines (51 loc) · 903 Bytes
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
63
.model small
.stack 100h
.data
original db 'My name is Farhan!', 0
reversed db 50 dup('$')
len equ $-original-1
.code
main proc
mov ax, @data
mov ds, ax
mov es, ax
lea si, original
lea di, reversed
mov cx, len
call reverse_string
lea dx, original
mov ah, 9
int 21h
call newline
lea dx, reversed
mov ah, 9
int 21h
mov ah, 4Ch
int 21h
main endp
reverse_string proc
push cx
push si
push di
mov si, 0
mov di, len-1
reverse_loop:
mov al, [original + si]
mov [reversed + di], al
inc si
dec di
loop reverse_loop
pop di
pop si
pop cx
ret
reverse_string endp
newline proc
mov ah, 2
mov dl, 10
int 21h
mov dl, 13
int 21h
ret
newline endp
end main