Code: Select all
from pyasm.x86asm import assembler
from pyasm.x86cpToCoff import *
a = assembler()
a.AP("_main")
a.AI("XOR EAX, EAX")
a.AI("MOV EBX, 0x7d4d14e0")
a.AI("MOV AX, 5000")
a.AI("PUSH EAX")
a.AI("CALL EBX")
a.EP()
cp = a.Compile()
coff = CpToCoff(cp).makeReleaseCoff()
f = file("D:\\worktests\\obj.obj", "wb")
coff.WriteToFile(f)
f.close()
This next piece of code returns a different hex value I am guessing because it is a different assembler, "Nasm" and different output format elf instead of CDECL
Code: Select all
;sleep.asm
[SECTION .text]
global _start
_start:
xor eax,eax
mov ebx, 0x7d4d14e0 ;address of Sleep
mov ax, 5000 ;pause for 5000ms
push eax
call ebx ;Sleep(ms);