Prev: OctaOS
Next: DIV overflow
From: Guga on
On Mar 27, 6:56 am, "Wolfgang Kern" <nowh...(a)never.at> wrote:
> Hello Guga,
> [..]
>
> > Wolfgang...i tested it.. but i couldn´t suceed to make what is
> > necessary. I didn´t understood the code you did. And, if possible
> > i don´t want to use MMX instructions.
>
> I see, You asked for asciiDEC2HEX conversion :)
> My examples cover just bin2HEX_out and bin2DEC_out.
>
> 80 bit conversion could be done in three registers,
> but for 128 bit I'm afraid you either need a few LOCALs or
> use SSE to speed it up.
>
> I have only one 'variable size' conversion in my KESYS,
> from signed bytes up to unsigned 512 bit plus 10^x exponent.
>
> I can extract the method for fix-sized conversion and
> convert it into readable ASM. Today I'm invited to a party,
> so I better start with it tomorrow afternoon :)
>
> __
> wolfgang
>
> Are you sure that you cannot renounce on the stack frame? ;)
> You check for limits and errors in the ascii-input before ?
>
> > I suceeded to make a variation of atoi64.. but i wanted an atoi80 (or
> > also a atoi128).
> > The code i did is:
>
> __________________________________________________________
> ;;
> convert a null terminated ascii string to qword
> result in edx:eax
> ;;
>
> Proc atoi64:
> Arguments @String
>
> mov ebx D(a)String
>
> xor esi esi ; HiQword
> xor ecx ecx ; LowQWord
>
> While B$ebx <> 0
>
> call alldecmul ecx, esi
> mov ecx eax
> mov esi edx
>
> movsx eax B$ebx
> sub eax '0'
> cdq
> add ecx eax
> adc esi edx
>
> inc ebx
> End_While
>
> mov eax ecx
> mov edx esi
>
> EndP
>
> __________________________________________________________
>
> ;;
> Multiply a Qword unsigned integer by 10
>
> ;;
>
> Proc alldecmul:
> Arguments @ValA_Low, @ValA_Hi
> uses esi, ebx
>
> mov eax D(a)ValA_Hi
> mov ecx 10
> mov ebx D(a)ValA_Low
>
> cmp eax 0 | jne @Notzero
> mov eax ebx
> mul ecx
> ExitP
>
> @Notzero:
>
> mul ecx
>
> mov esi eax
> mov eax ebx ; ValA_Low
>
> mul ecx
> add edx esi
>
> EndP
> __________________________________________________________
>
> Note: The alldecmul is a variation of allmul function. Here:
>
> ;;
> Multiply two 64 bit integers.
>
> ;;
>
> Proc allmul:
> Arguments @ValA_Low, @ValA_Hi, @ValB_Low, @ValB_Hi
> uses esi, ebx
>
> mov eax D(a)ValA_Hi
> mov ecx D(a)ValB_Hi
>
> mov esi D(a)ValB_Low
> mov ebx D(a)ValA_Low
>
> or ecx eax | jne @NotEqual
> mov ecx esi
> mov eax ebx
> mul ecx
> ExitP
>
> @NotEqual:
> mov ecx esi
>
> mul ecx
>
> mov esi eax
> mov eax ebx ; ValA_Low
> mul D(a)ValB_Hi
>
> add esi eax
> mov eax ebx ; ValA_Low
>
> mul ecx
> add edx esi
>
> EndP
>
> Any idea how to make a atoi80 or atoi128 ?
>
> Best Regards,
>
> Guga


Hi wolfgang.. tks for the reply.

Have a good party :):):)

I can remove the usage of stack frames. I´m just used to them for
readability purposes mainly. I distinguish better a functin from
another when i see the 1st "Proc" on the begginning of a line.

About thye checkings for errors and limits on the ascii string.. yes..
they are used in other routine. On the example i provided, i built it
only when the string was already checked.

"80 bit conversion could be done in three registers, but for 128 bit
I'm afraid you either need a few LOCALs or use SSE to speed it up. "

Yes.. this is what i was thinking. Using 80 bit in 3 registers, and on
128 bit, using local to compute the data, and returning them in 4
registers (or returning in inside a global data - like a structure)


"I can extract the method for fix-sized conversion and convert it into
readable ASM."

Tks.. i´ll appreciate it :)

But.. if you suceed to do for 128 bit.. is SSE really needed ?

Best Regards,

Guga



From: Guga on
On Mar 27, 12:28 am, Frank Kotler <fbkot...(a)verizon.net> wrote:
> Guga wrote:
>
> ...
>
> > I can´t understand the logic of using shld
>
> Randy is doing *hex* ascii to integer. The "shld 4" does a multi-dword
> multiply by *16*.
>
> I *completely* misunderstood what you were trying to do. The code from
> Nasm64developer is to convert a "float string" (can contain '.', 'e',
> etc. plus decimal digits) to IEEE???(whatever that number is... 754)
> floating-point format. Still an "interesting" project, perhaps, but not
> what you want, at all!
>
> With my New Improved (mis)Understanding, this looks a lot easier. I'm
> not sure what you'd do with a tbyte/tword integer, but if you can
> multiply a tword by ten, you've got it made. Might be worth developing
> an "arbitrary size" multiply, rather than specifically tword. Lemme
> think on this a little...
>
> Best,
> Frank

