Ассемблер error a2070 invalid instruction operands

I'm newbie in Win32 Assembly: I learn code this program, it's Window simple. But I get the error: error a2070 invalid instruction operands (MASM) I have searched on google about this error, bu...

I’m newbie in Win32 Assembly:

I learn code this program, it’s Window simple. But I get the error:

error a2070 invalid instruction operands (MASM)

I have searched on google about this error, but I still don’t understand.

.386
.model flat, stdcall
option casemap:none

include masm32includewindows.inc
include masm32includekernel32.inc
include masm32includeuser32.inc
includelib masm32libkernel32.lib
includelib masm32libuser32.lib

WinMain PROTO :HINSTANCE, :HINSTANCE, :LPSTR, :DWORD

.data
    AppName     db "First Windows", 0
    ClassName   db "Window Class", 0

.data?
    hInstance   dd ?
    CommandLine dd ?

.code
start:
    invoke  GetModuleHandle, NULL
    MOV     hInstance, EAX
    invoke  GetCommandLine
    MOV     CommandLine, EAX
    invoke  WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
    invoke  ExitProcess, EAX

    WinMain PROC ahInstance:HINSTANCE, 
            ahPrevInstance:HINSTANCE, 
            aCommandLine:LPSTR, 
            aCommandShow:DWORD
        LOCAL   wc:WNDCLASSEX
        LOCAL   hwnd:HANDLE
        LOCAL   msg:MSG

        MOV     wc.cbSize, SIZEOF WNDCLASSEX
        MOV     wc.style, CS_HREDRAW or CS_VREDRAW
        MOV     wc.lpfnWndProc, offset WndProc
        MOV     wc.cbClsExtra, NULL
        MOV     wc.cbWndExtra, NULL
        MOV     wc.hInstance, hInstance ;;;;;;;;;;;;;;;; Error here

        invoke  LoadIcon, NULL, IDI_APPLICATION
        MOV     wc.hIcon, EAX
        MOV     wc.hIconSm, EAX
        invoke  LoadCursor, NULL, IDC_ARROW
        MOV     wc.hCursor, EAX
        MOV     wc.hbrBackground, COLOR_WINDOW+1
        MOV     wc.lpszMenuName, NULL
        MOV     wc.lpszClassName, offset ClassName

        invoke  RegisterClassEx, addr wc

        invoke  CreateWindowEx, NULL, addr ClassName, addr AppName, 
                WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 
                CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, ahInstance, NULL
        MOV     hwnd, EAX

        invoke  ShowWindow, hwnd, SW_SHOWNORMAL
        invoke  UpdateWindow, hwnd

        .WHILE TRUE
            invoke  GetMessage, addr msg, NULL, 0, 0
            .BREAK .IF (!EAX)
            invoke  TranslateMessage, addr msg
            invoke  DispatchMessage, addr msg
        .ENDW

        MOV EAX, msg.wParam
        RET
    WinMain endp

    WndProc PROC ahWnd:HWND, aMsg:DWORD, awParam:WPARAM, alParam:LPARAM
        .IF aMsg == WM_DESTROY
            invoke  PostQuitMessage, NULL
        .ELSE
            invoke  DefWindowProc, ahWnd, aMsg, awParam, alParam
            ret
        .ENDIF
        XOR EAX, EAX
        ret
    WndProc endp
end start

That line:

MOV     wc.hInstance, hInstance

gets an error, I replace by:

PUSH hInstance
POP  wc.hInstance

—> this is OK.

But I don’t understand WHY ???

Anyone can help me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
.386
.model flat, stdcall
option  casemap:none     
 
include ..INCLUDEwindows.inc             
;include ..INCLUDEcomctl32.inc
;include ..INCLUDEFpu.inc
;include ..INCLUDEuser32.inc
include ..INCLUDEkernel32.inc                         
;includelib ..LIBcomctl32.lib       
;includelib ..LIBFpu.lib
;includelib ..LIBuser32.lib
includelib ..LIBkernel32.lib
 
ExitProcess proto :DWORD
GetStdHandle proto :DWORD
WriteConsoleA proto :DWORD, :DWORD, :DWORD, :DWORD, :DWORD 
ReadConsoleA proto :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
 
