【发布时间】:2013-04-03 16:19:18
【问题描述】:
在 x86 汇编语言中,是否有任何有效的方法可以将字节转换为二进制数字字符串(表示为 0 和 1 的字节数组)?据我所知,在 x86 汇编中没有任何“toString”函数,就像在大多数高级编程语言中一样。
.stack 2048
.data
theString byte 0, 0, 0, 0, 0, 0, 0, 0 ;store eax as a binary string here.
ExitProcess proto, exitcode:dword
.code
start:
mov eax, 3;
;now I need to convert eax to a binary string somehow (i. e., a byte array of 0s and 1s)
invoke ExitProcess, 0
end start
【问题讨论】:
-
至少可以从x86汇编语言的寄存器中获取第一位:stackoverflow.com/questions/15238467/…
-
如果您的意思是转换,例如字符串“1101”的值 13 然后查看我对stackoverflow.com/questions/15786970/… 的回答它可以在 x86 上通过循环和
SHL/JC组合相当有效地完成。 -
@Michael 该问题讨论的是 MIPS 程序集而不是 x86 程序集。
-
阅读实际答案。它绝不是 MIPS 特定的,甚至不包含任何 MIPS 代码。