ASM的未定义.data部分

问题描述 投票:0回答:1

当我试图编译这个ASM时,我收到了一个错误

Write an assembly program to implement the following. 
while X > 0
if  X != 3 AND (X > A OR X <B)
X = X –2
else
X = X –1
end while

使用短路评估 - 假设A,B和X是16位有符号整数变量 - 假设A = 9,B = 8,X = 11

我有.code区域,但我错过了.data?

.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

.data
     ; declare variables here
     X WORD ?

.code
main proc
     ; write your code here
     mov eax, X
     beginwhile:
     cmp eax, 0
     jng endwhile
     mov ebx,A
     mov ecx,B
     cmp X,3
     jne L1
     jmp L3
     jmp endwhile
L1:  
    cmp X, ebx
    jl L2
    cmp X,ecx
    jg L2
    jmp L3
    jmp endwhile
L2:
    mov X, X-2
    jmp endwhile
L3:
    mov X, X-1
    jmp endwhile
    endwhile:
    mov X, eax

    invoke ExitProcess,0
main endp
end main
visual-studio assembly x86 irvine32
1个回答
0
投票

由于这是用Visual Studio标记的,我假设正在使用MASM(ML.EXE),在这种情况下可以使用点指令,但我不确定这将是赋值的目标。点指令运算符需要可以转换为实际指令,因此不允许对内存进行内存比较。

但是,标题和问题询问了未初始化的数据部分,即.data?,并在此示例中显示。

        .data?
;                   ;for signed word, use sword instead of word
A       word    ?
B       word    ?
X       word    ?

        .code
;       ...    
        mov     ax,A
        mov     bx,B
        .while  (X > 0)
          .if     (X != 3) && (X > ax || X < bx)
            sub     X,2
          .else
            sub     X,1
          .endif
        .endw
;       ...    
© www.soinside.com 2019 - 2024. All rights reserved.