.stack 256
.data
 
m1 db  2,12,4,1,7,10,11,6,8,5,3,15,13,0,14,9
m2 db  14,11,2,12,4,7,13,1,5,0,15,10,3,9,8,6
m3 db  4,2,1,11,10,13,7,8,15,9,12,5,6,3,0,14
m4 db  11,8,12,7,1,14,2,13,6,15,0,9,10,4,5,3
 
ar1 db 6 dup(?)
ar2 db ?
ar3 db 4 dup(?)
per db ?        ;выходное значение
 
STD_INPUT_HANDLE    equ -10 ;winbase.h
STD_OUTPUT_HANDLE   equ -11
 
stdout dd ?
stdin dd ?                      
cWritten dd ?
msg1 db 'Vvedi 6-bit', 0dh, 0ah
msg4 db 'STROKA ' , 0dh, 0ah
msg3 db 'Vy vveli chislo: ',0dh, 0ah
msg5 db 'STOLBEC ' , 0dh, 0ah
msg6 db 'POLUCHENNOE CHISLO:    ' , 0dh, 0ah
 
 
 
.code
start:
invoke GetStdHandle, STD_OUTPUT_HANDLE 
    mov stdout, eax
invoke GetStdHandle, STD_INPUT_HANDLE 
    mov stdin, eax
    invoke  WriteConsoleA, stdout, ADDR msg1, sizeof msg1,  ADDR cWritten, 0
    invoke  ReadConsoleA,   stdin,  ADDR ar1, sizeof ar1, ADDR cWritten,0
 
    invoke  WriteConsoleA, stdout, ADDR msg3, sizeof msg3,  ADDR cWritten, 0
 
    invoke  WriteConsoleA, stdout, ADDR ar1, sizeof ar1,  ADDR cWritten, 0
 
    invoke  WriteConsoleA, stdout, ADDR msg4, sizeof msg4,  ADDR cWritten, 0
xor esi,esi
xor edi,edi
xor ebx,ebx
xor ebp,ebp
lea esi,ar1     ;массив
lea edi,ar2     ;строка
lea ebx,ar3     ;столбец
xor edx,edx         ;обнуление edx
mov ecx,6
sicle: 
.if(esi==0)
mov eax,2
mov edx,[esi]       ;помещаю в edx число с массива 1 
mul edx
add [edi],eax
;add ebp,[edi]
xor eax,eax
inc esi     
.elseif(esi==1)
add eax,1
mov edx,[esi]       ;помещаю в edx число с массива 1 
mul edx
add [ebx],eax
xor eax,eax
inc esi     
.elseif(esi==2)
add eax,2
mov edx,[esi]       ;помещаю в edx число с массива 1 
mul edx
add [ebx],eax
xor eax,eax
inc esi     
.elseif(esi==3)
add eax,4
mov edx,[esi]       ;помещаю в edx число с массива 1 
mul edx
add [ebx],eax
xor eax,eax
inc esi     
.elseif(esi==4)
add eax,8
mov edx,[esi]       ;помещаю в edx число с массива 1 
mul edx
add [ebx],eax
xor eax,eax
inc esi     
.elseif(esi==5)
add eax, 1
mov edx,[esi]       ;помещаю в edx число с массива 1 
mul edx
add [edi],eax
xor eax,eax
;add ebp,[edi]
inc esi     ;переход на последний элемент
.endif
LOOP sicle
mov ar2,edi     ;строка
mov ar3,ebx     ;столбец
    invoke  WriteConsoleA, stdout, ADDR ar2, 2,  ADDR cWritten, 0
 
    invoke  WriteConsoleA, stdout, ADDR msg5, sizeof msg5,  ADDR cWritten, 0
 
    invoke  WriteConsoleA, stdout, ADDR ar3, sizeof ar3,  ADDR cWritten, 0
 
    
    invoke ExitProcess, 0 
end start

