简体   繁体   English

如何在汇编中将二进制转换为ASCII

[英]How to convert binary to ascii in assembly

Im new to assembly language, i can have an idea in how to convert binary to ascii in another language but im having a hard time with assembly (assembly IA32, intel in linux). 我是汇编语言的新手,我可以对如何将另一种语言的二进制文件转换为ascii有一个想法,但是我在汇编方面遇到了麻烦(汇编IA32,Linux中的intel)。

The user must put a string of binary and the lenght like: 01100001011101000110000101110001011101010110010101101110 56 用户必须输入一个二进制字符串,长度如下:01100001011101000110000101110001011101010110010101101110 56

and the ouput must be: ataquen 输出必须是:ataquen

Im not asking to give me the complete function but i would like to know if there are some tips in assembly than can help me to build my program. 我没有要求给我完整的功能,但我想知道汇编中是否有一些技巧可以帮助我构建程序。 Thanks. 谢谢。

Assuming ESI points to users input and ECX = 8, this will convert a string of eight ASCII "0" & "1". 假设ESI指向用户输入且ECX = 8,则这将转换为八个ASCII“ 0”和“ 1”的字符串。

 NextCh:
        lodsb           
        ror     al, 1
        rcl     ah, 1
        loop    NextCh

So if input was 01110011 then AH is 0b1110011 = 73H = 115 = 's' 因此,如果输入为01110011则AH为0b1110011 = 73H = 115 ='s'

Each Ascii char is made up of one byte (8 bits). 每个Ascii字符由一个字节(8位)组成。 Each of your characters is either a 30h or a 31h (0 or 1). 您的每个字符都是30小时或31小时(0或1)。 Read 8 of them. 阅读其中的8条。 Calculate what number they are. 计算它们是多少。 Output as char. 输出为字符。

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

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