我想开始转换一个小nasm项目{c},以了解更多关于这个小软合成器的信息。C实现nasm代码
问题是我的asm知识非常非常生疏,我想知道从哪里开始。我想也许有一个反编译器可以帮助我,但是我还没有找到任何能够将这些简单的nasm列表转换为c的开源代码。
另一种方法是做转换asm->ç手动,但我努力理解的最简单的功能之一:(
即:
;distortion_machine
;---------------------------
;float a
;float b
;---------------------------
;ebp: distort definition
;edi: stackptr
;ecx: length
section distcode code align=1
distortion_machine:
pusha
add ecx, ecx
.sampleloop:
fld dword [edi]
fld dword [ebp+0]
fpatan
fmul dword [ebp+4]
fstp dword [edi]
scasd
loop .sampleloop
popa
add esi, byte 8
ret
破尝试:
void distortion_machine(???) { // pusha; saving all registers
int ecx = ecx+ecx; // add ecx, ecx; this doesn't make sense
while(???) { // .sampleloop; what's the condition?
float a = [edi]; // fld dword [edi]; docs says edi is stackptr, what's the meaning?
float b = [ebp+0]; // fld dword [ebp+0]; docs says ebp is distort definition, is that an input parameter?
float c = atan(a,b); // fpatan;
float d = c*[ebp+4]; // fmul dword [ebp+4];
// scasd; what's doing this instruction?
}
return ???;
// popa; restoring all registers
// add esi, byte 8;
}
我想上面的nasm列表是一个非常简单的循环扭曲一个简单的音频缓冲区,但我不明白哪些是输入和哪些是输出,我做甚至不理解循环条件:')
任何有关上述例程的帮助,以及如何在这个小小的教育项目上取得进展,我们将非常感激。
'添加ECX,ecx'只是由其中两个意义,如果所述功能正在工作时,例如'short'样品(SO 2个字节)乘法装置ECX及长度是以样本表示。 – Jack
请在帖子中只提问一个问题。我假设问题是“我如何将nasm程序集转换为C”。 “需要关于如何完成”的类型问题或“这些代码做什么”的建议在这里是无关紧要的。 –
BadZen
@Jack好吧,让我们假设例程正在修改'short *'输入缓冲区,但'loop'将ecx减1,不是吗?另外,在这种情况下,“ebp”和“edi”的含义是什么? – BPL