Roland <rv@ronetech.com> wrote in message news:3D50F00A.EBF0567@ronetech.com...KarL a écrit :
Source:
.
.somepublicfunction() { __asm mov dx, 0x300 __asm mov al, m_cC __asm out dx,al }
you are loading the offset of m_cC in al !
you have to do like this:asm mov eax,this
asm mov al,[eax].m_cCroland
C:\tmp\bugtest>bcc32 -S bug.cpp
Borland C++ 5.0 for Win32 Copyright (c) 1993, 1996 Borland International
bug.cpp:
Error bug.cpp 9: Type 'someobj' may not be defined here
Warning bug.cpp 13: Function should return a value in function somepublicfunction()
Error bug.cpp 18: Expression syntax in function someobj::somebuggyfunction()
*** 2 errors in Compile ***
C:\tmp\bugtest>bcc -S bug.cpp
Borland C++ 5.0 Copyright (c) 1987, 1996 Borland International
bug.cpp:
Error bug.cpp 9: Type 'someobj' may not be defined here
Warning bug.cpp 13: Function should return a value in function somepublicfunction()
Error bug.cpp 18: Expression syntax in function someobj::somebuggyfunction()
*** 2 errors in Compile ***
class someobj {
unsigned char m_cC; // This is private to someobj only
public:
void somebuggyfunction();
void somefunction();
}; // NOTICE THE ';' now...somepublicfunction() // This is a global function
{
__asm mov dx, 0x300
__asm mov al, m_cC // trying to access non global variable
__asm out dx,al
}
void someobj::somebuggyfunction()
{
__asm mov dx, 0x300
__asm mov al, m_cC // Question, 16-bit and 32-bit compatible???
__asm out dx,al
}
void someobj::somefunction()
{
m_cC = 0x56;
}
C:\tmp\bugtest>bcc -S bug.cpp
Borland C++ 5.0 Copyright (c) 1987, 1996 Borland International
bug.cpp:
Warning bug.cpp 13: Function should return a value in function somepublicfunctio
n()
Error bug.cpp 18: Expression syntax in function someobj::somebuggyfunction()
*** 1 errors in Compile ***
C:\tmp\bugtest>bcc32 -S bug.cpp
Borland C++ 5.0 for Win32 Copyright (c) 1993, 1996 Borland International
bug.cpp:
Warning bug.cpp 13: Function should return a value in function somepublicfunctio
n()
Error bug.cpp 18: Expression syntax in function someobj::somebuggyfunction()
*** 1 errors in Compile ***
C:\tmp\bugtest>sc -C bug.cpp
__asm mov al, ThisIsABogusVariable
^
bug.cpp(11) : Warning 13: Illegal type/size of operands for the mov instruction
}
^
bug.cpp(13) : Error: undefined label 'ThisIsABogusVariable'
--- errorlevel 1
void someobj::somebuggyfunction()
{
unsigned char uc = m_cC; // Use the stack to get member variable
__asm mov dx, 0x300
__asm mov al, uc // Now both 16-bit and 32-bit is OK... (I think)
__asm out dx,al
}