我进退两难。我需要来自用户的输入数字,然后对输入进行算术运算。我现在只是一个初学者,现在为止我没有用任何IO,除了它要求用户输入一个名称和打印输出,使用WriteConsoleA和ReadConsoleA程序。我找不到对谷歌的帮助,就如何ASCII字符转换为小数输入,以及如何以小数为ASCII码输出转换。我想preFER做到这一点使用任何的库函数之前手动。我想不出如何将单个字符转换为字符串,反之亦然。如何做到这一点?,是的,如果你写code的答案,如果可能的话,使用MASM语法,我不熟悉其他的汇编'语法。谢谢!!Devjeet
I am in a fix. I need to input numbers from the user and then perform arithmetic calculations on the input. I'm just a beginner now and till now I've not used any IO, except in a program which asks the user for a name and prints an output, using WriteConsoleA and ReadConsoleA. I couldn't find any help on google, on how to convert ascii characters to decimals for input and how to convert decimals to ascii for output. I'd prefer to do this manually before using any of the library functions. I can't figure how to convert a single character into a string and vice versa. How is this done? And yeah, if you write code in the answers, if, possible, use masm syntax as i am not familiar with the other assemblers' syntax. Thanks!! Devjeet
推荐答案如果你有这样的人31H小数,你可以再补充30H到每一个将它们转换为ASCII字符,如(AL = 31H):
If you have a decimal like 31h on al, you can just add 30h to each one to convert them to ASCII characters, like (AL = 31h):
mov cl,al shr al, 4 // now al = 03 add al,30h // now al = 33h, which if you output is the ASCII character '3'现在,你可以恢复人与移位4左边得到下一个'1',然后再添加30小时。我希望这说明了这一点:)
Now, you can restore al and shift left by 4 to get the next '1' and again add 30h. I hope this illustrates the point :)
更多推荐
转换成ASCII字符成十进制在大会为使用WriteConsoleA和readConsoleA
发布评论