Results 1 to 6 of 6

Thread: Arrays, Floats and doubles on inline ASM?

  1. #1

    Thread Starter
    Addicted Member Nigh™a®e's Avatar
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    175

    Arrays, Floats and doubles on inline ASM?

    hi,

    I'm trying to figure out how to use array and floats with asm

    for example
    int nOp1 = 10;
    int nOp2 = 2;

    Code:
    	int nOp1 = 10;
    	int nOp2 = 5;
    
    	__asm mov eax, nOp1;
    	__asm add eax, nOp2;
    in this case the result of eax = 15


    Code:
    	float fOp1 = 10.5f;
    	float fOp2 = 3.07f;
    
    	__asm mov eax, fOp1;
    	__asm add eax, fOp2;
    in this case the result of eax = -4.3434515e-038



    next problem i have i using array structures (stored in vector)

    Code:
    	pCodes.push_back( OpCode( OC_MOV,  a ) );
    	pCodes.push_back( OpCode( OC_ADD,  b ) );
    	pCodes.push_back( OpCode( OC_MOVR, r ) );
    to store the execution of the opcode (r = a + b)

    Code:
    	pOC = pCodes[nCode];
    	__asm mov eax, pOC.Data
    this part of code is working

    Code:
    	__asm mov eax, pCodes[nCode];.Data
    this ain't :

    warning C4537: 'nCode' : '.' applied to non-UDT type
    error C2410: 'Data' : ambiguous member name in 'second operand'

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Originally posted by dglienna
    if it's a dial-up account, then these posts won't help. I assume that AOL is dialup, but I could be wrong. Internet Connection Sharing should be able to do what you want, though.

    Can you find each PC from the other by its IP address? The first time you click on it, you may have to log on with a username/password. If you do, you could just map the drive on the machine, and have it retain the connection for all log ons in the future. I do that from my XP laptop to a W2K Workstation, and everything works fine.

    The W2K machine has an account for LAPTOP, otherwise, I can't see the shared folders (and printer). Others have suggested otherwise, but it works for me just fine.
    If he doesn't need to share the internet connection then all he needs for both the computers to communicate is forthem to have IP addresses in the same subnet.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Addicted Member Nigh™a®e's Avatar
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    175
    lol visualAd, what has this to do with my question

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Sorry - this happened a couple of days back too. I reply to one thread and it a ppears in another totally random thread.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: Arrays, Floats and doubles on inline ASM?

    Originally posted by Nigh™a®e
    hi,

    I'm trying to figure out how to use array and floats with asm

    for example
    int nOp1 = 10;
    int nOp2 = 2;

    Code:
    	int nOp1 = 10;
    	int nOp2 = 5;
    
    	__asm mov eax, nOp1;
    	__asm add eax, nOp2;
    in this case the result of eax = 15


    Code:
    	float fOp1 = 10.5f;
    	float fOp2 = 3.07f;
    
    	__asm mov eax, fOp1;
    	__asm add eax, fOp2;
    in this case the result of eax = -4.3434515e-038



    next problem i have i using array structures (stored in vector)

    Code:
    	pCodes.push_back( OpCode( OC_MOV,  a ) );
    	pCodes.push_back( OpCode( OC_ADD,  b ) );
    	pCodes.push_back( OpCode( OC_MOVR, r ) );
    to store the execution of the opcode (r = a + b)

    Code:
    	pOC = pCodes[nCode];
    	__asm mov eax, pOC.Data
    this part of code is working

    Code:
    	__asm mov eax, pCodes[nCode];.Data
    this ain't :

    warning C4537: 'nCode' : '.' applied to non-UDT type
    error C2410: 'Data' : ambiguous member name in 'second operand'

    The problem your having with doing floating point numbers is because your talking to the wrong processor / unit. When doing calculations for floating point numbers, you have to use the FPU (Floating Point Unit).

    You can't work with arrays the C++ way in ASM. You have to do it the ASM way, IE: you use offsets to move through the array.
    Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. - Oscar Wilde

  6. #6
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    The thing is that you deal with arrays in C++, in the assembler way (base + offset). The problem is that you do not deal with vectors in C++ the assembler way.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width