首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >装配irvine32中输入尺寸的控制?

装配irvine32中输入尺寸的控制?
EN

Stack Overflow用户
提问于 2013-05-24 04:09:08
回答 1查看 778关注 0票数 0

当我从用户那里获取玩家名字时,我如何限制输入的大小?我就是这样使用的:

代码语言:javascript
复制
player1 byte 36 dup(' '),0

但当玩家输入超过36个字符时,计算机发出警报声,剩余部分写入player2名称的一部分。

EN

回答 1

Stack Overflow用户

发布于 2013-05-24 06:19:39

来自:http://lcs.syr.edu/faculty/pease/handouts/CSE%20281/Irvine%20Programming%20Examples/Lib32/Irvine32_Library/Irvine32.asm

代码语言:javascript
复制
;--------------------------------------------------------
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个字符,并验证它是否有效。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16722988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档