The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Rainstorm on October 28, 2006, 01:07:41 AM

Title: problem with this code
Post by: Rainstorm on October 28, 2006, 01:07:41 AM
hi,..
am just fiddling with the code I wrote to understand what's going on better..& the following code fails
for this line - mov edx, offset data - i get the error
error A2098: invalid operand for OFFSET
testrun PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD

      .data
      linne1 db 50

      .data?
        hInstance dd ?

      .code
; ---------------------------------------------------------------------
LibMain proc instance:DWORD,reason:DWORD,unused:DWORD

    .if reason == DLL_PROCESS_ATTACH
      push instance
      pop hInstance
      mov eax, TRUE

    .elseif reason == DLL_PROCESS_DETACH
    .elseif reason == DLL_THREAD_ATTACH
    .elseif reason == DLL_THREAD_DETACH

    .endif

    ret

LibMain endp

testrun proc mWnd:DWORD,aWnd:DWORD,data:DWORD,parms:DWORD,show:BOOL,nopause:BOOL

mov ecx, dword PTR linne1
mov edx, offset data
mov [edx], ecx
mov eax, 3

ret
testrun endp
end LibMain
Title: Re: problem with this code
Post by: EduardoS on October 28, 2006, 02:02:45 AM
You can't use OFFSET with local variables or parameters, use lea instead:

lea edx, data
Title: Re: problem with this code
Post by: Rainstorm on October 28, 2006, 03:48:01 AM
thanks for the info!
it assembled right now :)

Rainstorm.