void putHorizLine(int x1,int x2,int y2,int color)
{
int lineoffset = y2 * (g_cscreen->pitch >> 2;
asm
{
mov ax, [g_puiScreen] // move segment of Where to AX
mov es, ax // set ES to segment of Where
mov di, [lineoffset] // set di to Y offset
add di, [x1] // add the X1 offset to DI
mov al, // move Col to AL
mov ah, al // move Col to AH (we want 2 copies for word moving)
mov cx, [x2] // move X2 to CX
sub cx, [x1] // move the change in X to CX
shr cx, 1 // divide change in X by 2 (for word moving)
jnc Start // if we have an even number of moves, go to Start
stosb // otherwise, move one byte more
}
Start: asm
{
rep stosw // do it!
}
}
</pre>
Inline asm
Hi could someone please help me set up the functions so that it works
Are you getting compile errors? If not, use a debugger to go through the code and see what happens.
Suggestion: Unless you have a good reason to use 16-bit assembly, start using 32/64-bit assembly.
Suggestion: Unless you have a good reason to use 16-bit assembly, start using 32/64-bit assembly.
Quote:Original post by vNistelrooy
Are you getting compile errors? If not, use a debugger to go through the code and see what happens.
Suggestion: Unless you have a good reason to use 16-bit assembly, start using 32/64-bit assembly.
Oh so that is 16bit asm? Okay so how can i make it 32bit, that is probably why it won't compile under a win32 project
Quote:Original post by RDragon1
Why are you using assembly at all?
Speed, is that a valid excuse?
Quote:Original post by RDragon1
Nope
Well actually i want to learn asm, so you going to help me..
Here is the compile output in c++:
error C2065: 'ASM' : undeclared identifier
error C2143: syntax error : missing ';' before '{'
error C2065: 'mov' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'ax'
error C2065: 'ax' : undeclared identifier
error C2059: syntax error : '['
error C2059: syntax error : '{'
error C2143: syntax error : missing ';' before '{'
error C2065: 'rep' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'stosw'
error C2065: 'stosw' : undeclared identifier
error C2143: syntax error : missing ';' before '}'
Quote:Original post by RDragon1
Nope
How about being useful!
Umm the asm keyword is actually:
__asm
{}
Hope that helps,
Dave
If you want speed then you won't be losing much, if any, by using C in place. Even C++ won't slow it down noticably. If you weight up the time taken to solve this problem to the speed of the program, i think you'll find C++ perfectly fine.
dave
dave
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement