I am trying to reassemble code reversed from an executable using radare2. I have managed to extract the asm and am using nasm for reassembling.
The question is, the code also contains commands like
byte ptr [esi],pushal, fucomi st(3) and sqrtps xmm5, xmmword [edx - 1]
which I'm unfamiliar with.
I tried assembling with the nasm -felf -o
command. However, I'm getting the following errors.
test.asm:68: error: comma, colon, decorator or end of line expected after operand
test.asm:69: error: comma, colon, decorator or end of line expected after operand
test.asm:85: error: comma, colon, decorator or end of line expected after operand
test.asm:133: error: comma, colon, decorator or end of line expected after operand
test.asm:167: error: impossible combination of address sizes
test.asm:167: error: invalid effective address
test.asm:298: error: symbol `pushal' redefined
test.asm:423: error: comma, colon, decorator or end of line expected after operand
test.asm:637: error: comma, colon, decorator or end of line expected after operand
test.asm:802: error: symbol `pushal' redefined
According to this stackoverflow post, the keyword ptr does not exist in nasm and it suggested that the word be removed. Doing that resolved a few errors. Now I have the following errors:
test.asm:68: error: comma, colon, decorator or end of line expected after operand
test.asm:69: error: comma, colon, decorator or end of line expected after operand
test.asm:85: error: comma, colon, decorator or end of line expected after operand
test.asm:133: error: comma, colon, decorator or end of line expected after operand
test.asm:298: error: symbol `pushal' redefined
test.asm:423: error: comma, colon, decorator or end of line expected after operand
test.asm:637: error: comma, colon, decorator or end of line expected after operand
test.asm:802: error: symbol `pushal' redefined
Since I have no idea what pushal and sqrtps mean, I'm reluctant to remove them from the code. Could someone please explain what these commands mean?
Additionally suggestions on how I can get this as a compilable error-free code are also welcome.
EDIT: Following user blabb s suggestion, i replaced pushal with pushad and now I have only 2 errors
test.asm:80: error: comma, colon, decorator or end of line expected after operand
test.asm:127: error: comma, colon, decorator or end of line expected after operand
The 2 lines in question are:
fucomi st(3)
and
sqrtps xmm5, xmmword [edx - 1]
any suggestions as to how to handle this?
EDIT 2: including lines 76-83
pop esi
int3
sti
xor ebx,ebx
fucomi st(0),st(3)
jmp 0x400299
pop es
xor ebx, ebx
and lines 122-132
add cl, bh
iretd
mov dr0, ebx
and eax, ebx
ret
push 0xf
sqrtps xmm5, xmmword [edx - 1]
push ecx
push 0xffffffffffffffff
call dword [ecx + 0x51]
push ecx
EDIT3: Based on user blabb s suggestion and also by referring the NASM docs, I found that NASM does not accept st(0),st(3) and instead it accepts st0,st3. Now only one error left.
test.asm:127: error: comma, colon, decorator or end of line expected after operand
Still did not understand how to handle this.