After spending some time on TDG3D Engine and hl2 smd loader I've played with machine codes. It is quite interesting thing. I have never seen small source in delphi for making real EXE files, so I decided to make my own mini-compiler.
http://www.igrodel.ru/tdg3d/pe-asm0.2.zip (20kb) - exe+source code+examples
Currently it supports only three instructions (see readme.txt). But it's enough to compile small examples like that:
I release source code, maybe it will be useful, making engine script compiler to machine code, for students learning delphi, and so on..import
import Kernel32.dll WriteFile
import Kernel32.dll GetStdHandle
.var
string s1 "This is a loop!"
byte STD_INPUT_HANDLE 0xf5
dword count 0x00000000
.code
:label1
push =STD_INPUT_HANDLE
call getstdhandle
push 0x00 // lpOverlapped
push @count // lpNumberOfBytesWritten
push =length(s1) // nNumberOfBytesToWrite
push @s1 // lpBuffer
push eax // hFile
call writefile
jmp label1
Bookmarks