The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: debugee on February 10, 2012, 03:55:16 AM

Title: an error in masm32
Post by: debugee on February 10, 2012, 03:55:16 AM
.386
.model flat,stdcall
option casemap:none


.code

shell_start      equ      this byte
      nop
      jmp   @f      ;; this instruct give rise to error !!
      nop
   @@:
      nop
shell_end      equ      this byte


TestFunc   proc   uses ebx esi edi _dwTest
   
   
      ret
TestFunc   endp   
start:
   ;;;;shell_end - shell_start = nop + jmp(short jmp) + nop + nop = 1 + 2 + 1 + 1 = 5
   invoke   TestFunc,shell_end - shell_start   ;;result shell_end - shell_start = 0DH !!
   
   ;;;you can see this error by Ollydbg.

   ret
end   start
Title: Re: an error in masm32
Post by: dedndave on February 10, 2012, 04:21:56 AM
masm32 is a package of libraries, include files, examples, tutorials, and tools
masm is a program by microsoft   :P
this is a masm bug - not masm32
it is probably fixed on more recent versions of masm
there was a recent related thread, only the problem was with $ in the .DATA section

at any rate, for your case, try this for a work-around...
include \masm32\include\masm32rt.inc

.code

shell_start::
      nop
      jmp   @f      ;; this instruct give rise to error !!
      nop
   @@:
      nop
shell_end::


TestFunc   proc   uses ebx esi edi _dwTest
   
   
      ret
TestFunc   endp   
start:
   ;;;;shell_end - shell_start = nop + jmp(short jmp) + nop + nop = 1 + 2 + 1 + 1 = 5
   invoke   TestFunc,shell_end - shell_start   ;;result shell_end - shell_start = 0DH !!
   
   ;;;you can see this error by Ollydbg.

   ret
end   start
Title: Re: an error in masm32
Post by: debugee on February 10, 2012, 04:33:14 AM
thanks for you reply !
but you code still error .

shell_start::
shell_end::

that syntax i don't see before ,  :lol\
i had learn it at  here .  :lol :lol

Title: Re: an error in masm32
Post by: dedndave on February 10, 2012, 04:35:54 AM
Quotebut you code still error

interesting   :P

Quoteshell_start::
shell_end::

that syntax i don't see before

it is similar to ":", except "::" has global scope
Title: Re: an error in masm32
Post by: debugee on February 10, 2012, 04:39:51 AM
 :lol

::

i have see that in nasm
Title: Re: an error in masm32
Post by: dedndave on February 10, 2012, 04:44:23 AM
it seems to be a problem with INVOKE (a masm-internal macro)
try this....

        push    shell_end-shell_start
        CALL    TestFunc

Title: Re: an error in masm32
Post by: debugee on February 10, 2012, 04:49:02 AM
hi dedndave .

yes, invoke instruct lead to the error .
yestorday, i had to modify it like you code
:U
Title: Re: an error in masm32
Post by: dedndave on February 10, 2012, 06:50:26 AM
i happened to think - this will probably work...
TempParm = shell_end-shell_start
        INVOKE  TestFunc,TempParm

:8)
Title: Re: an error in masm32
Post by: hutch-- on February 10, 2012, 07:56:05 AM
 :bg

These bug reports always make me laugh, MASM has always been a buggy old pig that you had to be familiar with to get results from. Its an assembler, not a consumer multimedia app and there must be at least a million ways of writing code that does not work. The trick is to write code that does work.
Title: Re: an error in masm32
Post by: debugee on February 10, 2012, 11:20:53 AM
yes , just code batter. :bg
Title: Re: an error in masm32
Post by: SteveAsm on February 10, 2012, 03:00:10 PM
Quote from: hutch-- on February 10, 2012, 07:56:05 AM
...there must be at least a million ways of writing code that does not work. The trick is to write code that does work.

That is worthy of being a "quote".
Title: Re: an error in masm32
Post by: clive on February 10, 2012, 05:06:28 PM
Quote from: SteveAsmThat is worthy of being a "quote".

Made me chuckle too, perhaps the million monkeys working on Shakespeare could knock out a couple of bad MASM examples in the process. Or perhaps Edison's quip about discovering a thousand ways not to make a light bulb.