在程序集中增加起始打印地址

时间:2012-12-09 13:12:34

标签: assembly masm

我有以下代码:

mov   ecx, 0
mov   eax, offset ReadWritten
RottenApple:
    push ecx
    push eax

    push 0
    push eax
    push 1
    push offset bytearray
    push consoleOutHandle
    call WriteConsole

    pop eax
    pop ecx
    inc     ecx
    inc     eax
    cmp     ecx, 10
    jne     RottenApple

目的是打印,如果用户输入为“123456”,则为拳头1,然后是2等...但它只打印10个1。增加偏移量有什么不对,为什么它没有任何差异?

1 个答案:

答案 0 :(得分:0)

请注意,调用eax会破坏WriteConsole(它将包含返回值),因此您必须像保存ecx一样保存它。

<强>更新

仔细看,你用错误的参数调用WriteConsole。您想要增加偏移量,正如您在问题中所说,但您并没有这样做。 尝试类似:

    mov   ecx, 0
    mov   eax, offset bytearray
RottenApple:
    push ecx
    push eax

    push 0
    push offset ReadWritten
    push 1
    push eax
    push consoleOutHandle
    call WriteConsole

    pop eax
    pop ecx
    inc     ecx
    inc     eax
    cmp     ecx, 10
    jne     RottenApple
相关问题