From 48e49905d09bb5f15656ac162524d41f522c556b Mon Sep 17 00:00:00 2001 From: IgorA Date: Wed, 7 Sep 2011 15:58:22 +0000 Subject: [PATCH] add new programm 'str_double' git-svn-id: svn://kolibrios.org@2162 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../develop/str_double/trunk/build_en.bat | 5 + .../develop/str_double/trunk/build_ru.bat | 5 + programs/develop/str_double/trunk/readme.htm | 57 ++ .../develop/str_double/trunk/str_do_opt3.png | Bin 0 -> 4800 bytes .../develop/str_double/trunk/str_double.asm | 612 ++++++++++++++++++ 5 files changed, 679 insertions(+) create mode 100644 programs/develop/str_double/trunk/build_en.bat create mode 100644 programs/develop/str_double/trunk/build_ru.bat create mode 100644 programs/develop/str_double/trunk/readme.htm create mode 100644 programs/develop/str_double/trunk/str_do_opt3.png create mode 100644 programs/develop/str_double/trunk/str_double.asm diff --git a/programs/develop/str_double/trunk/build_en.bat b/programs/develop/str_double/trunk/build_en.bat new file mode 100644 index 0000000000..0cef4124d2 --- /dev/null +++ b/programs/develop/str_double/trunk/build_en.bat @@ -0,0 +1,5 @@ +@erase lang.inc +@echo lang fix en >lang.inc +@fasm str_double.asm str_double +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/develop/str_double/trunk/build_ru.bat b/programs/develop/str_double/trunk/build_ru.bat new file mode 100644 index 0000000000..32be3bf8ea --- /dev/null +++ b/programs/develop/str_double/trunk/build_ru.bat @@ -0,0 +1,5 @@ +@erase lang.inc +@echo lang fix ru >lang.inc +@fasm str_double.asm str_double +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/develop/str_double/trunk/readme.htm b/programs/develop/str_double/trunk/readme.htm new file mode 100644 index 0000000000..018b2d189b --- /dev/null +++ b/programs/develop/str_double/trunk/readme.htm @@ -0,0 +1,57 @@ + + +String to Double + + + + +

String to Double 07.09.2011

+

╧ЁюуЁрььр фы  яЁхюсЁрчютрэш  ўшёхы шч ёЄЁюъш т ЇюЁьрЄ float, double, р Єръцх шч 10 шыш 16 Ёшўэюую тю float.

+ +

╤фхырэр эр юёэютх яЁюуЁрьь√ hex2dec2bin ш яЁшьхЁют шч Їрщыр list2_05.inc (ртЄюЁ ╩єыръют ┬ырфшьшЁ ├хээрф№хтшў 24.05.2002), ъюЄюЁ√х ChE яхЁхфхыры ё 16 эр 32 сшЄр эр рёёхьсыхЁ fasm.

+

╧ЁюуЁрььр яючтюы хЄ Ёх°рЄ№ Єръшх чрфрўш:

+

1) ўшёыю т ёЄЁюъютюь тшфх яхЁхтхёЄш т 4 срщЄр (float) т ьр°шээ√щ тшф

+

2) ўшёыю т ёЄЁюъютюь тшфх яхЁхтхёЄш т 8 срщЄ (double) т ьр°шээ√щ тшф

+

3) ўшёыю т ьр°шээюь тшфх (float) яхЁхтхёЄш т ёЄЁюъют√щ тшф (5 чэръют яюёых чря Єющ).

+ +

╧ЁшьхЁ

+

╠√ чэрхь ўЄю хёЄ№ эхъюЄюЁюх ўшёыю float, ёюїЁрэхээюх т ьр°шээюь тшфх, эряЁшьхЁ 3fa00000. ╫Єю с√ єчэрЄ№ ъръ ¤Єю ўшёыю сєфхЄ ёьюЄЁхЄ№ё  т фхё Єшўэюь тшфх фхырхь Єръшх фхщёЄтш :

+

1) тъы■ўрхь юяЎш■ float(dec,hex) -> str, +2) ттюфшь ЄхъёЄ 0x3fa00000, +3) эрцшьрхь ┬тюф (т рэуы. тхЁёшш Ok).

+

