-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.h
104 lines (91 loc) · 1.7 KB
/
string.h
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
96
97
98
99
100
101
102
103
104
extrn strlen_proc:far
extrn strcat_proc:far
extrn strchr_proc:far
extrn memset_proc:far
extrn strcmp_proc:far
extrn atof_proc:far
strlen macro s, len
lea di, s
call strlen_proc
mov [len], ax
endm
strcat macro dest, source
lea di, dest
lea si, source
call far ptr strcat_proc
endm
strchr macro s, c, gasit
lea si, s
mov ah, c
call far ptr strchr_proc
mov [gasit], al
endm
memset macro s, c, count
mov al, c
lea di, s
mov cx, count
call far ptr memset_proc
endm
; pos din source
strpcat macro dest, source, pos
lea di, dest
lea si, source
add si, pos
call far ptr strcat_proc
endm
; compara 2 siruri
strcmp macro cs, ct, gasit
lea si, cs
lea di, ct
call far ptr strcmp_proc
mov [gasit], ax
endm
; str delete last character
strdlc macro source
local @@sfarsit
lea di, source
call far ptr strlen_proc
; Daca sirul are lungimea 0, terminam operatia
cmp ax, 0
je @@sfarsit
; Punem la sfarsitul sirului 0
lea si, source
add si, ax
dec si
mov byte ptr [si], 0
@@sfarsit:
endm
; str delete zero
strdz macro source
local @@sfarsit, @@again, @@go_on, stiintific
.data
stiintific db 0
.code
strchr source, 'E', stiintific
cmp byte ptr [stiintific], 1
je @@sfarsit
lea di, source
call far ptr strlen_proc
; Daca sirul are lungimea 0, terminam operatia
cmp ax, 0
je @@sfarsit
; Punem la sfarsitul sirului 0
lea si, source
add si, ax
dec si
@@again:
cmp byte ptr [si], '.'
jne @@go_on
mov byte ptr [si], 0
jmp @@sfarsit
@@go_on:
cmp byte ptr [si], '0'
jne @@sfarsit
cmp ax, 1
je @@sfarsit
mov byte ptr [si], 0
dec si
dec ax
jmp @@again
@@sfarsit:
endm