我正在學習一些彙編語言(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中。數據定義了一個字節?
編輯:
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
什麼平臺/操作系統? – kuba 2012-04-05 17:44:05
剛編輯原稿。 – Nogg 2012-04-05 17:47:34
這應該可以幫助你http://stackoverflow.com/questions/523185/a-simple-assembly-input-question – 2012-04-05 17:55:35