Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


win32 asm question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 October 1999 - 08:04 AM

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


Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 12 October 1999 - 02:05 PM

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


#3 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 October 1999 - 07:09 PM

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.

#4 Josh Neta   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 October 1999 - 04:49 AM

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


#5 bit   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 October 1999 - 05:55 AM

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


#6 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 October 1999 - 08:13 AM

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.


#7 bit   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 October 1999 - 04:45 PM

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


#8 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 October 1999 - 06:42 PM

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.


#9 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 13 October 1999 - 07:12 PM

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


#10 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 October 1999 - 08:04 AM

Thanx,
It works now.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS