News:

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

What's wrong with this MOV?

Started by frktons, August 03, 2010, 11:42:02 AM

Previous topic - Next topic

frktons

Hi.
I'm wondering why this MOV gives me an error during compilation:

    mov NumFmt.lpDecimalSep,  lpSep  ; Pointer to NULL terminated string with the decimal separator
    mov NumFmt.lpThousandSep, lpTsep ; Pointer to NULL terminated string with the thousand separator


error:

Microsoft (R) Macro Assembler Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Assembling: C:\masm32\examples\format_number2.asm
C:\masm32\examples\format_number2.asm(45) : error A2070:invalid instruction operands
C:\masm32\examples\format_number2.asm(46) : error A2070:invalid instruction operands
_
Assembly Error
. . .


and this version is accepted and works:

    mov NumFmt.lpDecimalSep,  offset Sep  ; Pointer to NULL terminated string with the decimal separator
    mov NumFmt.lpThousandSep, offset Tsep ; Pointer to NULL terminated string with the thousand separator


I define lpSep and lpTsep this way:

.data
    Sep         DB  ",",0
    lpSep       DD  Sep
    Tsep        DD  ".",0
    lpTsep      DD  Tsep 


and the input fields are defined:

    lpDecimalSep      DWORD      ?
    lpThousandSep     DWORD      ?

inside the NumFmt structure.  ::)



Mind is like a parachute. You know what to do in order to use it :-)

redskull

The first version is a memory-to-memory MOV (the value at the address 'lpSep' trying to be moved to the address of "NumFmt+lpDecimalSep').  The second way is proper (moving the address of Sep into the address of "NumFmt+lpDecimalSep'.  Or, alternatively, you could move lpSep into a register first.

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

frktons

Quote from: redskull on August 03, 2010, 11:47:48 AM
The first version is a memory-to-memory MOV (the value at the address 'lpSep' trying to be moved to the address of "NumFmt+lpDecimalSep').  The second way is proper (moving the address of Sep into the address of "NumFmt+lpDecimalSep'.  Or, alternatively, you could move lpSep into a register first.

-r

Woops!!! memory to memory.  :red
Thanks redskull  :U
Mind is like a parachute. You know what to do in order to use it :-)

Farabi

If you want to save bytes on moving memory to memory use push and pop instruction, or use M2M macro, but it slower compared to mov, if Im not mistaken.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

frktons

Quote from: Farabi on August 03, 2010, 01:33:59 PM
If you want to save bytes on moving memory to memory use push and pop instruction, or use M2M macro, but it slower compared to mov, if Im not mistaken.

Thanks Farabi. I know how to do it, but I forgot it in this occasion  :P
Mind is like a parachute. You know what to do in order to use it :-)