Subversion Repositories Kolibri OS

Rev

Rev 1476 | Rev 2102 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1476 Rev 2086
1
struct FileInfoBlock
1
struct FileInfoBlock
2
	Function dd ?
2
	Function dd ?
3
	Position dd ?
3
	Position dd ?
4
	Flags	 dd ?
4
	Flags	 dd ?
5
	Count	 dd ?
5
	Count	 dd ?
6
	Buffer	 dd ?
6
	Buffer	 dd ?
7
		db ?
7
		db ?
8
	FileName dd ?
8
	FileName dd ?
9
ends
9
ends
10
 
10
 
11
struct TexColViv
11
struct TexColViv
12
  Text rb MAX_COLOR_WORD_LEN ; ñëîâî
12
  Text rb MAX_COLOR_WORD_LEN ; ñëîâî
13
  f1 dd 0
13
  f1 dd 0
14
  wwo db ? ; whole words only
14
  wwo db ? ; whole words only
15
  endc db ? ; ñèìâîë êîíöà âûäåëåíèÿ (wwo&4)
15
  endc db ? ; ñèìâîë êîíöà âûäåëåíèÿ (wwo&4)
16
  color db ? ; íîìåð öâåòà
16
  color db ? ; íîìåð öâåòà
17
ends
17
ends
18
 
18
 
19
count_colors_text dd 1
19
count_colors_text dd 1
20
ColWords dd 0
20
ColWords dd 0
21
color_cursor dd ?
21
color_cursor dd ?
22
color_wnd_capt dd ?
22
color_wnd_capt dd ?
23
color_wnd_work dd ?
23
color_wnd_work dd ?
24
color_wnd_bord dd ?
24
color_wnd_bord dd ?
25
color_select dd ?
25
color_select dd ?
26
color_cur_text dd ?
26
color_cur_text dd ?
27
color_wnd_text dd ?
27
color_wnd_text dd ?
28
 
28
 
29
options_file dd 0
29
options_file dd 0
30
options_file_end dd 0
30
options_file_end dd 0
31
tex_colors dd 0
31
tex_colors dd 0
32
tex_help_f1 dd 0
32
tex_help_f1 dd 0
33
 
33
 
34
Col dd 0 ;óêàçàòåëü íà ñòðóêòóðû êëþ÷åâûõ ñëîâ TexColViv
34
Col dd 0 ;óêàçàòåëü íà ñòðóêòóðû êëþ÷åâûõ ñëîâ TexColViv
35
 
35
 
36
keyUpr dd 0
36
keyUpr dd 0
37
err_opn db 0 ;îøèáêà îòêðûòèÿ ôàéëà
37
err_opn db 0 ;îøèáêà îòêðûòèÿ ôàéëà
38
err_sav db 0 ;îøèáêà ñîõðàíåíèÿ ôàéëà
38
err_sav db 0 ;îøèáêà ñîõðàíåíèÿ ôàéëà
39
 
39
 
40
sc system_colors
40
sc system_colors
41
 
41
 
42
run_file_70 FileInfoBlock
42
run_file_70 FileInfoBlock
43
 
43
 
44
align 4
44
align 4
45
InitColText:
45
InitColText:
46
	pushad
46
	pushad
47
 
47
 
48
	mov  ebx,dword[fn_col_option]
48
	mov  ebx,dword[fn_col_option]
49
	copy_path ebx,fn_syntax_dir,file_name_rez,0
49
	copy_path ebx,fn_syntax_dir,file_name_rez,0
50
	copy_path file_name_rez,sys_path,file_name,0
50
	copy_path file_name_rez,sys_path,file_name,0
51
 
51
 
52
  mov eax,70
52
  mov eax,70
53
  mov [run_file_70.Function], 0
53
  mov [run_file_70.Function], 0
54
  mov [run_file_70.Position], 0
54
  mov [run_file_70.Position], 0
55
  mov [run_file_70.Flags], 0
55
  mov [run_file_70.Flags], 0
56
  mov ebx,[options_file_end]
56
  mov ebx,[options_file_end]
57
  sub ebx,[options_file]
57
  sub ebx,[options_file]
58
  mov [run_file_70.Count], ebx
58
  mov [run_file_70.Count], ebx
59
  m2m [run_file_70.Buffer], [options_file]
59
  m2m [run_file_70.Buffer], [options_file]
