【发布时间】:2012-04-05 17:40:29
【问题描述】:
我正在学习一些汇编语言 (x86 Irvine.32 windows7),并且有一个关于如何从用户那里输入的问题。我所拥有的这本书并没有深入探讨它。我想提示用户:
myfirst BYTE "Welcome! This program calculates the sum of a list of numbers.", 0dh, 0ah, 0dh, 0ah ; greeting
BYTE "How many integers will be added? : "
那么用户将输入X。我如何读取用户输入的内容并将其放入变量中?
是不是就这么简单:
INVOKE ReadConsole, SomeVairable
SomeVairable 在 .data 中定义为一个字节的位置?
编辑:
INCLUDE Irvine32.inc
BufSize = 80
.data
buffer BYTE BufSize DUP(?)
stdInHandle HANDLE ?
bytesRead DWORD ?
myfirst BYTE "Welcome! This program calculates the sum of a list of numbers.", 0dh, 0ah, 0dh, 0ah ; greeting
BYTE "How many integers will be added? : "
mysecond BYTE "Please enter the "
.code
main PROC
mov edx, OFFSET myfirst ;move the location of myfirst into edx
call WriteString
; Get handle to standard input
INVOKE GetStdHandle, STD_INPUT_HANDLE
mov stdInHandle,eax
; Wait for user input
INVOKE ReadConsole, stdInHandle, ADDR buffer,
BufSize, ADDR bytesRead, 0
exit
main ENDP
END main
【问题讨论】:
-
@PavanManjunath:可能帮助不大——这是为 DOS 编写的,但这是为 Windows 编写的。从汇编语言级编程的角度来看,两者并没有太多共同点。
标签: winapi assembly x86 masm irvine32