News:

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

JEAXNZ ??

Started by mariø, February 07, 2005, 04:50:55 PM

Previous topic - Next topic

mariø

are thre any short instrunction to do this:
.if (eax==IDOK)
   jmp start
.endif

Mirno

Shorter than

cmp eax, IDOK
je start

I don't think so, but it's not exactly huge though.

Mirno

Ratch

mariø,
     There is a shorter sequence if you don't mind if EAX is changed.  Ratch


     DEC EAX
     JZ start

mariø

thanks rat, i'm thinking in something like this.

Nilrem

Without windows apis how can one compare the information at two addresses/offsets?
I try cmp [var], [var] but to no avail.

Mirno

There is no mem, mem compare instruction.

You must first move one variable to a register (if you choose carefully, you can then use it later).

Mirno

Nilrem

why does mov eax, [var] not work then?

hutch--

To perform memory comparison, try something like this.


mov eax, var1
cmp eax, var2
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Nilrem

Thanks that worked Hutch, but unfortunately did not solve my fundamental problem located in my lstrcmp post.

Nilrem

Anyway to move var,var1? Otherwise there is no way my code can work, mov ebx, var mov va1, ebx just will not cut it for my type of code.

Dark Schneider

EBX should be reserved.

To move var, var1 just use this:

mov eax, var1
mov var, eax

or this to avoid all registers:

push var1
pop var

if that still can't cure, then post your code sample and may be someone can help

Nilrem

This is an example of my code


xor ecx,ecx
someproc proc
inc ecx
if ecx = 1 - mov var,var2
if ecx = 2, mov var,var1
call anotherproc proc
manipulate var1
inc ecx
ret

but in the manipulation procedure all the registers are used so I can't use them, because after the program closes I need to pop them back off.

Hmm lightbulb idea.. could I do this?

mov eax,var
push eax ; save value right?
manipulate eax
pop eax ; put the value back?
but then when the program closes they won't be how they originally started will they? that will lead to crashes?

sluggy

That depends on what you mean by "when the program closes". If it means when the app exits, then you don't really carfe if the registers are the same as what they were on entry. If you mean "when the function returns", then what you need to do is push all the registers when you enter your proc, and pop them all when you leave. A handy way to do this is with the "USES" statement, like this:


    proc blah USES eax ebx ecx edx  param1:DWORD, .....


then MASM will insert the correct PUSH/POP code for you when it compiles. Also, if you are using ecx as a counter, always PUSH it before calling another proc, never trust the other proc to preserve it. I have had a few bugs happen this way, by calling another proc and having my count register get all messed up.

Nilrem

It won't work because in my manipulating variable procedure I have to push and pop most of the registers. I need to move 3 variables to three seperate registers and push/pop them but cannot. Is there no way at all to move something to a variable? I just do not understand why I cannot fill an initialised variable? There must be some way around this problem as I can see it occuring a lot?

dsouza123

If you aren't using the FPU, you could use it to hold some values temporarily in the FPU registers.