【发布时间】:2011-08-17 01:27:09
【问题描述】:
有一天我开始学习 ASM,我已经完成了一些教程,甚至成功地将教程内容修改为使用 jmp 和 cmp 等,而不是 MASM .if 和 .while 宏。
我决定先尝试写一些非常非常简单的东西,然后再继续学习更高级的教程。我正在写一个斐波那契数发生器。这是我到目前为止的来源:
.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 教程中的第一个示例,但这似乎完全不同 (?)。
【问题讨论】: