简体   繁体   English

如何获得汇编语言中字符的ASCII码?

[英]How to get ASCII code of an character in assembly language?

I need to enter a string and to show that string like array of ASCII codes. 我需要输入一个字符串并显示该字符串,例如ASCII码数组。 How can i implement it in assembly language. 我如何用汇编语言实现它。

In assembly language, characters are already encoded in ASCII (or unicode or whatever). 在汇编语言中,字符已经以ASCII(或unicode或其他)编码。 You work with characters as numbers. 您将字符用作数字。

What you need to be able to is to format numbers in their denary representation, for output. 您需要能够以数字的形式表示数字,以便输出。 This is not specific to character codes. 这不是特定于字符代码的。

There will almost certainly be library routines to do this, but it's not hard to do yourself. 几乎肯定会有库例程来执行此操作,但是自己做起来并不难。 Basically, you write a loop which repeatedly extracts the lowest digit from the number (by taking the residue of the number modulo 10 - look for a MOD instruction), converts that into the character code for a digit (by adding 48) and adds it to a buffer, then divides the number by 10 to move on to the next digit. 基本上,您编写了一个循环,该循环反复从数字中提取最低位数字(通过取模10的余数-查找MOD指令),将其转换为数字的字符代码(通过添加48)并将其相加到缓冲区,然后将数字除以10,即可移至下一位。 You repeat that until the number is zero. 重复该操作,直到数字为零。

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

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