News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Clearing buffers (Masm32)

Started by timertik, March 20, 2007, 07:52:25 AM

Previous topic - Next topic

timertik

Today I was working on an application and added it to the tray on minimize
and I noticed when I run a function that requires me to clear the buffer
it will xor eax and when minimized to the tray it has no icon  :(
I tried all I could to no avail  here is the line of code I run to clear a buffer
     push eax
push ecx
push edi
xor eax, eax
mov ecx, 512/4
mov edi, offset buffer
rep stosd
pop edi
pop ecx
pop eax

Is there any way to clear the buffer without messing with the registers maybe an api can do it??
how do you guys do this?
I cannot release this the way it is if the icon disapeers after pressing a button  :snooty:
I hope you guys can help from what I have read there are some masm gurus here

hutch--

Hi timertik,

welcome on board. You can reduce the code to using 1 register but I don't think there is an easy way to do it with none.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

timertik

then maybe I can make the icon load into another register? I couldnt  figure out how to modify this because I used an api for it
and If I modify the string of code that clears the buffers it doesnt work maybe im doing something wrong I need to avoid using eax when
clearing buffers I tried replacing eax with ebx and it didnt work.
this single line of code seems to be the culprit I took off piece by piece and tested the icon status and if I add this code Icon is gone take it off Icon is back  :eek
The Culprit:
mov ecx, 512/4
So i modified the code:
push esi
push ebx
push edi
xor esi, esi
mov ebx, 512/4
mov edi, offset buffer
rep stosd
pop edi
pop ecx
pop esi


and now the icon works but the buffer doesnt get cleared  :dazzled:

MichaelW

You could try preserving EAX around the code that clears the buffer, just a you are preserving EBX, ESI, and EDI.

eschew obfuscation

u

Your first code-snippet should work - the problem must be that your buffer is not 512 bytes, but less. Or maybe somewhere you've used the instruction "std". Try putting a "cld" before the "rep stosd"
Please use a smaller graphic in your signature.

PBrennick

timertik,

invoke  RtlZeroMemory, addr buffer, sizeof buffer

Paul
The GeneSys Project is available from:
The Repository or My crappy website

Mark_Larson


  you can also call memset from the CRT functions.  It will let you pick what character to write so you just say a 0.

BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

timertik

Thanks for all your input I Learned some new stuff and found two working methods but I landed on PBrennick's method.
@PBrennick
This method is what I was looking for in the beggining and thought I would never find it works perfect and my Icon shows up also it solved another error that was produced from such lengthy code I was using before

PBrennick

The GeneSys Project is available from:
The Repository or My crappy website