有没有办法在汇编中将char转换为其ASCII值?

时间:2019-04-21 01:18:28

标签: assembly arm

我需要在arm汇编中获取char的ASCII值,最好是十六进制格式。 例如,如果char为'a',则我的程序需要输出0x61。 我找到的最接近的东西是在C中进行类型转换,其中

int x = 'a';

似乎可以解决问题。手臂上有类似的东西吗? 谢谢

1 个答案:

答案 0 :(得分:1)

大多数汇编程序都支持ASCII字符文字,例如 public static string encryptionMethod(string Text, string key) { string encryptedText = string.Empty; try { byte[] clearBytes = StringToByteArray(Text); ;//Encoding.UTF8.GetBytes(Text); TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); des.KeySize = 128; des.Mode = CipherMode.CBC; des.Padding = PaddingMode.None; des.Key = StringToByteArray(key); //Passing key in byte array //des.BlockSize = 64; byte[] ivBytes = new byte[8] { 0, 0, 0, 0, 0, 0, 0, 0 }; des.IV = ivBytes; ICryptoTransform ct = des.CreateEncryptor(); //Interface with some result byte[] resultArray = ct.TransformFinalBlock(clearBytes, 0, clearBytes.Length); encryptedText = ByteArrayToHexString(resultArray); } catch (Exception exception) { return ""; } return encryptedText; } public static byte[] StringToByteArray(string hex) { return Enumerable.Range(0, hex.Length) .Where(x => x % 2 == 0) .Select(x => Convert.ToByte(hex.Substring(x, 2), 16)) .ToArray(); }

否则,只需查找ASCII码的整数值即可。 http://www.asciitable.com/

一旦寄存器中有一个二进制整数,则以与其他任何整数相同的方式用十六进制或十进制打印它,例如rabbitmq-users或将其拆分为4位半字节,然后向每个数字添加mov r0, #'a'printf