[英]Controlling of input size in irvine32 of assembly?
從用戶那里獲取玩家名稱時,如何限制輸入的大小? 我這樣使用:
player1 byte 36 dup(' '),0
但是當播放器輸入了超過36個字符時,計算機將發出警報聲,而剩余部分正在寫入player2名稱的一部分。
來自: http : //lcs.syr.edu/faculty/pease/handouts/CSE%20281/Irvine%20Programming%20Examples/Lib32/Irvine32_Library/Irvine32.asm
;--------------------------------------------------------
ReadString PROC
LOCAL bufSize:DWORD, saveFlags:DWORD, junk:DWORD
;
; Reads a string from the keyboard and places the characters
; in a buffer.
; Receives: EDX offset of the input buffer
; ECX = maximum characters to input (including terminal null)
; Returns: EAX = size of the input string.
; Comments: Stops when Enter key (0Dh,0Ah) is pressed. If the user
; types more characters than (ECX-1), the excess characters
; are ignored.
; Written by Kip Irvine and Gerald Cahill
;
; Last update: 11/19/92, 03/20/2003
;--------------------------------------------------------`
因此,答案是您應該將ECX設置為可以安全地接收到緩沖區的最大字符數,包括null。 也許您沒有正確設置該值-您可以嘗試將其人工設置為簡短字符(例如10個字符),然后驗證其是否有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.