Содержание

  1. Error a2070 invalid instruction operands как исправить
  2. Answered by:
  3. Question
  4. Answers
  5. Русские Блоги
  6. Процесс установки OpenSSL и решения ошибок под Windows
  7. Примечание. Этот тест прошел успешно в версии WIN10 64 VS2012 openssl-1.0.2o. Другие условия не гарантируют успеха. Если возникнут вопросы, обращайтесь к блогеру. Брат попробуй помочь решить это.
  8. Русские Блоги
  9. Процесс установки OpenSSL и решения ошибок под Windows
  10. Примечание. Этот тест прошел успешно в версии WIN10 64 VS2012 openssl-1.0.2o. Другие условия не гарантируют успеха. Если возникнут вопросы, обращайтесь к блогеру. Брат попробуй помочь решить это.

Error a2070 invalid instruction operands как исправить

Answered by:

Question

Answers

The thing I would suggest is use the size descriptors for the first operand.

movlps qword ptr [rdx], xmm7

Because you are dereferencing a memory location (that is what the [] does, it says to access the memory location specified in rdx) the assembler doesn’t know the size of the memory block you are pointing to. So you have to give the assembler the size of this memory location. The qword ptr tells it that it is pointing to a qword block of memory (that is quad word or 8 byte, which is the same size as half of xmm7).

A similar thing is true for movss. Except that in this case you would need to use dword ptr instead of qword ptr. So modify this line to.

movss dword ptr [rdx+8], xmm6

Oh, and if you are going to give a sample please make sure that it will give only the problem you describe. Your sample will actually give two more errors. The first is on the line

and the second is on the line

This is because test is an instruction and instructions take priority over identifiers. So instead of seeing the proc and thinking test is a name of a procedure, it will see test think that it is an instruction and expect two valid parameters for it.

Источник

Русские Блоги

Процесс установки OpenSSL и решения ошибок под Windows

Есть два способа использовать OpenSSL под Windows:
1. Непосредственно загрузите установочный пакет, скомпилированный другими:http://slproweb.com/products/Win32OpenSSL.html
2. Скомпилируйте и установите самостоятельно:
1. Загрузите и установите perl.
http://www.activestate.com/activeperl/downloads/
2. Установка и настройка:
напрямую запустите установочный файл (например: ActivePerl-5.16.3.1604-MSWin32-x86-298023.msi), чтобы завершить установку; процесс установки автоматически завершит настройку переменных среды (после завершения установки Вы можете увидеть каталог bin Perl в переменных системной среды (например: добавлен C: Program Files perl site bin;)), настраивать вручную не нужно;
3. Проверьте успешность установки:
Войдите, например, в папку каталога установки perl и выполните «perl example.pl». Если отображается «Привет от ActivePerl!», это означает, что установка Perl прошла успешно. Как показано ниже:

После успешной установки Perl вы можете начать использовать связанные с Perl команды для установки OpenSSL.
4. OpenSSL может загрузить исходный код и скомпилировать его самостоятельно, либо вы можете напрямую загрузить установочный пакет и использовать его после установки.
5. Используйте исходный код для компиляции openssl
1) Путь для загрузки исходного кода openssl:
http://www.openssl.org/source/
2) Настройте переменные среды VS2012 (потому что инструмент nmake, поставляемый с vs2012, будет использоваться при компиляции openssl позже).
Запустите файл vcvars32.bat в каталоге bin VS2012 (например, E: Visuol Studio 2012 VC bin), чтобы завершить настройку. Mine не отображается из-за конфигурации. . Больше никаких скриншотов.
3) Настройте openssl
Ниже приводится метод настройки OpenSSL, который я нашел в Интернете, здесь я свяжу его:https://blog.csdn.net/houjixin/article/details/25806151



Я последовал его методу, и было две ошибки:
1.

2.

Чтобы найти решение, потребовалось много усилий,
Решение первой ошибки: отключить сборку

Второе решение ошибки: оно находится на официальном сайте openssl, метод — отключить IPV6.
может относиться к:http://rt.openssl.org/Ticket/Display.html?id=2097&user=guest&pass=guest

В конце концов я изменил его на:

Я очень рад быть здесь, компилировал и компилировал, а значит, успешно, duangduangduang, результат появился:


Это очень больно, но я все равно не сдавался. Думаю, решить эту проблему нетрудно. Позже я нашел такую ​​статью на Baidu:https://blog.csdn.net/mfcing/article/details/43059105, На самом деле это не имеет отношения к этой ошибке, но я видел такой код:

Мне было интересно, связано ли это с моей предыдущей компиляцией? Я постучал:

