jc_23

|
分享:
▲
可否给个清楚例子呀 例如由键盘输入: 5<enter> 12<enter>
然后萤幕会丢出 101 5 5 1100 14 C 10001 21 11
这样的资料吗? 以下是从数值转 ascii 的程式,可以好好利用
; Description: Converts a binary number into a ascii string. ; Input: EAX - Binary number. ; ECX - Number system base. ; - 10, decimal system. ; - 16, hex system. ; ES:DI - Ptr to buffer that will hold the resulting string. ; ; Output: ES:DI - Pointer to end of string. ; ; Modified: EAX, EDX, DI ; Notes: This is a recursive procedure.
binary_2_string PROC NEAR PUBLIC xor edx, edx ; div ecx ; Divide or eax, eax ; Continue untill quotent = 0 jz bts_00
push edx ; Save remainder call binary_2_string ; Recursion pop edx
bts_00: mov al, dl cmp al, 0Ah jb bts_01
add al, ('A' - Ɔ' - 0Ah)
bts_01: add al, Ɔ' ; convert to ascii stosb ; store in the buffer ret binary_2_string ENDP
|