┬ Ёхчєы№ЄрЄх єчэрхь ўЄю ¤Єю ўшёыю 1.25:

+ +

╨шё. 1. ╚ёяюы№чютрэшх юяЎшш float(dec,hex) -> str

+ + \ No newline at end of file diff --git a/programs/develop/str_double/trunk/str_do_opt3.png b/programs/develop/str_double/trunk/str_do_opt3.png new file mode 100644 index 0000000000000000000000000000000000000000..3d4840ba3425997f004fe60c2e7844b90eddefb8 GIT binary patch literal 4800 zcmai2c{tSV*B@g^gApM#_Gl9^=O1+fH?IYI^lD_{-{gctOaarV%cx6om#uwXK;^N-eu+rJj7?Y{I%i`HG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4*0-~6n;e*PA^klCq)Iu#l{+hCA3yckE;lg`)d)c?K>-pp)!b=qrbEb zId&lz84}PGSMXX!P0W(g)Oe0{OJaP!{yU%PXYXiJ_Y>_Bd^W'9' и <'A' + .us1: ;составное условие + cmp bl,'F' + jle .us2 + cmp bl,'a' + jl @f ;отсеиваем символы >'F' и <'a' + sub bl,32 ;переводим символы в верхний регистр, для упрощения их последущей обработки + .us2: ;составное условие + sub bl,'0' + cmp bl,9 + jle .cor1 + sub bl,7 ;convert 'A' to '10' + .cor1: + shl eax,4 + add eax,ebx + inc esi + jmp .cycle_16 + @@: + cmp ecx,0 ;если число отрицательное + jne @f + sub ecx,eax + mov eax,ecx + @@: + pop esi ecx ebx + ret +endp + + + +;--------------------------------------------------------------------- +align 4 +button: + mcall 17 ; 17 - получить идентификатор нажатой кнопки + cmp ah, 1 ; если НЕ нажата кнопка с номером 1, + jne @f + mcall -1 + @@: + cmp ah, 5 + jne @f + cmp dword[option_group1],opt3 + jne .opt_3_end + stdcall conv_str_to_int,dword[edit1.text] + mov dword[Data_Double],eax + finit + fld dword[Data_Double] + fstp qword[Data_Double] + + ; Data_Double - преобразуемое число + ; NumberSymbolsAD - количество знаков после запятой (0-17) + call DoubleFloat_to_String + mov dword[Data_Double],eax ;восстанавливаем значение в формате float + jmp .opt_all_end + .opt_3_end: + + mov esi,string1 + mov edi,Data_String + cld + mov ecx,32 + rep movsb + + call String_to_DoubleFloat + cmp dword[option_group1],opt1 + jne .opt_all_end ;если выбран float, то преобразуем из ранее полученного double + finit + fld qword[Data_Double] ;читаем из double + fstp dword[Data_Double] ;а возвращаем во float + .opt_all_end: + jmp red + @@: + jmp still + +mouse: + stdcall [edit_box_mouse], edit1 + stdcall [option_box_mouse], Option_boxes1 + jmp still + +;------------------------------------------------ +align 4 +draw_window: + mcall 48, 3, sys_colors, sizeof.system_colors + + mcall 12, 1 + mov edx, 0x14000000 + or edx, [sys_colors.work] + mcall 0, 200*65536+300, 200*65536+175, ,,title + + mcall 8, (300-53)*65536+38,145*65536+ 15, 5,[sys_colors.work_button] ; кнопка Ok + + mov ecx, 0x80000000 + or ecx, [sys_colors.work_text] + mcall 4, 15*65536 +30,, binstr, + mcall , 15*65536 +58,, decstr, + mcall , (240-56*3)*65536 +58,, Data_String, + mcall , 15*65536 +72,, hexstr, + mcall , 15*65536+150,, numstr, + + mov ecx, 0x80000000 + or ecx, [sys_colors.work_button_text] + mcall , (300-42)*65536+149, , Okstr,3 + + cmp dword[option_group1],opt1 + je @f ;если выбран float, то старшие 4 байта (из double) не печатаем + cmp dword[option_group1],opt3 + je @f ;если выбран float, то старшие 4 байта (из double) не печатаем + mov ecx, dword[Data_Double+4] + mcall 47, 8*65536+256,,185*65536+72,[sys_colors.work_text] ; 16-ная + + mov ecx, dword[Data_Double+4] + mcall ,8*65536+512,,240*65536+30, ; 2-ная + ror ecx, 8 + mcall ,,,(240-56)*65536+30, + ror ecx, 8 + mcall ,,,(240-56*2)*65536+30, + ror ecx, 8 + mcall ,,,(240-56*3)*65536+30, + ror ecx, 8 + @@: + + mov ecx,dword[Data_Double] + mcall 47, 8*65536+256,,240*65536+72,[sys_colors.work_text] ; 16-ная + + mov ecx,dword[Data_Double] + mcall , 8*65536+512,,240*65536+44, ; 2-ная + ror ecx, 8 + mcall ,,,(240-56)*65536+44, + ror ecx, 8 + mcall ,,,(240-56*2)*65536+44, + ror ecx, 8 + mcall ,,,(240-56*3)*65536+44, + ror ecx, 8 + + mcall 38, 15*65536+300-15, 137*65536+137, [sys_colors.work_graph] + stdcall [edit_box_draw], edit1 + stdcall [option_box_draw], Option_boxes1 + mcall 12, 2 ; функция 12: сообщить ОС об отрисовке окна + +ret + + +;------------------------------------------------- +title db 'string to double 07.09.11',0 +hexstr db 'hex:',0 +decstr db 'dec:',0 +binstr db 'bin:',0 + +if lang eq ru + numstr db 'Число:',0 + Okstr db 'Ввод',0 + head_f_i: + head_f_l db 'Системная ошибка',0 +else + numstr db 'Number:',0 + Okstr db 'Ok',0 + head_f_i: + head_f_l db 'System error',0 +end if + +mouse_dd dd 0 +edit1 edit_box 182, 59, 146, 0xffffff, 0xff, 0x80ff, 0, 0x8000, (string1_end-string1), string1, mouse_dd, 0 +editboxes_end: + +;option_boxes +opt1 option_box option_group1, 15, 90, 8, 12, 0xffffff, 0x80ff, 0, op_text.1, 17 +opt2 option_box option_group1, 15, 106, 8, 12, 0xffffff, 0x80ff, 0, op_text.2, 18 +opt3 option_box option_group1, 15, 122, 8, 12, 0xffffff, 0x80ff, 0, op_text.3, 21 + +op_text: ;текст для радио кнопок + .1 db 'str(dec) -> float' + .2 db 'str(dec) -> double' + .3 db 'float(dec,hex) -> str' +;указатели для option_box +option_group1 dd opt1 +Option_boxes1 dd opt1, opt2, opt3, 0 + +system_dir_0 db '/sys/lib/' +lib_name_0 db 'box_lib.obj',0 +err_msg_found_lib_0 db 'Не найдена библиотека ',39,'box_lib.obj',39,0 +err_msg_import_0 db 'Ошибка при импорте библиотеки ',39,'box_lib',39,0 + +l_libs_start: + lib_0 l_libs lib_name_0, sys_path, library_path, system_dir_0,\ + err_msg_found_lib_0,head_f_l,import_box_lib,err_msg_import_0,head_f_i +l_libs_end: + +align 4 +import_box_lib: + ;dd sz_init1 + edit_box_draw dd sz_edit_box_draw + edit_box_key dd sz_edit_box_key + edit_box_mouse dd sz_edit_box_mouse + ;edit_box_set_text dd sz_edit_box_set_text + option_box_draw dd aOption_box_draw + option_box_mouse dd aOption_box_mouse + ;version_op dd aVersion_op +dd 0,0 + ;sz_init1 db 'lib_init',0 + sz_edit_box_draw db 'edit_box',0 + sz_edit_box_key db 'edit_box_key',0 + sz_edit_box_mouse db 'edit_box_mouse',0 + ;sz_edit_box_set_text db 'edit_box_set_text',0 + aOption_box_draw db 'option_box_draw',0 + aOption_box_mouse db 'option_box_mouse',0 + ;aVersion_op db 'version_op',0 + +i_end: + sys_colors system_colors + rb 0x400 ;stack + sys_path rb 4096 + library_path rb 4096 +e_end: ; метка конца программы