-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreverse.asm
54 lines (34 loc) · 888 Bytes
/
reverse.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
; reverse string
name "reverse"
org 100h
jmp start
; when reversed it will be a readable string,
; '$' marks the end of the string:
string1 db '!gnirts a si siht$'
start: lea bx, string1
mov si, bx
next_byte: cmp [si], '$'
je found_the_end
inc si
jmp next_byte
found_the_end: dec si
; now bx points to beginning,
; and si points to the end of string.
; do the swapping:
do_reverse: cmp bx, si
jae done
mov al, [bx]
mov ah, [si]
mov [si], al
mov [bx], ah
inc bx
dec si
jmp do_reverse
; reverse complete, print out:
done: lea dx, string1
mov ah, 09h
int 21h
; wait for any key press....
mov ah, 0
int 16h
ret