60
  mov byte[run_file_70+20], 0
60
  mov byte[run_file_70+20], 0
61
  mov [run_file_70.FileName], file_name
61
  mov [run_file_70.FileName], file_name
62
  mov ebx,run_file_70
62
  mov ebx,run_file_70
63
  int 0x40
63
  int 0x40
64
 
64
 
65
 
65
 
66
	;init: count_colors_text, ColWords, ...
66
	;init: count_colors_text, ColWords, ...
67
	mov dword[count_colors_text],1
67
	mov dword[count_colors_text],1
68
	mov dword[ColWords],0
68
	mov dword[ColWords],0
69
	mov dword[tex_help_f1],0
69
	mov dword[tex_help_f1],0
70
 
70
 
71
  cmp eax,6
71
  cmp eax,6
72
  je @f
72
  je @f
73
  cmp eax,0
73
  cmp eax,0
74
  je @f
74
  je @f
75
    cmp ax,10
75
    cmp ax,10
76
    jl .zifra_0_9
76
    jl .zifra_0_9
77
      mov al,'?'
77
      mov al,'?'
78
      sub ax,48
78
      sub ax,48
79
    .zifra_0_9:
79
    .zifra_0_9:
80
    add ax,48
80
    add ax,48
81
 
81
 
82
    jmp .no_colors
82
    jmp .no_colors
83
  @@:
83
  @@:
84
 
84
 
85
	mov esi,[options_file]
85
	mov esi,[options_file]
86
	mov edi,count_colors_text
86
	mov edi,count_colors_text
87
	mov ecx,9*4
87
	mov ecx,9*4
88
	rep movsb
88
	rep movsb
89
 
89
 
90
	mov eax,[options_file]
90
	mov eax,[options_file]
91
	add eax,32
91
	add eax,32
92
	mov dword[tex_colors],eax
92
	mov dword[tex_colors],eax
93
 
93
 
94
	mov eax,dword[count_colors_text] ;init: Col (offset to key words)
94
	mov eax,dword[count_colors_text] ;init: Col (offset to key words)
95
	add eax,8
95
	add eax,8
96
	shl eax,2
96
	shl eax,2
97
	add eax,[options_file]
97
	add eax,[options_file]
98
	mov dword[Col],eax
98
	mov dword[Col],eax
99
 
99
 
100
	;init: tex_help_f1
100
	;init: tex_help_f1
101
	mov ecx,dword[ColWords]
101
	mov ecx,dword[ColWords]
102
	imul ecx,sizeof.TexColViv
102
	imul ecx,sizeof.TexColViv
103
	add ecx,dword[Col]
103
	add ecx,dword[Col]
104
	mov dword[tex_help_f1],ecx
104
	mov dword[tex_help_f1],ecx
105
 
105
 
106
	;ôîðìèðîâàíèå òåêñòà â îêíå òåêñòîâîãî ðåäàêòîðà
106
	;ôîðìèðîâàíèå òåêñòà â îêíå òåêñòîâîãî ðåäàêòîðà
107
	stdcall [ted_clear], tedit0,1
107
	stdcall [ted_clear], tedit0,1
108
 
108
 
109
	stdcall print_capt,capt_header
109
	stdcall print_capt,capt_header
110
 
110
 
111
	stdcall print_capt,col_1
111
	stdcall print_capt,col_1
112
	stdcall print_color,[color_cursor]
112
	stdcall print_color,[color_cursor]
113
	stdcall print_capt,col_2
113
	stdcall print_capt,col_2
114
	stdcall print_color,[color_wnd_capt]
114
	stdcall print_color,[color_wnd_capt]
115
	stdcall print_capt,col_3
115
	stdcall print_capt,col_3
116
	stdcall print_color,[color_wnd_work]
116
	stdcall print_color,[color_wnd_work]
117
	stdcall print_capt,col_4
117
	stdcall print_capt,col_4
118
	stdcall print_color,[color_wnd_bord]
118
	stdcall print_color,[color_wnd_bord]
119
	stdcall print_capt,col_5
119
	stdcall print_capt,col_5
120
	stdcall print_color,[color_select]
120
	stdcall print_color,[color_select]
121
	stdcall print_capt,col_6
121
	stdcall print_capt,col_6
122
	stdcall print_color,[color_cur_text]
122
	stdcall print_color,[color_cur_text]
