【发布时间】:2016-10-17 17:16:32
【问题描述】:
好的,所以我正在尝试使用 nasm -f elf final.asm 在程序集中组装一些代码:
xor eax,eax
push eax
push dword(0x75792273)
push dword(0x70742027)
push dword(0x77777875)
push dword(0x20237678)
push dword(0x76727827)
push dword(0x27797175)
push dword(0x75711225)
push dword(0x72747676)
push dword(0x74231476)
push dword(0x70707470)
push dword(0x23247077)
push dword(0x78707822)
push dword(0x24711174)
push dword(0x22707373)
push dword(0x78717974)
push dword(0x75771777)
push dword(0x70777125)
push dword(0x73731472)
push dword(0x71277377)
push dword(0x79251822)
push dword(0x79707478)
push dword(0x78742779)
push dword(0x72727871)
push dword(0x71251475)
push dword(0x27247772)
push dword(0x79757479)
push dword(0x70227071)
push dword(0x77737420)
push dword(0x70251970)
push dword(0x74747127)
push dword(0x23277677)
push dword(0x79712024)
push esp
pop esi
mov edi,esi
mov edx,edi
cld
mov ecx,0x80
mov ebx,0x41
xor eax,eax
push eax
lods byte[esi]
xor eax,ebx
stos byte[es:edi]
loop 0xb7
push esp
pop esi
int 0x3
这会导致以下错误:
final.asm:44: error: parser: instruction expected
final.asm:46: error: parser: instruction expected
我在以下位置找到了这些错误的答案: NASM: parser: instruction expected rep movs
基本上,这表示 lods 和 stos 指令不被 NASM 识别。这意味着我需要将它们转换成 NASM 能够识别的东西,这样我才能得到相同的结果。
我的问题是,我可以将这两行更改为什么,以便 NASM 可以编译它,以便最终调试它。
【问题讨论】:
-
更改为简单的
lodsb和stosb(无操作数)。 -
当我运行它时,我得到:test.asm:44:错误:操作码和操作数的无效组合 test.asm:46:错误:操作码和操作数的无效组合
-
lodsb 字节[esi] stosb 字节[es:edi]
-
只使用
lodsb和stosb不lodsb byte [esi]。 -
顺便说一句,用
lodsb覆盖段使用,NASM中的语法是ss lodsb(我自己很好奇,因为我还不需要它,所以我不得不搜索一段时间才能找到NASM句法)。stos系列指令固定为es并且不能被覆盖。