转换成ASCII字符成十进制在大会为使用WriteConsoleA和readConsoleA

编程入门 行业动态 更新时间:2024-10-18 08:34:13
本文介绍了转换成ASCII字符成十进制在大会为使用WriteConsoleA和readConsoleA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我进退两难。我需要来自用户的输入数字,然后对输入进行算术运算。我现在只是一个初学者,现在为止我没有用任何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

本文发布于:2023-10-24 20:06:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524878.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换成   字符   大会   ASCII   成十进制

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!