我有一天学习ASM并且我做了一些教程,甚至成功修改了教程内容以使用jmp和cmp等代替MASM .if和.while宏 .
在继续学习更高级的教程之前,我决定尝试编写一些非常非常简单的东西 . 我正在写一个Fibonacci数字生成器 . 这是我到目前为止的来源:
.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.code
start:
mov eax, 1
mov ecx, 1
_a:
push eax
add eax, ecx
pop ecx
; Jump to _b if there is an overflow on eax
; Print Values Here
jmp _a
_b:
push 0
call ExitProcess
end start
我打算检查eax / ecx上的溢出,但是现在我只想在屏幕上显示eax / ecx的值 .
我知道如何从.data中推送常量字符串的地址并调用StdOut,这是hello world教程中的第一个示例,但这看起来完全不同(?) .
1 回答
这个代码由Microsoft自己提供
http://support.microsoft.com/kb/85068
请注意,此代码在16位系统上输出AX寄存器 . 但是你可以得到这个想法,你只需要通过循环遍历每个字符将AX值转换为ASCII字符 . 跳过中断部分并使用StdOut功能 .
在这里也看到:
http://www.masm32.com/board/index.php?PHPSESSID=fa4590ba57dbaad4bc44088172af0b49&action=printpage;topic=14410.0