Please, tell me this is not true:

http://courses.ece.uiuc.edu/ece291/lecture/lockwood/cond_jump_info.html

""""""""""""""""""""""""""""""""""""""""""""""""
Suppose you write the following program and assemble it with MASM

my_label: NOP
NOP
.. and 300 more NOPS ..
NOP
CMP AX,BX
JE my_label
.. More code ..


MASM will actually generate the following code:

my_label: NOP
NOP
.. and 300 more NOPS ..
NOP
CMP AX,BX
JNE +3
JMP my_label
.. More code ..
""""""""""""""""""""""""""""""""""""""""""""""""

I am about to test it.
Posted on 2002-03-17 20:38:51 by bdjames
I guess f0dder has already told about it.


Masm is not a compiler, it's an assembler.

The file ml.exe assembles the file you are using, and link.exe link it to the object file generated in order to create an executable, a dll....etc.


I tested and the info is wrong.

I wrote
my_label: NOP
NOP
.. and 300 more NOPS ..
NOP
CMP AX,BX
JE my_label
.. More code ..

And the result as exactly as it is:

my_label: NOP
NOP
.. and 300 more NOPS ..
NOP
CMP AX,BX
JE my_label
.. More code ..

You can do the same test on 3dframes, for5 example (on masm package rom hutch) .

Put the code at the end and see the results.

like this:

(...)

Frame3D endp

; #########################################################################

my_label::

(300 nops)

CMP AX,BX
JE my_label
(more code ---i used some more nops)
nop
nop
nop
nop
nop
nop
ret

end start

Analyse the file with your favorite disassembler, like IdaPro, OllyDbg, W32dasm or other....

If some differences appearsm, it's not due to the assmbler, but to the disassembler you are using to analyse the file.

One of the reasons that the code can seem to be altered (JNE +3
JMP my_label ), is probably to the code that is just under JE my_label. Depending your disassembler or the code it self, it can not be well aligned and cause a misunderstooding when the disassembler analyses the file.

It's commom that kinda thing happens...and seems to be an error. (but it not necessarily can be).

If the code don't have much room (or it's compressed and you decompressed it), any changes you make can cause this. Even a simple nop can make a disassembler confused, and can cause errors, making windows interprets the code in a wrong way.

It's not masm privilege, it can be caused to any compiler or assembler.

Programs created to work with windows 311, using old borland versions or older compilers (or even 16 bits programming), can cause this mistake most commonly.


I am not sure i got you the most accurated information, i guess f0dder, bitRAKE, Ewayne, E?in, are more skilled to answer this issue.

Although, one thing is right: This mistakes can happen and they are nor caused by masm....And masm don't generate this error if it the code is aligned correctly.

Regards,

Beyond2000!
Posted on 2002-03-17 21:38:35 by Beyond2000!
BD,

At the bottom, an assembler is a program that will "assemble" mnemonics to opcodes. Most have options to do more and that tends to make them more like compilers but if you had to draw the distinction, a compiler without the use of an inline assembler does not translate mnemonics to opcodes directly, they usually work in larger blocks of code.

Regards,

hutch@movsd.com
Posted on 2002-03-17 21:39:04 by hutch--
Found it, try this:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.model small

fill macro
db 300 dup(144)
endm

.code
_my_label:
NOP
NOP
fill
NOP
CMP AX,BX
JE _my_label
NOP
NOP
end _my_label
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

But it is ok when you specify flat model/286+.
:tongue:
I wonder if there are any more of these.
Posted on 2002-03-17 22:29:33 by bdjames