123
 
123
 
124
	stdcall print_capt,col_7
124
	stdcall print_capt,col_7
125
	mov ecx,[count_colors_text] ;êîëè÷åñòâî öâåòîâ òåêñòà
125
	mov ecx,[count_colors_text] ;êîëè÷åñòâî öâåòîâ òåêñòà
126
	mov eax,[tex_colors]
126
	mov eax,[tex_colors]
127
	@@:
127
	@@:
128
		stdcall print_capt,capt_type_dd
128
		stdcall print_capt,capt_type_dd
129
		stdcall print_color,[eax]
129
		stdcall print_color,[eax]
130
		add eax,4
130
		add eax,4
131
	loop @b
131
	loop @b
132
 
132
 
133
	stdcall print_capt,capt_lbl_wo
133
	stdcall print_capt,capt_lbl_wo
134
	mov ecx,dword[ColWords]
134
	mov ecx,dword[ColWords]
135
	mov eax,[Col]
135
	mov eax,[Col]
136
	xor ebx,ebx
136
	xor ebx,ebx
137
	@@:
137
	@@:
138
		inc ebx
138
		inc ebx
139
		stdcall print_word,eax,ebx
139
		stdcall print_word,eax,ebx
140
		add eax,sizeof.TexColViv
140
		add eax,sizeof.TexColViv
141
	loop @b
141
	loop @b
142
 
142
 
143
	stdcall print_capt,capt_lbl_f1
143
	stdcall print_capt,capt_lbl_f1
144
	mov ecx,dword[ColWords]
144
	mov ecx,dword[ColWords]
145
	mov eax,[Col]
145
	mov eax,[Col]
146
	xor ebx,ebx
146
	xor ebx,ebx
147
	@@:
147
	@@:
148
		inc ebx
148
		inc ebx
149
		stdcall print_word_f1,eax,ebx
149
		stdcall print_word_f1,eax,ebx
150
		add eax,sizeof.TexColViv
150
		add eax,sizeof.TexColViv
151
	loop @b
151
	loop @b
152
	
152
	
153
	stdcall [ted_init_scroll_bars], tedit0,4
153
	;stdcall [ted_init_scroll_bars], tedit0,4
-
 
154
	;stdcall [ted_draw], tedit0
154
	stdcall [ted_draw], tedit0
155
	call draw_window
155
 
156
 
156
	.no_colors:
157
	.no_colors:
157
	popad
158
	popad
158
	ret
159
	ret
159
 
160
 
160
align 4
161
align 4
161
proc print_color, color:dword
162
proc print_color, color:dword
162
	pushad
163
	pushad
163
	mov eax,dword[color]
164
	mov eax,dword[color]
164
 
165
 
165
	mov ebx,eax ;ìåíÿåì ìåñòàìè red è blue
166
	mov ebx,eax ;ìåíÿåì ìåñòàìè red è blue
166
	shr ebx,16
167
	shr ebx,16
167
	xchg al,bl
168
	xchg al,bl
168
	and eax,0xffff
169
	and eax,0xffff
169
	and ebx,0xff
170
	and ebx,0xff
170
	shl ebx,16
171
	shl ebx,16
171
	or eax,ebx
172
	or eax,ebx
172
 
173
 
173
	ror al,4
174
	ror al,4
174
	ror eax,8
175
	ror eax,8
175
	ror al,4
176
	ror al,4
176
	ror eax,8
177
	ror eax,8
177
	ror al,4
178
	ror al,4
178
	rol eax,16
179
	rol eax,16
179
	mov edi,text_buffer
180
	mov edi,text_buffer
180
	mov word[edi],'0x'
181
	mov word[edi],'0x'
181
	add edi,2
182
	add edi,2
182
	mov ecx,6
183
	mov ecx,6
183
	@@:
184
	@@:
184
		mov ebx,eax
185
		mov ebx,eax
185
		and ebx,0xf
186
		and ebx,0xf
186
		cmp bx,9
187
		cmp bx,9
187
		jle .cifra
188
		jle .cifra
188
			add bx,39
189
			add bx,39
189
		.cifra:
190
		.cifra:
190
		add bx,48
191
		add bx,48
191
		mov byte[edi],bl
192
		mov byte[edi],bl
192
		inc edi
193
		inc edi
193
		shr eax,4
194
		shr eax,4
