The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: miaomiao on March 15, 2006, 09:51:35 AM

Title: translate C++ code to MASM32
Post by: miaomiao on March 15, 2006, 09:51:35 AM
hi all, I am not familiar with C++ code, And I had see some C++ codes to  transform a string to another.
Then how can I do in my MASM32 codes? I need your help, Thanks.

the following is the C++ codes





By the way: SRC is a DWORD
     
Title: Re: translate C++ code to MASM32
Post by: miaomiao on March 16, 2006, 05:00:27 AM
anyone can help or give me some advices? Thank you.

This code IS the BEST one for me that I cannot translate "int num1 = (int) (SRC & ((long) Math.Round(Math.Pow(2, (double) num6)))) "
Title: Re: translate C++ code to MASM32
Post by: zooba on March 16, 2006, 07:31:38 AM
Perhaps if you try and separate that line into each little step and explain what it is doing, you will be able to implement it in asm.

Also, think about what the result of it is and describe it in english. There's a pretty good chance there's one or two commands that will do exactly that, without the overhead of using C's libraries and floating point functions.

Cheers,

Zooba :U
Title: Re: translate C++ code to MASM32
Post by: miaomiao on March 16, 2006, 12:49:13 PM
Thank you zooba, I translated, and only this code I donnot know how to translate into MASM32 codes, "text4 = Strings.Right(text4, 1) + Strings.Left(text4, Strings.Len(text4) - 1);", anyone else can help me please ?
Title: Re: translate C++ code to MASM32
Post by: miaomiao on March 16, 2006, 02:14:16 PM
The following is my translated codes, but it cannot work correctly, anyone else can tell me which codes are not correctly? Thank you.



Title: Re: translate C++ code to MASM32
Post by: dsouza123 on March 16, 2006, 05:13:27 PM
The code
text4 = Strings.Right(text4, 1) + Strings.Left(text4, Strings.Len(text4) - 1);
is rotating text.  Last becomes first. Does it num8 times.

Example
12345678
81234567
78123456
67812345
56781234
45678123

With a buffer of twice the size of the string (not counting the terminating zero),
with the string right justified (padded with the number of spaces equal to original length placed first).
The last chararcter can be replace one character before the current start and the last replaced with a zero byte.

****ABCD0
***DABC00
**CDAB000
*BCDA0000
ABCD00000

So no shifting/copying the whole string each time.