Кисть и кисть. . . . . . . . . . Ждал больше минуты . наконец!

Я снова выполнил тест nmake -f ms ntdll.mak и проверил его.

Примечание. Этот тест прошел успешно в версии WIN10 64 VS2012 openssl-1.0.2o. Другие условия не гарантируют успеха. Если возникнут вопросы, обращайтесь к блогеру. Брат попробуй помочь решить это.

Источник

Русские Блоги

Процесс установки OpenSSL и решения ошибок под Windows

Есть два способа использовать OpenSSL под Windows:
1. Непосредственно загрузите установочный пакет, скомпилированный другими:http://slproweb.com/products/Win32OpenSSL.html
2. Скомпилируйте и установите самостоятельно:
1. Загрузите и установите perl.
http://www.activestate.com/activeperl/downloads/
2. Установка и настройка:
напрямую запустите установочный файл (например: ActivePerl-5.16.3.1604-MSWin32-x86-298023.msi), чтобы завершить установку; процесс установки автоматически завершит настройку переменных среды (после завершения установки Вы можете увидеть каталог bin Perl в переменных системной среды (например: добавлен C: Program Files perl site bin;)), настраивать вручную не нужно;
3. Проверьте успешность установки:
Войдите, например, в папку каталога установки perl и выполните «perl example.pl». Если отображается «Привет от ActivePerl!», это означает, что установка Perl прошла успешно. Как показано ниже:

После успешной установки Perl вы можете начать использовать связанные с Perl команды для установки OpenSSL.
4. OpenSSL может загрузить исходный код и скомпилировать его самостоятельно, либо вы можете напрямую загрузить установочный пакет и использовать его после установки.
5. Используйте исходный код для компиляции openssl
1) Путь для загрузки исходного кода openssl:
http://www.openssl.org/source/
2) Настройте переменные среды VS2012 (потому что инструмент nmake, поставляемый с vs2012, будет использоваться при компиляции openssl позже).
Запустите файл vcvars32.bat в каталоге bin VS2012 (например, E: Visuol Studio 2012 VC bin), чтобы завершить настройку. Mine не отображается из-за конфигурации. . Больше никаких скриншотов.
3) Настройте openssl
Ниже приводится метод настройки OpenSSL, который я нашел в Интернете, здесь я свяжу его:https://blog.csdn.net/houjixin/article/details/25806151



Я последовал его методу, и было две ошибки:
1.

2.

Чтобы найти решение, потребовалось много усилий,
Решение первой ошибки: отключить сборку

Второе решение ошибки: оно находится на официальном сайте openssl, метод — отключить IPV6.
может относиться к:http://rt.openssl.org/Ticket/Display.html?id=2097&user=guest&pass=guest

В конце концов я изменил его на:

Я очень рад быть здесь, компилировал и компилировал, а значит, успешно, duangduangduang, результат появился:


Это очень больно, но я все равно не сдавался. Думаю, решить эту проблему нетрудно. Позже я нашел такую ​​статью на Baidu:https://blog.csdn.net/mfcing/article/details/43059105, На самом деле это не имеет отношения к этой ошибке, но я видел такой код:

Мне было интересно, связано ли это с моей предыдущей компиляцией? Я постучал:

Кисть и кисть. . . . . . . . . . Ждал больше минуты . наконец!

Я снова выполнил тест nmake -f ms ntdll.mak и проверил его.

Примечание. Этот тест прошел успешно в версии WIN10 64 VS2012 openssl-1.0.2o. Другие условия не гарантируют успеха. Если возникнут вопросы, обращайтесь к блогеру. Брат попробуй помочь решить это.

Источник

  • Remove From My Forums
  • Question

  • when compiling this in ml64.exe 64bit (masm64)

    the SSE command give me an error

    what do i need to do to include the SSE commands in 64 bit?

     

       
    .code

    foo PROC

    movlps [rdx], xmm7 ;;error A2070: invalid instruction operands
    movhlps xmm6, xmm7
    movss [rdx+8], xmm6 ;;rror A2070: invalid instruction operands
    ret

    foo ENDP

    end

    i get the error:

     

       1>Performing Custom Build Step
    1> Assembling: extasm.asm
    1>extasm.asm(6) : error A2070: invalid instruction operands
    1>extasm.asm(10) : error A2070: invalid instruction operands
    1>Microsoft (R) Macro Assembler (x64) Version 8.00.50727.215
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1>Project : error PRJ0019: A tool returned an error code from "Performing Custom Build Step"

    • Edited by

      Monday, March 15, 2010 6:00 PM

