flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > unlimited floats, no mul, no div, small size, etc happy |
Author |
|
idle 08 Jun 2011, 22:30
Tomasz, your birthday soon :)
Code: ;enu: get binary representation of decimal fraction ; decimal fraction stored in binary-coded-decimal format ; as there are no limits to input, byte -1 should precede it: db -1, 6,2,5,.. ; that example implies you want to get 0.625 in binary ; it can all be used in unlimited floats representation ; it can also be used to mul bcd's by powers of two ; ask your quests to edemko@rambler.ru please ; ; on init do smth like: ; decimal_fraction db -1, 6,2,5,0,0,0 ; .: ; ... ; mov edi,decimal_fraction.-1 ; call frac ; ... ; ; on exit: ; edx:ebp:ebx - normalized fraction ; ecx - steps to get real fraction(denormalized) ; edi - rank0 position of fraction ; esi - byte -1 position +1 ; flags.df - 1 ; flags - ? ;rus: TODO frac: sub edx,edx ;assume empty fraction sub ebp,ebp sub ebx,ebx std ;skip trailing zeros sub eax,eax lea ecx,[eax-1] repe scasb sub ecx,ecx ;total number of multiplications we'll do cmp al,-1 je .ret ;fraction = .0 inc edi ;remember decimal rank0 location .until_normalized: mov esi,edi mov ah,0 ;no carries initially .load: lodsb ;get current rank digit cmp al,10 jb .mul ;common digit inc ecx shr ah,1 rcl ebx,1 rcl ebp,1 rcl edx,1 test edx,edx jns .until_normalized sub ecx,32*3 ;number of preceding zeros we've removed = denormalization steps count .ret: ret 0 .mul: shr ah,1 ;include carry from previous rank operation adc al,al ;digit*2 + carry cmp al,10 jb .store ;else we correct result into a bcd(lazy) form add al,256-10 mov ah,1 .store: mov [esi+1],al jmp .load edit: + russian intro here: http://fasmme.googlecode.com/files/frac.inc |
|||
08 Jun 2011, 22:30 |
|
idle 11 Jun 2011, 12:26
|
|||
11 Jun 2011, 12:26 |
|
idle 30 Jun 2011, 11:54
Code: ;cmp al,10 ;jb .store ;else we correct result into a bcd(lazy) form ;add al,256-10 ;mov ah,1 ;= adc ah,ah aaa ;2011_06_30 move to Main if preferred, thank you for attention :) LAST EDIT HERE: now here: http://board.flatassembler.net/topic.php?t=12980 |
|||
30 Jun 2011, 11:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.