194
	loop @b
195
	loop @b
195
	mov byte[edi],13
196
	mov byte[edi],13
196
	mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
197
	mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
197
	stdcall [ted_text_add], tedit0,text_buffer,9,ebx
198
	stdcall [ted_text_add], tedit0,text_buffer,9,ebx
198
	popad
199
	popad
199
	ret
200
	ret
200
endp
201
endp
201
 
202
 
202
align 4
203
align 4
203
proc print_capt, capt:dword
204
proc print_capt, capt:dword
204
	pushad
205
	pushad
205
	mov esi,dword[capt]
206
	mov esi,dword[capt]
206
	stdcall str_len,esi
207
	stdcall str_len,esi
207
	stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_change_time+ted_opt_ed_move_cursor
208
	stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_change_time+ted_opt_ed_move_cursor
208
	popad
209
	popad
209
	ret
210
	ret
210
endp
211
endp
211
 
212
 
212
align 4
213
align 4
213
proc print_word, text:dword, index:dword
214
proc print_word, text:dword, index:dword
214
	pushad
215
	pushad
215
	mov esi,text_buffer
216
	mov esi,text_buffer
216
	mov byte[esi],0
217
	mov byte[esi],0
217
	stdcall str_cat,esi,capt_beg_word
218
	stdcall str_cat,esi,capt_beg_word
218
	stdcall str_len,esi
219
	stdcall str_len,esi
219
	add esi,eax
220
	add esi,eax
220
 
221
 
221
	mov edi,dword[text]	
222
	mov edi,dword[text]	
222
	stdcall code_string,edi,esi ;êîäèðóåì ñòðîêó ñ êëþ÷åâûì ñëîâîì
223
	stdcall code_string,edi,esi ;êîäèðóåì ñòðîêó ñ êëþ÷åâûì ñëîâîì
223
	stdcall str_cat,esi,capt_end_word
224
	stdcall str_cat,esi,capt_end_word
224
 
225
 
225
	cmp dword[edi+MAX_COLOR_WORD_LEN],0 ;f1
226
	cmp dword[edi+MAX_COLOR_WORD_LEN],0 ;f1
226
	je @f
227
	je @f
227
		stdcall str_cat,esi,capt_calc_f1
228
		stdcall str_cat,esi,capt_calc_f1
228
		stdcall str_cat_value,esi,[index]
229
		stdcall str_cat_value,esi,[index]
229
		stdcall str_cat,esi,capt_lbl_f1_use
230
		stdcall str_cat,esi,capt_lbl_f1_use
230
		jmp .end_f1_calc
231
		jmp .end_f1_calc
231
	@@:
232
	@@:
232
		stdcall str_cat,esi,capt_null
233
		stdcall str_cat,esi,capt_null
233
	.end_f1_calc:
234
	.end_f1_calc:
234
 
235
 
235
	mov esi,text_buffer
236
	mov esi,text_buffer
236
	stdcall str_len,esi ;óçíàåì äëèííó âñåé ñòðîêè
237
	stdcall str_len,esi ;óçíàåì äëèííó âñåé ñòðîêè
237
	stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_change_time+ted_opt_ed_move_cursor
238
	stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_change_time+ted_opt_ed_move_cursor
238
 
239
 
239
mov ecx,edi
240
mov ecx,edi
240
mov edi,text_buffer
241
mov edi,text_buffer
241
mov byte[edi],','
242
mov byte[edi],','
242
inc edi
243
inc edi
243
mov byte[edi],0
244
mov byte[edi],0
244
	xor eax,eax
245
	xor eax,eax
245
	mov al,byte[ecx+MAX_COLOR_WORD_LEN+4] ;wwo
246
	mov al,byte[ecx+MAX_COLOR_WORD_LEN+4] ;wwo
246
	stdcall str_cat_value,edi,eax
247
	stdcall str_cat_value,edi,eax
247
	stdcall str_len,edi
248
	stdcall str_len,edi
248
	add edi,eax
249
	add edi,eax
249
	mov byte[edi],','
250
	mov byte[edi],','
250
	inc edi
251
	inc edi
251
 
252
 
252
	xor eax,eax
253
	xor eax,eax
253
	mov al,byte[ecx+MAX_COLOR_WORD_LEN+4+1] ;endc
254
	mov al,byte[ecx+MAX_COLOR_WORD_LEN+4+1] ;endc
