Pregunta

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
¿Fue útil?

Solución

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top