@RedKate
Только учусь

Masm Ошибка error A2022: instruction operands must be the same size?

Задание занести в переменные значения a1=12 a2=17 a3=19 c1=15 c2=26. Произвести некоторые операции и вывести в окне MessageBox значение находящееся в регистре ecx. Вот мой код:

.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\masm32.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\masm32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data
    hello db "Hello", 0
    buffer db 128 dup(0)
    format db '%d',0
    result db 'ecx = %d and ebx = %d',0
    a1 dw 12
    a2 dw 17
    a3 dw 19
    c1 dw 15
    c2 dw 26

.code

start:
    

    ; eax = (a2-a1)*a3 = 95
    mov eax, [a2]
    mov ecx, [a1]
    sub eax, ecx
    mov ecx, [a3]
    mul ecx

    ; ecx = c1+c2 = 41

    mov ebx, [c1]
    mov ecx, [c2]
    add ecx, ebx

    ; ebx = a1+a2 = 29

    mov ebx, [a1]
    mov edx, [a2]
    add ebx, edx

    ; edx - shift arifm left a2 for 4

    mov edx, [a2]
    sal edx, 4

    ; while (ecx > -5){
    ;     rcx -= 3
    ;     if (ecx mod 2 != 0){
    ;         ebx += eax
    ;     }
    ; }

    mov edi, eax
    nwhile:
        cmp ecx, -5
        jnge afterwhile
        sub ecx, 3
        mov eax, ecx
        mov edx, 2
        div edx
        cmp edx, 0
        je afterif
        add ebx, edi
    afterif:
        jmp nwhile
        afterwhile:


    invoke wsprintf, offset buffer, offset format, ecx, ebx
    invoke MessageBoxA, NULL, offset buffer , ADDR hello , MB_OK
    invoke ExitProcess, 0

end start

При попытке компиляции .obj файла выдает такое:

counter.asm(31) : error A2022: instruction operands must be the same size
counter.asm(32) : error A2022: instruction operands must be the same size
counter.asm(34) : error A2022: instruction operands must be the same size
counter.asm(39) : error A2022: instruction operands must be the same size
counter.asm(40) : error A2022: instruction operands must be the same size
counter.asm(45) : error A2022: instruction operands must be the same size
counter.asm(46) : error A2022: instruction operands must be the same size
counter.asm(51) : error A2022: instruction operands must be the same size

Очевидно, что ошибка в занесении значений переменных в регистры, но что делать я так и не поняла.
  • Вопрос задан
  • 267 просмотров
Пригласить эксперта
Ответы на вопрос 1
Rsa97
@Rsa97
Для правильного вопроса надо знать половину ответа
eax - 32-битный регистр.
dw - 16-битное значение.
Логично, что они не the same size
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы