Hi,
I am to take an input from user. Then, I need to convert that Ascii string to a 64-bit integer. I can do this with 32-bit, but I have no idea how to do it in 64-bit.
Anybody know, please give me a hint. Thanks a lot.
Subtraction is performed by replacing ADD with SUB and ADC with SBB.
For shift, you must shift by only one bit at a time.
To shift a 64-bit number left (i.e. x2)
shl dword ptr num1,1
rcl dword ptr num1[4],1
To shift a 64-bit number right (i.e. /2)
shr dword ptr num1[4],1
rcr dword ptr num1,1
So why do you need to know about addition and shifting? Because you CAN'T use the 32-bit mul and div reliably! Remember you are using 64-bit numbers and mul and div can't hack 64-bit numbers.
So how to multiply by 10 (which is needed to convert to integer, right?)??
Well, multiply by 10 is:
10X
2(5X)
2(4X + 1X)
So you need to multiply by powers of two. And how to multiply by powers of two? Why shift, of course!!!
So, to multiply by 10, put the number in two registers, shift the registers left twice, add the original number, then shift the registers again.
Have fun! And make sure you check your numbers...
"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.