"With my New Improved (mis)Understanding, this looks a lot easier. I'm
not sure what you'd do with a tbyte/tword integer, but if you can
multiply a tword by ten, you've got it made. Might be worth developing
an "arbitrary size" multiply, rather than specifically tword. Lemme
think on this a little..."

Tks frank :)

an arbitraty size ?

How ?

I 1st thought in making loops inside the alldecmul to get the
remainders, but then.. i got stuck because i couldn´t knew how to get
the remainders for the tword, and put them on different registers then
edx:eax.

I mean.. if using the convertino to 80 bit.. 3 registers can hold the
value, 128 bits, it may be 4 registers (or putting the generated data
on a structure with the proper size)



Best Regards,

Guga


From: Frank Kotler on
Guga wrote:

....
> "With my New Improved (mis)Understanding, this looks a lot easier. I'm
> not sure what you'd do with a tbyte/tword integer, but if you can
> multiply a tword by ten, you've got it made. Might be worth developing
> an "arbitrary size" multiply, rather than specifically tword. Lemme
> think on this a little..."
>
> Tks frank :)
>
> an arbitraty size ?
>
> How ?

Like Herbert showed you - or look at my "translation" to Nasm if his
syntax baffles you. (It baffles *me*! I disassemble the thing with
ndisasm and work from there!)

> I 1st thought in making loops inside the alldecmul to get the
> remainders, but then.. i got stuck because i couldn�t knew how to get
> the remainders for the tword, and put them on different registers then
> edx:eax.
>
> I mean.. if using the convertino to 80 bit.. 3 registers can hold the
> value,

Yeah... two and a half registers, if we want to be stingy -
cx:edx:eax... or use a segreg for the odd two bytes :)

But what's the point? What are you going to do with this 80-bit integer
once you've got it? Strange size for an integer - but used for
extended-precision floats, which is what threw me off.

> 128 bits, it may be 4 registers (or putting the generated data
> on a structure with the proper size)

You won't want to tie up four registers (or 2-1/2) for long, so you'll
be wanting to store results in memory in any case, I would imagine.
Herberts routine won't do a tword exactly, since "size" is specified in
dwords, but the idea could be modified so it would, if that's what you
really want. Seems an odd size to write a special routine for. 128 bits
("oword"? I think that's what RosAsm calls 'em) makes more sense - just
set Herbert's "size" to 4...

Best,
Frank
From: Herbert Kleebauer on
Frank Kotler wrote:
> Herbert Kleebauer wrote:

> Okay, I see what you mean (I think). In case some other examinees (I
> mean "dear readers") wish to participate, I won't post my answer yet.

That's the advantage of my syntax: I can post the missing line
and still nobody will understand it:

addcq.l #0,r1
From: Guga on
On Mar 27, 8:53 am, "Guga" <Guga...(a)gmail.com> wrote:
> On Mar 27, 12:28 am, Frank Kotler <fbkot...(a)verizon.net> wrote:
>
>
>
>
>
> > Guga wrote:
>
> > ...
>
> > > I can´t understand the logic of using shld
>
> > Randy is doing *hex* ascii to integer. The "shld 4" does a multi-dword
> > multiply by *16*.
>
> > I *completely* misunderstood what you were trying to do. The code from
> > Nasm64developer is to convert a "float string" (can contain '.', 'e',
> > etc. plus decimal digits) to IEEE???(whatever that number is... 754)
> > floating-point format. Still an "interesting" project, perhaps, but not
> > what you want, at all!
>
> > With my New Improved (mis)Understanding, this looks a lot easier. I'm
> > not sure what you'd do with a tbyte/tword integer, but if you can
> > multiply a tword by ten, you've got it made. Might be worth developing
> > an "arbitrary size" multiply, rather than specifically tword. Lemme
> > think on this a little...
>
> > Best,
> > Frank
>
> "With my New Improved (mis)Understanding, this looks a lot easier. I'm
> not sure what you'd do with a tbyte/tword integer, but if you can
> multiply a tword by ten, you've got it made. Might be worth developing
> an "arbitrary size" multiply, rather than specifically tword. Lemme
> think on this a little..."
>
> Tks frank :)
>
> an arbitraty size ?
>
> How ?
>
> I 1st thought in making loops inside the alldecmul to get the
> remainders, but then.. i got stuck because i couldn´t knew how to get
> the remainders for the tword, and put them on different registers then
> edx:eax.
>
> I mean.. if using the convertino to 80 bit.. 3 registers can hold the
> value, 128 bits, it may be 4 registers (or putting the generated data
> on a structure with the proper size)
>
> Best Regards,
>
> Guga- Hide quoted text -
>
> - Show quoted text -

Ok, guys

i think i finally got it working.. It seems that the function can
works without any size multiple of 32 bits. So it seems to be working
on 32bits, 64 bits, 96 bits, 128 bits and so on. (well.. not sure
yet.. if it is really working.. i have no way how to check some test
number)

I used the mul routine only. The code is a total mess. so i´ll post it
here if it is really running ok.

In the meanwhile.. can someone pls tell me, if this ascii decimal
number: "1699504104824251512520704" have the following hexadecimal
form of:

0167E2__04D586300__00000000

The "__" mark i just posted here to make it easier to see the 4 byte
chain.


Best Regards,

Guga

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Prev: OctaOS
Next: DIV overflow