开发者

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. How can i implement it in assembly language.


In assembly language, characters are already encoded in ASCII (or unicode or whatever). 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. You repeat that until the number is zero.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