简体   繁体   English

在程序的irvine32中控制输入大小?

[英]Controlling of input size in irvine32 of assembly?

How can I limit the size of input when I was taking player name from user? 从用户那里获取玩家名称时,如何限制输入的大小? I am using like that: 我这样使用:

player1 byte 36 dup(' '),0

but when the player entered more than 36 characters, computer is giving alert sound and remain part is writing to part of player2 name. 但是当播放器输入了超过36个字符时,计算机将发出警报声,而剩余部分正在写入player2名称的一部分。

From: http://lcs.syr.edu/faculty/pease/handouts/CSE%20281/Irvine%20Programming%20Examples/Lib32/Irvine32_Library/Irvine32.asm 来自: 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
;--------------------------------------------------------`

So the answer is that you should set ECX to the maximum number of characters you are able to safely accept into your buffer, inclusive of the null. 因此,答案是您应该将ECX设置为可以安全地接收到缓冲区的最大字符数,包括null。 Perhaps you are not correctly setting that value - you could try manually making it artificially short such as 10 characters and verifying that it has an effect. 也许您没有正确设置该值-您可以尝试将其人工设置为简短字符(例如10个字符),然后验证其是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM