-
Notifications
You must be signed in to change notification settings - Fork 0
/
emu8086_subStringCheck.asm
95 lines (74 loc) · 1.09 KB
/
emu8086_subStringCheck.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
org 100h
include 'emu8086.inc'
jmp start:
str1 db 'assembly', 0;
str2 db 'sdf', 0;
start:
mov si, 0;
mov di, 0;
mov ax, 0;
lengthOfFirstString:
cmp str1[si],0;
je gotLengthOne;
inc ax;
inc si;
jmp lengthOfFirstString;
gotLengthOne:
print "First String Length: ";
call print_num_uns;
printn "";
mov ax, 0;
mov si, 0;
mov di, 0;
lengthOfSecondString:
cmp str2[di], 0;
je gotLengthTwo;
inc di;
inc ax;
jmp lengthOfSecondString;
gotLengthTwo:
print "Second String Length: ";
call print_num_uns;
printn "";
mov di, 0;
mov si, 0;
mov bx, ax;
mov ax, 0;
substringCheck:
cmp str1[si], 0;
je stop;
mov dl, str1[si];
mov cl , str2[di];
cmp str1[si], 0;
je stop;
cmp str2[di], 0;
je stop;
inc si;
inc di;
cmp dl, cl;
je one;
jne two;
jmp substringCheck;
one:
inc ax;
jmp substringCheck;
two:
cmp ax, 1;
je temp;
mov ax, 0;
mov di, 0;
jmp substringCheck;
temp:
dec si;
mov ax, 0;
mov di, 0;
jmp substringCheck;
stop:
cmp bx, ax;
je decision;
printn "Decision: Not Substring";
ret;
decision:
printn "Decision: Substring";
define_print_num_uns;
ret;