254
	cmp al,0
255
	cmp al,0
255
	je @f
256
	je @f
256
		stdcall str_cat_value,edi,eax
257
		stdcall str_cat_value,edi,eax
257
		stdcall str_len,edi
258
		stdcall str_len,edi
258
		add edi,eax
259
		add edi,eax
259
	@@:
260
	@@:
260
	mov byte[edi],','
261
	mov byte[edi],','
261
	inc edi
262
	inc edi
262
 
263
 
263
	xor eax,eax
264
	xor eax,eax
264
	mov al,byte[ecx+MAX_COLOR_WORD_LEN+4+2] ;color
265
	mov al,byte[ecx+MAX_COLOR_WORD_LEN+4+2] ;color
265
	stdcall str_cat_value,edi,eax
266
	stdcall str_cat_value,edi,eax
266
	stdcall str_len,edi
267
	stdcall str_len,edi
267
	add edi,eax
268
	add edi,eax
268
	mov byte[edi],13
269
	mov byte[edi],13
269
	inc edi
270
	inc edi
270
	mov byte[edi],0
271
	mov byte[edi],0
271
 
272
 
272
	mov esi,text_buffer
273
	mov esi,text_buffer
273
	stdcall str_len,esi
274
	stdcall str_len,esi
274
	stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_move_cursor
275
	stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_move_cursor
275
 
276
 
276
	popad
277
	popad
277
	ret
278
	ret
278
endp
279
endp
279
 
280
 
280
align 4
281
align 4
281
proc print_word_f1, text:dword, index:dword
282
proc print_word_f1, text:dword, index:dword
282
	pushad
283
	pushad
283
	mov edi,dword[text]
284
	mov edi,dword[text]
284
	mov esi,dword[edi+MAX_COLOR_WORD_LEN] ;f1
285
	mov esi,dword[edi+MAX_COLOR_WORD_LEN] ;f1
285
	cmp esi,0
286
	cmp esi,0
286
	je @f
287
	je @f
287
		mov ebx,text_buffer
288
		mov ebx,text_buffer
288
		mov byte[ebx],0
289
		mov byte[ebx],0
289
		stdcall str_cat,ebx,capt_point
290
		stdcall str_cat,ebx,capt_point
290
		stdcall str_cat_value,ebx,[index]
291
		stdcall str_cat_value,ebx,[index]
291
		stdcall str_cat,ebx,capt_beg_db
292
		stdcall str_cat,ebx,capt_beg_db
292
		stdcall str_len,ebx
293
		stdcall str_len,ebx
293
		add ebx,eax
294
		add ebx,eax
294
		
295
		
295
		add esi,dword[tex_help_f1]
296
		add esi,dword[tex_help_f1]
296
		stdcall code_string,esi,ebx ;êîäèðóåì ñòðîêó
297
		stdcall code_string,esi,ebx ;êîäèðóåì ñòðîêó
297
		stdcall str_cat,ebx,capt_end_word_f1
298
		stdcall str_cat,ebx,capt_end_word_f1
298
 
299
 
299
		mov ebx,text_buffer
300
		mov ebx,text_buffer
300
		stdcall str_len,ebx
301
		stdcall str_len,ebx
301
		stdcall [ted_text_add], tedit0,ebx,eax,ted_opt_ed_move_cursor
302
		stdcall [ted_text_add], tedit0,ebx,eax,ted_opt_ed_move_cursor
302
	@@:
303
	@@:
303
	popad
304
	popad
304
	ret
305
	ret
305
endp
306
endp
306
 
307
 
307
align 4
308
align 4
308
proc code_string, text:dword, out_text:dword
309
proc code_string, text:dword, out_text:dword
309
	pushad
310
	pushad
310
	mov esi,dword[text]
311
	mov esi,dword[text]
311
	stdcall str_len,esi
312
	stdcall str_len,esi
312
	mov ecx,eax
313
	mov ecx,eax
313
	mov edi,dword[out_text]
314
	mov edi,dword[out_text]
314
 
315
 
315
	.copy:
316
	.copy:
316
		mov al,byte[esi]
317
		mov al,byte[esi]
317
		inc esi
318
		inc esi
318
		cmp al,9
319
		cmp al,9
319
		je @f
320
		je @f
320
		cmp al,13
321
		cmp al,13
