문제

I've made a program in Assembly that should reverse a string like "Was it a rat I saw?" but I can't seem to figure out what the error means: "Use square brackets to address memory, ADDR or OFFSET to get address:- Mov handle, [dest + ebx]." Any idea what this means? Thanks!

.Data

hInst   DD      NULL
src     DB      "Was it a rat I saw?         ", 0DH, 0AH
ssize   DD      ($ - src)
dest    DB      "...................         ", 0DH, 0AH
handle  DD      NULL

.Code

start:
    Invoke GetModuleHandle, NULL
    Invoke GetStdHandle, STD_OUTPUT_HANDLE
    Mov [hInst], Eax
    Call Main
    Invoke ExitProcess, Eax

Main:

    Xor Eax, Eax
    Ret

L1:
    Mov Ecx, [ssize]
    Mov Ebx, 0

L2:
    Mov Al, [src + Ebx]
    Mov [dest + Ebx], Al
    Mov handle, [dest + Ebx]
    Invoke WriteConsole, [handle]
    Inc Ebx
    Loop L2
도움이 되었습니까?

해결책

You cannot move data from one memory location to another in a single instruction. The address modes of the CPU doesn't allow that.

Instead try

mov EAX, [dest + EBX]
mov [handle], EAX
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top