Answers

  • The thing I would suggest is use the size descriptors for the first operand.

    movlps qword ptr [rdx], xmm7

    Because you are dereferencing a memory location (that is what the [] does, it says to access the memory location specified in rdx) the assembler doesn’t know the size of the memory block you are pointing to. So you have to give the assembler the size of this memory location. The qword ptr tells it that it is pointing to a qword block of memory (that is quad word or 8 byte, which is the same size as half of xmm7).

    A similar thing is true for movss. Except that in this case you would need to use dword ptr instead of qword ptr. So modify this line to.

    movss dword ptr [rdx+8], xmm6

    Oh, and if you are going to give a sample please make sure that it will give only the problem you describe. Your sample will actually give two more errors. The first is on the line

    test PROC

    and the second is on the line

    test ENDP

    This is because test is an instruction and instructions take priority over identifiers. So instead of seeing the proc and thinking test is a name of a procedure, it will see test think that it is an instruction and expect two valid parameters for it.

    *Edit*

    Also, please don’t post in multpile forums.
    Duplicate http://social.msdn.microsoft.com/Forums/en-GB/vcgeneral/thread/4f473acb-7b14-4bf4-bed3-e5e87e1f81e7


    Visit my (not very good) blog at http://c2kblog.blogspot.com/

    • Marked as answer by
      _Green_
      Tuesday, March 16, 2010 7:38 AM

Topic: Don’t understand why mov instruction gives an invalid operand error  (Read 16004 times)

mrBean

Hi,  I am learning Assembly language using Jeff Dunterman’s Assembly Language Step by Step book. 

I am trying out a 16 bit real mode flat model assembly program using MASM32 in Win XP.

The code is:

.286
.MODEL TINY
.DATA               ; Initialised data section
eatmsg   db  «Eat at Joe’s!», 13, 10, «$»    ;message to display             

.CODE               ; Code section
start:

    mov dx, eatmsg  ; Mem data ref without [] loads the address
    mov ah, 9       ; Function 9 displays text to standard output
    int 21H         ; Call DOS

    mov ax, 04C00H  ; DOS function to exit the program
    int 21H         ; Return control to DOS

end start

When I assembled the file, I got the following message:
error A2070: invalid instruction operands

The error refers to the mov dx, eatmsg statement.  What is wrong with the operand that causes the error message to appear?

Also, there is a warning:
warning A4023: with /coff switch, leading underscore required for start address : start

I saw other code examples which use the start label so I am not sure what is the cause of the warning?


Logged


    mov dx, offset eatmsgwithout the «offset» operator, it tries to load the first WORD of the string into DX
because the string is defined as BYTE type and DX is a WORD — the error occurs


Logged


Also, there is a warning:
warning A4023: with /coff switch, leading underscore required for start address : start

I saw other code examples which use the start label so I am not sure what is the cause of the warning?

it’s odd that i don’t recall seeing that one   :biggrin:
as it happens, i have always used a «_main» PROC as the entry point (an old C compiler standard)

        .MODEL  Tiny
        .386
        OPTION  CaseMap:None

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

        .CODE

;************************************************************************************

        ORG     100h

_main   PROC    NEAR

        mov     dx,offset s$Msg
        mov     ah,9
        int     21h

        mov     ax,4C00h
        int     21h

_main   ENDP

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

s$Msg   db 'Hello World !',0Dh,0Ah,24h

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

        END     _main


i have also never used a .DATA section with a TINY model program
but — that is nice, if it works

when it’s all said and done, a couple rules for a TINY model are:
all code and data must fall within a single 64 KB segment
the program loader uses the first 256 bytes of the segment for the PSP, Program Segment Prefix
so, the first byte of the .COM program must be ORG’ed at 100h
and it is always where execution begins

it’s likely that the linker combines .DATA at the end of the code segment


Logged


