如何使用yasm在MS Windows中写入控制台?

时间:2012-03-29 18:18:56

标签: windows console yasm

我尝试了这段代码(使用中断),但它适用于DOS:

mov eax, 42 ; write 42 to console
mov ecx, 10 ; in decimal
out_int_loop:
    xor edx, edx
    div ecx
    push eax
        add dl, '0' ; one digit 
        mov ah, 2 ; 2 is code for writing character
        int 21h
    pop eax
    cmp eax, 0
    jnz out_int_loop

1 个答案:

答案 0 :(得分:0)

我使用了来自winapi的WriteConsoleA函数。

我还使用GetStdHandle获取stdout

要导入此功能,您需要以下这些行:

extern  __imp__GetStdHandle@4
extern  __imp__WriteConsoleA@20