The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Theidson on June 21, 2007, 10:35:01 AM

Title: error A2085
Post by: Theidson on June 21, 2007, 10:35:01 AM
Hello everyone,
Newbie question here:

getting the following error:
error A2085: instruction or register not accepted in current CPU mode

when assembling code with:
      .486
      .model flat, stdcall
      option casemap :none

on this instruction:
   MOVD      tX[ DI ], 0

using:
m32v9r
i.e.
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

anybody help ?
appologies if i'm asking an obvious question but i've tried all types of the MOVD, MOVQ instructions but to no avail

Title: Re: error A2085
Post by: Tedd on June 21, 2007, 11:44:09 AM
mov DWORD PTR tx[di],0

The instruction is always just "mov" - if you want/need to specify a size then that's separate (byte/word/dword; and annoyingly followed by 'ptr')
Title: Re: error A2085
Post by: hutch-- on June 21, 2007, 01:00:55 PM
I would like to know a bit more about what tX is and how its defined and I would like to see the context where you are using DI rather than the 32 bit EDI. Just make sure you are not trying to build 16 bit code or use 16 bit addressing in 32 bit mode which is what you have defined with,


      .486
      .model flat, stdcall
      option casemap :none
Title: Re: error A2085
Post by: MichaelW on June 21, 2007, 03:28:40 PM
Theidson,

MOVD and MOVQ are MMX instructions, so you need to use a .MMX (or .XMM) directive to enable the instruction set. The directive should follow option casemap :none, otherwise ML will recognize only upper case for the register names (MM0 but not mm0, etc.)

You cannot use a 16-bit register to store an address in 32-bit code, because such code uses 32-bit addresses.
Title: Re: error A2085
Post by: Theidson on June 22, 2007, 08:02:57 AM
tX was defined:
   tX                                  dd 16 dup(0)

the .mmx changed the error to:
error A2070: invalid instruction operands
on either
MOVD tx[ DI ], 0
MOVD tx[ EDI ], 0
MOVD tx[ EDI ], EAX

The instruction set ref. says:
"The source and destination operands can be general-purpose registers"
MOVD mm, r/m32   Move doubleword from r/m32 to mm.
MOVD r/m32,mm    Move doubleword from mm to r/m32

Yes 32-bit code is what I'm wanting to produce ultimately
Thank you for your suggestions so far
I suspect i have the syntax wrong somehow as its been a while since I did assembler, but really want to get back into it.
Title: Re: error A2085
Post by: Tedd on June 22, 2007, 12:05:32 PM
None of those involve mmx registers, so they're not mmx instructions - you're simply storing a general-purpose register, or constant value, into memory (indexed by edi).
MOVD is specifically for mmx, e.g. "movd MM0,eax", "movd tX[edi],MM0", etc
Title: Re: error A2085
Post by: Theidson on June 23, 2007, 06:29:57 AM
Yes, so if the instruction set ref. says:
"The source and destination operands can be general-purpose registers"
I should be able to use MOVED with normal registers shouldn't I ? or even MOVEQ ?
Title: Re: error A2085
Post by: Tedd on June 23, 2007, 02:06:22 PM
Well, no - if it doesn't involve an mmx register then it's not an mmx instruction. There are already general-purpose instructions for moving to/from/between general-purpose registers and memory.
The source can be a general purpose register, or the destination can be a general purpose register, but not both at the same time -- one must be an mmx register; ditto for memory.

MOVQ allows a different combination, which excludes general-purpose registers (but includes memory <-> mmx/xmm-register).