Hi,

   Doing a search on «Jeff Dunterman’s Assembly Language Step
by Step book.», I got a description that says it uses the NASM
assembler.  That makes your comment «; Mem data ref without
[] loads the address» correct.  However the error message
numbers seem to imply you are trying to use MASM as your
assembler.  So you would have to use OFFSET as Dave says.

   NASM and MASM use different, though similar, syntax.

Regards,

Steve N.


Logged


oh…
and, use the /COFF switch when assembling 32-bit code
this is 16-bit code — you want the /OMF switch (which is the default, so no switch)
that also means you need to use a 16-bit linker
in the masm32 pacakge, i believe it’s named Link16.exe


Logged


Ассемблер error a2070 invalid instruction operands

Answered by:

Question

Answers

The thing I would suggest is use the size descriptors for the first operand.

movlps qword ptr [rdx], xmm7

Because you are dereferencing a memory location (that is what the [] does, it says to access the memory location specified in rdx) the assembler doesn’t know the size of the memory block you are pointing to. So you have to give the assembler the size of this memory location. The qword ptr tells it that it is pointing to a qword block of memory (that is quad word or 8 byte, which is the same size as half of xmm7).

A similar thing is true for movss. Except that in this case you would need to use dword ptr instead of qword ptr. So modify this line to.

movss dword ptr [rdx+8], xmm6

Oh, and if you are going to give a sample please make sure that it will give only the problem you describe. Your sample will actually give two more errors. The first is on the line

and the second is on the line

This is because test is an instruction and instructions take priority over identifiers. So instead of seeing the proc and thinking test is a name of a procedure, it will see test think that it is an instruction and expect two valid parameters for it.

Источник

Ассемблер error a2070 invalid instruction operands

Asked by:

Question

ml64.exe gave an error A2070: invalid instruction operands.

This instruction worked in Linux. What’s wrong here? Thanks.

All replies

Welcome to MSDN forums! Thank you for your question.

We’re doing research on this issue. It might take some time before we get back to you.

Have you check instruction reference here: http://msdn.microsoft.com/en-us/library/x8zs5twb.aspx, you may find correct syntax from this page.

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

movq rax, 0x00ff00ff00ff00ff

has «error A2206: missing operator in expression». While it works in Linux.

Just because it works on Linux doesn’t mean it is right.

Reading the Intel instruction reference in the Intel Software Developer’s Manual volume 2A, the MOVQ has 4 forms

MOVQ mm, mm/m64 Move quadword from mm/m64 to mm.
MOVQ mm/m64, mm Move quadword from mm to mm/m64.
MOVQ xmm1, xmm2/m64 Move quadword from xmm2/mem64 to xmm1.
MOVQ xmm2/m64, xmm1 Move quadword from xmm1 to xmm2/mem64.

So what this mean is your first one is invalid because it is going from a general purpose register, even if it is a 64 bit one. The second one is invalid because it is a literal going to a general purpose register. The second one also has the problem of in ML64, hexadecimal numbers are written as 1234567890h not 0x1234567890.

As to why it works on Linux, who knows. Maybe the assembler is doing something like injecting instructions to make it work, like

Источник

Ассемблер error a2070 invalid instruction operands

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I have an existing .asm code file in 32 bit, now I need to support for x64, but I get a lot of error when compile with ml64.exe in visual studio:

error A2070: invalid instruction operands
error A2008: syntax error : VirtualProtect
error A2070: invalid instruction operands
fatal error A1010: unmatched block nesting : unlockAddress

Could you advise me what I should do? There is no error when compile in x86.

Answers

«Since I am not good in Assembly, could you please advise me the easy way to port this asm file to support x64?»

I’m not sure what advice can I give you apart from «well, you need to learn x86 and x64 assembly». Depending on the complexity of the existing code this might somewhat easy or quite complex.

For example I noticed that you seem to have a function named «getStackFrame». Such a function not only needs to be converted to x64 assembly but it also needs to be updated to take into account differences in stack frame handling between win32 and win64.

All replies

Sorry that the code can not be public anyway. Below is some line of code in the file:

.586
.MODEL FLAT, STDCALL

