我对如何实现这一点有一些问题。我正在尝试将整数转换为ASCII格式的三进制值。
; Macro to convert integer to senary value in ASCII format.
; Call: int2senary <integer>, <string-addr>
; Arguments:
; %1 -> <integer>, value
; %2 -> <string>, string address
; Reads <string>, place count including NULL into <count>
; Note, should preserve any registers that the macro alters.
mov eax, %1
mov r9d, 6
convLoop:
div r9d
add edx, 48
push edx
cmp eax, r9d
jge convLoop 发布于 2015-02-14 22:43:31
关于这段代码有几点:
a在执行DIV之前,需要清除EDX。
b只要EAX不为0,迭代就必须继续。
,c,,你需要计算一下你做了多少次PUSH-es。否则,在将结果存储在字符串中时,您如何知道稍后要执行多少次pop-s?
应用于代码:
mov eax, %1
mov r9d, 6
xor ecx, ecx ; (c)
convLoop:
xor edx, edx ; (a)
div r9d
add edx, 48
push edx
inc ecx ; (c)
test eax, eax ; (b)
jnz convLoop ; (b)https://stackoverflow.com/questions/28511166
复制相似问题