Advertisement

win32 asm question

Started by October 14, 1999 02:04 PM
8 comments, last by bosjoh 25 years, 2 months ago
Just take your current code add ';'s after all your statements and you can put your lables inside the _asm {}. Thats another thing its _asm not asm. So it would be something like:

_asm {
les di, buffer;
add di, 63360;
.
.
.
Loop:
mov al, [es:di-1];
.
.
.
}

Josh

Why adding 63360 to di? This would take the pointer to the bottom of the screen (I want to use this blurring effect all over the screen.
I already figured out that asm{} becomes _asm{}, but that's not my prblem. Every assembler test runs but when I use
les di, buffer
the compiler quits when it gets out of the function. I know that changing registers causes this, so I want to know which registers I should save (like in BC++ 5.0 not saving DS would be critical) and if I can use push and pop for that.
Advertisement
oops sorry about the wrong number (it was kinda late when i typed that). The problem is (probably) that youre trying to use old dos style stuff in windows which doesnt fly. Are you trying to use this with mode 13h or with DDraw? And as far as registers go you usually dont have to save any, its usually done by the compiler (tho in some cases such as CPUID you have to save them). But i could be wrong so try pushing and poping di, its not going to hurt anything. I cant really help you out much without knowing if youre trying to do this with DDraw or 13h, so tell me.

Josh

The C/C++ compilers tend to push everything on the stack for you and pop it off at the end. So, doing it again is kind of redundant.

Also, there is NO need to load the segments. The les instruction is invalid in 32-bit flat memory model program. Instead use lea if you want the address.

- Chris

Thanks bit, that was the information I need.
But here is another question: is it es:edi or just edi? And do you move (except using stos) a value at a memory like this:
mov es:edi, 10
or
mov edi, 10?

I'm using a directdraw 640x480x256 screenmode, lock the area and retrieving the pointer to the screen.

Just use EDI.

For all intents and purposes there are NO segments. This isn't entirely correct. But, you won't need to be doing anything with them.

- Chris

Advertisement
I've changed the code to this:

_asm{
lea edi, buffer
add edi, 640
mov ecx, 305920
xor ax, ax
xor bx, bx
};
Looper:
_asm{
mov al, [edi-1]
mov bl, [edi+1]
add ax, bx
mov bl, [edi-640]
add ax, bx
mov bl, [edi+640]
add ax, bx
shr ax, 2
jz Done
dec ax
};
Done:
_asm{
stosb
loop Looper
};

But it doesn't work. The address of 'buffer' is not loaded into EDI.

To move the buffer address into EDI, you can do:

MOV EDI, buffer

To move the contents of where the buffer address points
to into EAX, do:

MOV EAX, [EDI]

To increment the buffer address (to just the next byte), do:

ADD EDI, 1


Heathen

I've written this code in BC++ 5.0. My question is: how can I write it in VC++ 6.0?
And which registers should I save/load (using push & pop?). Here is the code:

asm{
les di, buffer
add di, 320
mov cx, 63360
xor ax, ax
xor bx, bx
};
Loop:
asm{
mov al, [es:di-1]
mov bl, [es:di+1]
add ax, bx
mov bl, [es:di-320]
add ax, bx
mov bl, [es:di+320]
add ax, bx
shr ax, 2
jz Done
dec ax
};
Done:
asm{
stosb
loop Loop
};//a blurring effect in 320x200 rez

Thanx,
It works now.

This topic is closed to new replies.

Advertisement