News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Cpp code

Started by mabdelouahab, March 24, 2015, 05:24:35 PM

Previous topic - Next topic

mabdelouahab

Good morning all
I need help to convert this code to masm
if (name)
{
char* buf;
int len = lstrlen(name);
int nonascii = 0;
for (unsigned char far* pc = (unsigned char far*)name; *pc; pc++)
if (*pc >= 128)
nonascii++;
if (nonascii)
{
unsigned char far* pn = (unsigned char far*)name;
buf = new char[nonascii + len + 1];
name = buf;
unsigned char c;
do
{
c = *pn++;
if (c < 128)
{
*buf++ = c;
}
else
{
char* px = foldName + (c-128)*2;
*buf++ = *px++;
if (*px)
*buf++ = *px;
}
} while (c);
}
out << ' ';
out << name;
if (nonascii)
delete name;
}


  char foldName[256+1] = {
  "_\0_\0_\0f\0_\0_\0_\0_\0_\0_\0S\0_\0OE_\0_\0_\0"
  "_\0_\0_\0_\0_\0_\0_\0_\0_\0TMs\0_\0oe_\0_\0Y\0"
  "_\0_\0c\0L\0_\0Y\0_\0_\0_\0c\0a\0_\0_\0_\0r\0_\0"
  "0\0_\0\062\0\063\0_\0u\0_\0_\0_\0\061\0o\0_\0_\0_\0_\0_\0"
  "A\0A\0A\0A\0AEA\0AEC\0E\0E\0E\0E\0I\0I\0I\0I\0"
  "D\0N\0O\0O\0O\0O\0OEx\0O\0U\0U\0U\0UEY\0_\0ss"
  "a\0a\0a\0a\0aea\0aec\0e\0e\0e\0e\0i\0i\0i\0i\0"
  "o\0n\0o\0o\0o\0o\0oe_\0o\0u\0u\0u\0uey\0_\0y\0"
};

my understanding is he's looking for a character that is equal to or greater than 128 then calculates a nonascii, then put a new text (text length + nonascii), I could not understand what inside a loop DO.
Thank you

Gunther

Hi  mabdelouahab,

Quote from: mabdelouahab on March 24, 2015, 05:24:35 PM
Good morning all
I need help to convert this code to masm

set the -S switch and the compiler will generate the assembly language output for you.

Gunther
You have to know the facts before you can distort them.

mabdelouahab

Quote from: Gunther on March 24, 2015, 10:21:51 PM
set the -S switch and the compiler will generate the assembly language output for you.
I didn't know this information thank you  Gunther  :t

Gunther

Hi mabdelouahab,

Quote from: mabdelouahab on March 25, 2015, 02:53:48 AM
I didn't know this information thank you  Gunther  :t

you're welcome. By the way, which compiler do you use?

Gunther
You have to know the facts before you can distort them.

mabdelouahab

Hi Gunther
Sometimes coincides with some of the topics that I do not find detailed documentation about them, and by accident I found the source code for the code generator,reads type libraries *.OLB; *.TLB and emits C++ source file, by Borland International
I started working in the past but I stopped for this reason(masm32.com/board/index.php?topic=2897.0) ,a long time ago I'm looking into the matter, and did not find a subject detailed
I wanted to convert this CPP File to masm code generator
Quote from: Gunther on March 25, 2015, 05:39:39 AM
you're welcome. By the way, which compiler do you use?
BCC55
* sorry for my english

Gunther

Hi mabdelouahab,

Quote from: mabdelouahab on March 25, 2015, 06:42:52 AM
BCC55

that should work. In older versions the Borland Compiler generated the assembly language source and left the C or CPP source as a comment. So you can see how is every high level language instruction into assembly language.

Quote from: mabdelouahab on March 25, 2015, 06:42:52 AM
* sorry for my english

My English isn't better.

Gunther
You have to know the facts before you can distort them.