16位整数无符号数字,转换成ASCII字符串,以十六进制表示 [英] 16-bit integer unsigned number into an ASCII string representing the number in hex

查看:744
本文介绍了16位整数无符号数字,转换成ASCII字符串,以十六进制表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于组装(68hc11),这是在纸上处理的配件.

For Asembly (68hc11) This is an assigment to handle in paper.

编写一个程序,将16位整数无符号数字转换为以十六进制表示数字的ASCII字符串.数字在寄存器D0中,字符串从寄存器A0中的地址开始放入内存.

Write a program to convert a 16-bit integer unsigned number into an ASCII string representing the number in hexadecimal. The number is in register D0 and the string is in put in memory starting at the address in register A0.

我如何将位数分为4位以表示汇编中的十六进制数,是否有说明? 我在可视化程序逻辑时也遇到了问题.分离了四位后,我如何使程序集将其转换为十六进制?当我得到十六进制字符时,我需要将其与每个可能的ASCII字符进行比较??

How can i separated the bit number into 4 bits to represent the hex number in assembly, is there an instruction for doing this? I have a problem to visualize the logic of the program, also. After separated the four bits how do i make the assembly to convert it to hex?? And to when I get the hex characters I need to compare them to each ascii possible character??

我真的不知道从哪里开始.

I really dont know where to start.

推荐答案

您可以使用按位移位和掩码将每个十六进制数字的4位分开.然后,您可以使用查找表将它们映射到ascii,或者使用0-9和A-F在字符表中是连续的事实.

You can use bitwise shift and masking to separate the 4 bits for each hex digit. Then you can use a lookup table to map them to ascii, or use the fact that 0-9 and A-F are consecutive in the character table.

这篇关于16位整数无符号数字,转换成ASCII字符串,以十六进制表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