PUBLIC unlockAddress
PUBLIC _invoke
PUBLIC _initialize
PUBLIC _getStackFrame
PUBLIC _validateCallee
PUBLIC _isValidInstructions
PUBLIC _getStackFrame

VirtualProtect PROTO STDCALL _address:DWORD,_size:DWORD,_newValue:DWORD,_pOldValue:DWORD
FlushInstructionCache PROTO STDCALL handle:DWORD, pAddress:DWORD,dataSize:DWORD
GetCurrentProcess PROTO STDCALL

error A2008: syntax error : .
error A2008: syntax error : .
error A2008: syntax error : FS
error A2008: syntax error : _address

Could you please advise? Is there any tutorial that show the way to modify existing 32 bit assembly code to support x64?

«Is there any tutorial that show the way to modify existing 32 bit assembly code to support x64?»

Not that I know of. In general it’s a lot of work despite the similarity between x86 and x64 instructions. Couple of things:

  • in your example .586, .model flat, stdcall and assume fs:nothing must go, they are not needed/supported
  • the STDCALL after PROTO must go to, x64 has only one calling convention vs. x86’s 3 calling conventions
  • PROTO is supported but INVOKE is not, if you use INVOKE to call those functions you’ll have to change the code to pushes and calls
  • all pointers are 64 bit so whenever you have pointers in your code you need to change 32 bit registers to 64 bit registers (eax -> rax) and dword to qword (for example the address argument of VirtualProtect is a pointer so it must be qword instead of dword)

Источник

Ассемблер error a2070 invalid instruction operands

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I have an existing .asm code file in 32 bit, now I need to support for x64, but I get a lot of error when compile with ml64.exe in visual studio:

error A2070: invalid instruction operands
error A2008: syntax error : VirtualProtect
error A2070: invalid instruction operands
fatal error A1010: unmatched block nesting : unlockAddress

Could you advise me what I should do? There is no error when compile in x86.

Answers

«Since I am not good in Assembly, could you please advise me the easy way to port this asm file to support x64?»

I’m not sure what advice can I give you apart from «well, you need to learn x86 and x64 assembly». Depending on the complexity of the existing code this might somewhat easy or quite complex.

For example I noticed that you seem to have a function named «getStackFrame». Such a function not only needs to be converted to x64 assembly but it also needs to be updated to take into account differences in stack frame handling between win32 and win64.

All replies

Sorry that the code can not be public anyway. Below is some line of code in the file:

.586
.MODEL FLAT, STDCALL

PUBLIC unlockAddress
PUBLIC _invoke
PUBLIC _initialize
PUBLIC _getStackFrame
PUBLIC _validateCallee
PUBLIC _isValidInstructions
PUBLIC _getStackFrame

VirtualProtect PROTO STDCALL _address:DWORD,_size:DWORD,_newValue:DWORD,_pOldValue:DWORD
FlushInstructionCache PROTO STDCALL handle:DWORD, pAddress:DWORD,dataSize:DWORD
GetCurrentProcess PROTO STDCALL

error A2008: syntax error : .
error A2008: syntax error : .
error A2008: syntax error : FS
error A2008: syntax error : _address

Could you please advise? Is there any tutorial that show the way to modify existing 32 bit assembly code to support x64?

«Is there any tutorial that show the way to modify existing 32 bit assembly code to support x64?»

Not that I know of. In general it’s a lot of work despite the similarity between x86 and x64 instructions. Couple of things:

  • in your example .586, .model flat, stdcall and assume fs:nothing must go, they are not needed/supported
  • the STDCALL after PROTO must go to, x64 has only one calling convention vs. x86’s 3 calling conventions
  • PROTO is supported but INVOKE is not, if you use INVOKE to call those functions you’ll have to change the code to pushes and calls
  • all pointers are 64 bit so whenever you have pointers in your code you need to change 32 bit registers to 64 bit registers (eax -> rax) and dword to qword (for example the address argument of VirtualProtect is a pointer so it must be qword instead of dword)

Источник

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Ассасин крид юнити ошибка msvcp100 dll
  • Ассасин крид синдикат ошибка msvcp110 dll
  • Ассасин крид синдикат ошибка msvcp100 dll
  • Ассасин крид синдикат ошибка 0xc000007b
  • Ассасин крид одиссея ошибки прошлого

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии