kolibrios-fun/programs/develop/libraries/utils/trunk/utils.asm
Akyltist 9b11245e08 Add COFF libraries "utils.obj" atof,ftoa,random
support for exponent, high accuracy, not normalized form of writing

git-svn-id: svn://kolibrios.org@4721 a494cfbc-eb01-0410-851d-a64ba20cac60
2014-03-31 05:57:30 +00:00

65 lines
2.7 KiB
NASM

;-----------------------------------------------------------------------------+
; Library "utils" (c) Sergei Steshin (Akyltist) |
;-----------------------------------------------------------------------------+
; Charset:DOS-866 Font:Courier New Size:9pt |
; compiler: FASM 1.69.31 |
; version: 0.1.0 |
; last update: 31/03/2014 |
; e-mail: dr.steshin@gmail.com |
; license: BSD |
;-----------------------------------------------------------------------------+
format MS COFF
public EXPORTS
section '.flat' code readable writable align 16
include '../../../../proc32.inc'
include '_ftoa.inc'
include '_atof.inc'
include '_rand.inc'
;-----------------------------------------------------------------------------+
; float to ascii string |
;-----------------------------------------------------------------------------+
ftoa: ;
mov ebx, dword [esp+4] ; out string
mov eax, dword [esp+8] ; in value
stdcall FloatToString,eax,ebx ;
ret 8 ;
;-----------------------------------------------------------------------------+
; ascii string to float |
;-----------------------------------------------------------------------------+
atof: ;
mov ebx, dword [esp+4] ; out <- value
mov eax, dword [esp+8] ; in -> string
stdcall string2float,eax,ebx ;
ret 8 ;
;-----------------------------------------------------------------------------+
; returns a random integer in the range [ 0...99999 ] |
;-----------------------------------------------------------------------------+
random: ;
call _random ; out <- eax random
ret ;
;=============================================================================;
align 16
EXPORTS:
dd szFtoa , ftoa
dd szAtof , atof
dd szRandom , random
dd 0 , 0
szFtoa db 'ftoa' ,0
szAtof db 'atof' ,0
szRandom db 'random' ,0
section '.data' data readable writable align 16