321
		je @f
322
		je @f
322
		cmp al,39
323
		cmp al,39
323
		je @f
324
		je @f
324
			mov byte[edi],al
325
			mov byte[edi],al
325
			inc edi
326
			inc edi
326
			loop .copy
327
			loop .copy
327
			jmp .end_copy
328
			jmp .end_copy
328
		@@:
329
		@@:
329
			mov byte[edi],39
330
			mov byte[edi],39
330
			mov byte[edi+1],','
331
			mov byte[edi+1],','
331
			add edi,2
332
			add edi,2
332
			and eax,0xff
333
			and eax,0xff
333
			mov dword[edi],0
334
			mov dword[edi],0
334
			call tl_convert_to_str
335
			call tl_convert_to_str
335
			stdcall str_len,edi
336
			stdcall str_len,edi
336
			add edi,eax
337
			add edi,eax
337
			mov byte[edi],','
338
			mov byte[edi],','
338
			mov byte[edi+1],39
339
			mov byte[edi+1],39
339
			add edi,2
340
			add edi,2
340
	loop .copy
341
	loop .copy
341
	.end_copy:
342
	.end_copy:
342
	mov byte[edi],0
343
	mov byte[edi],0
343
	popad
344
	popad
344
	ret
345
	ret
345
endp
346
endp
346
 
347
 
347
align 4
348
align 4
348
proc mem_clear, mem:dword, len:dword
349
proc mem_clear, mem:dword, len:dword
349
	push eax ecx edi
350
	push eax ecx edi
350
	cld
351
	cld
351
	xor al,al
352
	xor al,al
352
	mov edi, dword[mem]
353
	mov edi, dword[mem]
353
	mov ecx, dword[len]
354
	mov ecx, dword[len]
354
	repne stosb
355
	repne stosb
355
	pop edi ecx eax
356
	pop edi ecx eax
356
	ret
357
	ret
357
endp
358
endp
358
 
359
 
359
align 4
360
align 4
360
proc str_cat, str1:dword, str2:dword
361
proc str_cat, str1:dword, str2:dword
361
	push eax ecx edi esi
362
	push eax ecx edi esi
362
	mov esi,dword[str2]
363
	mov esi,dword[str2]
363
	stdcall str_len,esi
364
	stdcall str_len,esi
364
	mov ecx,eax
365
	mov ecx,eax
365
	inc ecx
366
	inc ecx
366
	mov edi,dword[str1]
367
	mov edi,dword[str1]
367
	stdcall str_len,edi
368
	stdcall str_len,edi
368
	add edi,eax
369
	add edi,eax
369
	cld
370
	cld
370
	repne movsb
371
	repne movsb
371
	pop esi edi ecx eax
372
	pop esi edi ecx eax
372
	ret
373
	ret
373
endp
374
endp
374
 
375
 
375
align 4
376
align 4
376
proc str_cat_value, str1:dword, value:dword
377
proc str_cat_value, str1:dword, value:dword
377
	pushad
378
	pushad
378
	mov edi,[str1]
379
	mov edi,[str1]
379
	stdcall str_len,edi
380
	stdcall str_len,edi
380
	add edi,eax
381
	add edi,eax
381
	mov eax,[value]
382
	mov eax,[value]
382
	call tl_convert_to_str
383
	call tl_convert_to_str
383
	popad
384
	popad
384
	ret
385
	ret
385
endp
386
endp
386
 
387
 
387
;output:
388
;output:
388
; eax = strlen
389
; eax = strlen
389
align 4
390
align 4
390
proc str_len, str1:dword
391
proc str_len, str1:dword
391
	mov eax,[str1]
392
	mov eax,[str1]
392
	@@:
393
	@@:
393
		cmp byte[eax],0
394
		cmp byte[eax],0
394
		je @f
395
		je @f
395
		inc eax
396
		inc eax
396
		jmp @b
397
		jmp @b
397
	@@:
398
	@@:
398
	sub eax,[str1]
399
	sub eax,[str1]
399
	ret
400
	ret
400
endp
401
endp
401
 
402
 
402
;input:
403
;input:
403
; eax = value
404
; eax = value
404
; edi = string buffer
405
; edi = string buffer
405
align 4
406
align 4
406
tl_convert_to_str:
407
tl_convert_to_str:
407
	pushad
408
	pushad
