flat assembler
Message board for the users of flat assembler.
Index
> Main > how DIV works? Goto page Previous 1, 2 |
Author |
|
revolution 22 Feb 2010, 10:37
LSD = Least Significant Digit
The meaning of digit could be decimal or any other base you choose up to 0xFFFFFFFF (2^32-1) |
|||
22 Feb 2010, 10:37 |
|
Picnic 23 Feb 2010, 19:09
serfasm wrote: How can divide a dqword(128bit) by a dword? Another sample shows arbitrary precision division can be found on topic your thoughts on division... |
|||
23 Feb 2010, 19:09 |
|
revolution 24 Feb 2010, 13:32
serfasm: A dqword (16 byte) x dqword (16 byte) multiply would have a 32 byte result size. It requires 16 (4*4) cross multiplies. Do you want to try and code it?
Also, you can make the adder more efficient: Code: mov eax,[first+0] mov ebx,[first+4] mov ecx,[first+8] mov edx,[first+12] add eax,[second+0] adc ebx,[second+4] adc ecx,[second+8] adc edx,[second+12] mov [result+0],eax mov [result+4],ebx mov [result+8],ecx mov [result+12],edx Code: mov eax,[second+0] mov ebx,[second+4] mov ecx,[second+8] mov edx,[second+12] add [first+0],eax adc [first+4],ebx adc [first+8],ecx adc [first+12],edx |
|||
24 Feb 2010, 13:32 |
|
edemko 26 Feb 2010, 07:56
revolution i'll view through your proposal some later: optimizing is of my interest. Below is a dq2a generating more readable number placing a space 0x20 between every triple:
Code: ; [buf53bytes] = ascii dqword[value]. ; flags saved. proc dq2a; value:dword, signed?:dword, buf53bytes:dword xchg esi,[esp+4] xchg eax,[esp+8] xchg edi,[esp+12] push ebx ecx edx pushfd push dword[esi+12] push dword[esi+8] push dword[esi+4] push dword[esi] cmp al,0 mov al,'+' je .pos test byte[esp+15],10000000b jz .pos mov al,'-' stdcall negdq,esp .pos: cld stosb std mov ecx,39+12 ;2^128=10^x; x=log(10;2)*128~38 -> 39 chars + 12 spaces between every triple add edi,ecx mov al,ch stosb mov esi,esp mov bx,' ' shl 8 or 39+12-3 .get: cmp cl,bl jne .not_3rd sub bl,1+3 mov al,bh jmp .3rd .not_3rd: stdcall divdq,esi,10 lea eax,[edx+'0'] .3rd: stosb loop .get add esp,16 popfd pop edx ecx ebx mov esi,[esp+4] mov eax,[esp+8] mov edi,[esp+12] ret 12 endp |
|||
26 Feb 2010, 07:56 |
|
edemko 26 Feb 2010, 08:03
revolution wrote:
simd? revolution: Code: ; dqword[to] = dqword[to] + dqword[from]. ; flags destroyed. proc adddq; to:dword, from:dword xchg edi,[esp+4] call .revo xchg edi,[esp+8] add eax,[edi] adc ebx,[edi+4] adc ecx,[edi+8] adc edx,[edi+12] mov edi,[esp+8] call .revo mov edi,[esp+4] ret 8 .revo:xchg eax,[edi] xchg ebx,[edi+4] xchg ecx,[edi+8] xchg edx,[edi+12] ret 0 endp edit there is an unlimited_length_chain numbers algo a bit in russian, contact me whenever you need the translation or just use http://translate.google.com, ok:? file download link at wasm.ru: http://wasm.ru/forum/attachment.php?item=4023 source code: http://wasm.ru/forum/viewtopic.php?id=37619, post #9 good luck
|
|||||||||||
26 Feb 2010, 08:03 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.