Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;-----------------------------------------------------------------------------;
  2. ;                           =[        INIT        ]=                          ;
  3. ;-----------------------------------------------------------------------------;
  4. ;; START:
  5.     call    utils_init
  6.  
  7. ;-----------------------------------------------------------------------------;
  8. ;                           =[        USE        ]=                           ;
  9. ;-----------------------------------------------------------------------------;
  10.     push    fvalue                        ; value dt (XXXXX.XXXXX)
  11.     push    fstring                       ; ASCIIZ string (rb 64)
  12.     call    [_ftoa]                       ; convert
  13.  
  14.     push    fstring                       ; ASCIIZ string ('XXXX.XXXXXX',0)
  15.     push    fvalue                        ; value dt (?)
  16.     call    [_atof]                       ; EAX: 0 - error, 1 - convert
  17.  
  18.     call    [_random]                     ; EAX: random digit [0...99999]
  19.  
  20. ;-----------------------------------------------------------------------------;
  21. ;                           =[        LOAD        ]=                          ;
  22. ;-----------------------------------------------------------------------------;
  23. utils_init:
  24.     mov     eax, 68                       ; load DLL
  25.     mov     ebx, 19                       ;
  26.     mov     ecx, utils_lib
  27.     int     0x40
  28.     test    eax, eax
  29.     jz      utils_exit
  30.  
  31.     mov     edx, eax                      ; initialize import
  32.     mov     esi, utils_import             ; import list
  33. utils_loop:
  34.     lodsd
  35.     test    eax, eax
  36.     jz      utils_done
  37.     push    edx
  38. utils_find:
  39.     mov     ebx, [edx]
  40.     test    ebx, ebx
  41.     jz      utils_exit                     ;import_not_found
  42.     push    eax
  43. @@:
  44.     mov     cl, [eax]
  45.     cmp     cl, [ebx]
  46.     jnz     utils_next
  47.     test    cl, cl
  48.     jz      utils_found
  49.     inc     eax
  50.     inc     ebx
  51.     jmp     @b
  52. utils_next:
  53.     pop     eax
  54.     add     edx, 8
  55.     jmp     utils_find
  56. utils_found:
  57.     pop     eax
  58.     mov     eax, [edx+4]
  59.     mov     [esi-4], eax
  60.     pop     edx
  61.     jmp     utils_loop
  62. utils_done:
  63.     ret
  64. utils_exit:
  65.     mov    eax, -1
  66.     int    0x40
  67.  
  68. ;-----------------------------------------------------------------------------;
  69. ;                           =[        DATA        ]=                          ;
  70. ;-----------------------------------------------------------------------------;
  71.     fvalue      dt -502556.267e600 ; dt ?
  72.     fstring     db rb 100          ; '-15.246789',0
  73.  
  74.     utils_lib   db  '/sys/lib/utils.obj',0    ; path
  75.  
  76.   align 4
  77.   utils_import:
  78.     _ftoa       dd  ftoa
  79.     _atof       dd  atof
  80.     _random     dd  random
  81.                 dd  0
  82.  
  83.     ftoa        db  'ftoa',0
  84.     atof        db  'atof',0
  85.     random      db  'random',0
  86. ;-----------------------------------------------------------------------------;
  87.  
  88.  
  89.