408
	stdcall mem_clear,edi,12
409
	stdcall mem_clear,edi,12
409
	call .str
410
	call .str
410
	popad
411
	popad
411
	ret
412
	ret
412
 
413
 
413
align 4
414
align 4
414
.str:
415
.str:
415
	mov ecx,0x0a ;çàäàåòñÿ ñèñòåìà ñ÷èñëåíèÿ èçìåíÿþòñÿ ðåãèñòðû ebx,eax,ecx,edx âõîäíûå ïàðàìåòðû eax - ÷èñëî
416
	mov ecx,0x0a ;çàäàåòñÿ ñèñòåìà ñ÷èñëåíèÿ èçìåíÿþòñÿ ðåãèñòðû ebx,eax,ecx,edx âõîäíûå ïàðàìåòðû eax - ÷èñëî
416
		;ïðåðåâîä ÷èñëà â ASCII ñòðîêó âõîäíûå äàííûå ecx=ñèñòåìà ñ÷èñëåíÿ edi àäðåñ êóäà çàïèñûâàòü, áóäåì ñòðîêó, ïðè÷åì êîíåö ïåðåìåííîé 
417
		;ïðåðåâîä ÷èñëà â ASCII ñòðîêó âõîäíûå äàííûå ecx=ñèñòåìà ñ÷èñëåíÿ edi àäðåñ êóäà çàïèñûâàòü, áóäåì ñòðîêó, ïðè÷åì êîíåö ïåðåìåííîé 
417
	cmp eax,ecx  ;ñðàâíèòü åñëè â eax ìåíüøå ÷åì â ecx òî ïåðåéòè íà @@-1 ò.å. íà pop eax
418
	cmp eax,ecx  ;ñðàâíèòü åñëè â eax ìåíüøå ÷åì â ecx òî ïåðåéòè íà @@-1 ò.å. íà pop eax
418
	jb @f
419
	jb @f
419
		xor edx,edx ;î÷èñòèòü edx
420
		xor edx,edx ;î÷èñòèòü edx
420
		div ecx     ;ðàçäåëèòü - îñòàòîê â edx
421
		div ecx     ;ðàçäåëèòü - îñòàòîê â edx
421
		push edx    ;ïîëîæèòü â ñòåê
422
		push edx    ;ïîëîæèòü â ñòåê
422
		;dec edi    ;ñìåùåíèå íåîáõîäèìîå äëÿ çàïèñè ñ êîíöà ñòðîêè
423
		;dec edi    ;ñìåùåíèå íåîáõîäèìîå äëÿ çàïèñè ñ êîíöà ñòðîêè
423
		call .str   ;ïåðåéòè íà ñàìó ñåáÿ ò.å. âûçâàòü ñàìó ñåáÿ è òàê äî òîãî ìîìåíòà ïîêà â eax íå ñòàíåò ìåíüøå ÷åì â ecx
424
		call .str   ;ïåðåéòè íà ñàìó ñåáÿ ò.å. âûçâàòü ñàìó ñåáÿ è òàê äî òîãî ìîìåíòà ïîêà â eax íå ñòàíåò ìåíüøå ÷åì â ecx
424
		pop eax
425
		pop eax
425
	@@: ;cmp al,10 ;ïðîâåðèòü íå ìåíüøå ëè çíà÷åíèå â al ÷åì 10 (äëÿ ñèñòåìû ñ÷èñëåíÿ 10 äàííàÿ êîìàíäà - ëèøíàÿ))
426
	@@: ;cmp al,10 ;ïðîâåðèòü íå ìåíüøå ëè çíà÷åíèå â al ÷åì 10 (äëÿ ñèñòåìû ñ÷èñëåíÿ 10 äàííàÿ êîìàíäà - ëèøíàÿ))
426
	or al,0x30  ;äàííàÿ êîìàíäà êîðî÷å  ÷åì äâå âûøå 
427
	or al,0x30  ;äàííàÿ êîìàíäà êîðî÷å  ÷åì äâå âûøå 
427
	stosb	    ;çàïèñàòü ýëåìåíò èç ðåãèñòðà al â ÿ÷åêó ïàìÿòè es:edi
428
	stosb	    ;çàïèñàòü ýëåìåíò èç ðåãèñòðà al â ÿ÷åêó ïàìÿòè es:edi
428
	ret
429
	ret