简体   繁体   中英

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).

The user must put a string of binary and the lenght like: 01100001011101000110000101110001011101010110010101101110 56

and the ouput must be: 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".

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

So if input was 01110011 then AH is 0b1110011 = 73H = 115 = 's'

Each Ascii char is made up of one byte (8 bits). Each of your characters is either a 30h or a 31h (0 or 1). Read 8 of them. Calculate what number they are. Output as char.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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