kolibrios/programs/develop/str_double/trunk/str_double.asm

319 lines
8.0 KiB
NASM
Raw Normal View History

; <20>ணࠬ<E0AEA3><E0A0AC> <20><><EFBFBD> <20><EFBFBD><EFBFBD><E0A0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><20><> <20><><EFBFBD>
; <20> <20><><EFBFBD> float, double, <20><><E2A0AA> <20><> 10 <20><><EFBFBD> 16 <20><><EFBFBD><E7ADAE>
; <20><> float.
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><EFBFBD><E1ADAE> hex2dec2bin <20> <20><EFBFBD><20><><><E4A0A9> list2_05.inc
; (<28><><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><E3ABA0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECA5A2> 24.05.2002),
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ChE <20><><EFBFBD><E0A5A4><EFBFBD><EFBFBD> <20> 16 <20><> 32 <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><E1A5AC><EFBFBD><EFBFBD> fasm.
; <20>ணࠬ<E0AEA3><E0A0AC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><E2A0AA> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
; 1) <20><><20> <20><><EFBFBD><E0AEAA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><E0A5A2><EFBFBD><EFBFBD> <20> 4 <20><><EFBFBD><EFBFBD><EFBFBD> (float) <20> <20><><EFBFBD><E8A8AD><EFBFBD> <20><><EFBFBD>
; 2) <20><><20> <20><><EFBFBD><E0AEAA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><E0A5A2><EFBFBD><EFBFBD> <20> 8 <20><><EFBFBD><EFBFBD> (double) <20> <20><><EFBFBD><E8A8AD><EFBFBD> <20><><EFBFBD>
; 3) <20><><20> <20><><EFBFBD><E8A8AD><EFBFBD> <20><><EFBFBD><EFBFBD> (float) <20><><EFBFBD><E0A5A2><EFBFBD><EFBFBD> <20> <20><><EFBFBD><E0AEAA><EFBFBD><EFBFBD> <20><><EFBFBD> (5 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><20><><EFBFBD><EFBFBD>⮩)
use32
org 0
db 'MENUET01'
dd 1,start,i_end,e_end,e_end,0,sys_path
include '../../../proc32.inc'
include '../../../macros.inc'
include '../../../KOSfuncs.inc'
include '../../../load_lib.mac'
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
include '../../../develop/info3ds/info_fun_float.inc'
include 'lang.inc'
@use_library
align 4
start:
load_libraries l_libs_start,l_libs_end
;<3B><EFBFBD><20><><>쪮 㤠筮 <20><><EFBFBD><EFBFBD><E3A7A8><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov ebp,lib_0
cmp dword[ebp+ll_struc_size-4],0
jz @f
mcall SF_TERMINATE_PROCESS
@@:
mcall SF_SET_EVENTS_MASK,0xC0000027
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS, sys_colors, sizeof.system_colors
edit_boxes_set_sys_color edit1,editboxes_end,sys_colors
option_boxes_set_sys_color sys_colors,Option_boxes1
align 4
red:
call draw_window
align 4
still:
mcall SF_WAIT_EVENT
cmp eax,1 ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1AEA2><EFBFBD> <20><><EFBFBD><EFBFBD> ?
je red ; <20><20><> - <20><> <20><><EFBFBD><EFBFBD><EFBFBD> red
cmp eax,2 ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ?
je key ; <20><20><> - <20><> key
cmp eax,3 ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ?
je button ; <20><20><> - <20><> button
cmp eax,6
je mouse
jmp still ; <20><20><><EFBFBD><>⨥ - <20> <20><><EFBFBD><><E6A8AA>
align 4
key: ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mcall SF_GET_KEY
;cmp ah,13
stdcall [edit_box_key], edit1
jmp still ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><><E6A8AA>
align 4
button:
mcall SF_GET_BUTTON
cmp ah, 1 ; <20><20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>஬ 1,
jne @f
mcall SF_TERMINATE_PROCESS
@@:
cmp ah, 5
jne @f
cmp dword[option_group1],opt3
jne .opt_3_end
stdcall conv_str_to_int,[edit1.text]
mov dword[Data_Double],eax
finit
fld dword[Data_Double]
fstp qword[Data_Double]
; Data_Double - <20><EFBFBD>ࠧ㥬<E0A0A7><E3A5AC> <20><>
mov word[NumberSymbolsAD],8 ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><20><><20><><EFBFBD><EFBFBD>⮩ (1-17)
call DoubleFloat_to_String
call String_crop_0
mov dword[Data_Double],eax ;<3B><><EFBFBD><EFBFBD><EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E7A5AD> <20> <20><><EFBFBD><E0ACA0> 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 ;<3B><20><><EFBFBD>࠭ float, <20><> <20><EFBFBD>ࠧ㥬 <20><><><E0A0AD> <20><><EFBFBD><EFBFBD><EFBFBD><E7A5AD><EFBFBD><EFBFBD> double
finit
fld qword[Data_Double] ;<3B><><EFBFBD> <20><> double
fstp dword[Data_Double] ;<3B> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> float
.opt_all_end:
jmp red
@@:
jmp still
align 4
mouse:
stdcall [edit_box_mouse], edit1
stdcall [option_box_mouse], Option_boxes1
jmp still
;------------------------------------------------
align 4
draw_window:
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS, sys_colors, sizeof.system_colors
mcall SF_REDRAW,SSF_BEGIN_DRAW
mov edx, 0x14000000
or edx, [sys_colors.work]
mcall SF_CREATE_WINDOW, (200 shl 16)+300, (200 shl 16)+175, ,,title
mcall SF_DEFINE_BUTTON, ((300-53) shl 16)+38, (145 shl 16)+15, 5, [sys_colors.work_button] ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ok
mov ecx, 0x80000000
or ecx, [sys_colors.work_text]
mcall SF_DRAW_TEXT, (15 shl 16) +30,, binstr,
mcall , (15 shl 16) +58,, decstr,
mcall , ((240-56*3) shl 16) +58,, Data_String,
mcall , (15 shl 16) +72,, hexstr,
mcall , (15 shl 16)+150,, numstr,
mov ecx, 0x80000000
or ecx, [sys_colors.work_button_text]
mcall , ((300-42) shl 16)+149, , Okstr,3
cmp dword[option_group1],opt1
je @f ;<3B><20><><EFBFBD>࠭ float, <20><> <20><><EFBFBD><EFBFBD>訥 4 <20><><EFBFBD><EFBFBD><EFBFBD> (<28><> double) <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
cmp dword[option_group1],opt3
je @f ;<3B><20><><EFBFBD>࠭ float, <20><> <20><><EFBFBD><EFBFBD>訥 4 <20><><EFBFBD><EFBFBD><EFBFBD> (<28><> double) <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
mov ecx, dword[Data_Double+4]
mcall SF_DRAW_NUMBER, (8 shl 16)+256,,(185 shl 16)+72,[sys_colors.work_text] ; 16-<2D><><EFBFBD>
mov ecx, dword[Data_Double+4]
mcall ,(8 shl 16)+512,,(240 shl 16)+30, ; 2-<2D><><EFBFBD>
ror ecx, 8
mcall ,,,((240-56) shl 16)+30,
ror ecx, 8
mcall ,,,((240-56*2) shl 16)+30,
ror ecx, 8
mcall ,,,((240-56*3) shl 16)+30,
ror ecx, 8
@@:
mov ecx,dword[Data_Double]
mcall SF_DRAW_NUMBER, (8 shl 16)+256,,(240 shl 16)+72,[sys_colors.work_text] ; 16-<2D><><EFBFBD>
mov ecx,dword[Data_Double]
mcall , (8 shl 16)+512,,(240 shl 16)+44, ; 2-<2D><><EFBFBD>
ror ecx, 8
mcall ,,,((240-56) shl 16)+44,
ror ecx, 8
mcall ,,,((240-56*2) shl 16)+44,
ror ecx, 8
mcall ,,,((240-56*3) shl 16)+44,
ror ecx, 8
mcall SF_DRAW_LINE, (15 shl 16)+300-15, (137 shl 16)+137, [sys_colors.work_graph]
stdcall [edit_box_draw], edit1
stdcall [option_box_draw], Option_boxes1
mcall SF_REDRAW,SSF_END_DRAW
ret
string1 db 32 dup (0)
string1_end:
;input:
; buf - 㪠<><E3AAA0><EFBFBD> <20><> <20><><EFBFBD>, <20><><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> 10 <20><><EFBFBD> 16 <20><><EFBFBD> <20><><EFBFBD><EFBFBD>
;output:
; eax - <20><>
align 4
proc conv_str_to_int uses ebx ecx esi, buf:dword
xor eax,eax
xor ebx,ebx
mov esi,[buf]
;<3B><><EFBFBD><E0A5A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A5AB><EFBFBD><EFBFBD> <20><>
xor ecx,ecx
inc ecx
cmp byte[esi],'-'
jne @f
dec ecx
inc esi
@@:
cmp word[esi],'0x'
je .load_digit_16
.load_digit_10: ;<3B><><EFBFBD><EFBFBD><EFBFBD><EBA2A0><EFBFBD> 10-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
mov bl,byte[esi]
cmp bl,'0'
jl @f
cmp bl,'9'
jg @f
sub bl,'0'
imul eax,10
add eax,ebx
inc esi
jmp .load_digit_10
jmp @f
.load_digit_16: ;<3B><><EFBFBD><EFBFBD><EFBFBD><EBA2A0><EFBFBD> 16-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
add esi,2
.cycle_16:
mov bl,byte[esi]
cmp bl,'0'
jl @f
cmp bl,'f'
jg @f
cmp bl,'9'
jle .us1
cmp bl,'A'
jl @f ;<3B><><EFBFBD><E1A5A8><EFBFBD><EFBFBD><><E1A8AC><EFBFBD><EFBFBD> >'9' <20> <'A'
.us1: ;<3B><><EFBFBD><EFBFBD><E2A0A2><EFBFBD> <20><EFBFBD><E1ABAE><EFBFBD>
cmp bl,'F'
jle .us2
cmp bl,'a'
jl @f ;<3B><><EFBFBD><E1A5A8><EFBFBD><EFBFBD><><E1A8AC><EFBFBD><EFBFBD> >'F' <20> <'a'
sub bl,32 ;<3B><><EFBFBD><E0A5A2><EFBFBD><EFBFBD><><E1A8AC><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><><E0A5A3><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E9A5AD> <20><> <20><><EFBFBD><E1ABA5><20><><EFBFBD>
.us2: ;<3B><><EFBFBD><EFBFBD><E2A0A2><EFBFBD> <20><EFBFBD><E1ABAE><EFBFBD>
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 ;<3B><20><><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥫쭮<E2A5AB>
jne @f
sub ecx,eax
mov eax,ecx
@@:
ret
endp
;-------------------------------------------------
title db 'string to double 03.01.21',0
hexstr db 'hex:',0
decstr db 'dec:',0
binstr db 'bin:',0
2024-06-03 01:34:02 +02:00
if lang eq ru_RU
numstr db '<27><>᫮:',0
Okstr db '<27><><EFBFBD><EFBFBD>',0
else
numstr db 'Number:',0
Okstr db 'Ok',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: ;⥪<><E2A5AA> <20><><EFBFBD><><E0A0A4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.1 db 'str(dec) -> float'
.2 db 'str(dec) -> double'
.3 db 'float(dec,hex) -> str'
;㪠<><E3AAA0><EFBFBD> <20><><EFBFBD> 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
l_libs_start:
lib_0 l_libs lib_name_0, library_path, system_dir_0,import_box_lib
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_draw',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
align 16
sys_path rb 4096
library_path rb 4096
rb 0x400 ;stack
e_end: ; <20><><20><><EFBFBD><EFBFBD><EFBFBD> <20>ணࠬ<E0AEA3><E0A0AC>