(* BSD 2-Clause License Copyright (c) 2018, 2019, Anton Krotov All rights reserved. *) MODULE API; IMPORT SYSTEM; VAR eol*: ARRAY 3 OF CHAR; base*: INTEGER; PROCEDURE [windows-, "kernel32.dll", "ExitProcess"] ExitProcess (code: INTEGER); PROCEDURE [windows-, "kernel32.dll", "ExitThread"] ExitThread (code: INTEGER); PROCEDURE [windows-, "kernel32.dll", "GlobalAlloc"] Alloc (uFlags, dwBytes: INTEGER): INTEGER; PROCEDURE [windows-, "kernel32.dll", "GlobalFree"] Free (hMem: INTEGER): INTEGER; PROCEDURE [windows-, "user32.dll", "MessageBoxA"] MessageBoxA (hWnd, lpText, lpCaption, uType: INTEGER): INTEGER; PROCEDURE DebugMsg* (lpText, lpCaption: INTEGER); BEGIN MessageBoxA(0, lpText, lpCaption, 16) END DebugMsg; PROCEDURE _NEW* (size: INTEGER): INTEGER; RETURN Alloc(64, size) END _NEW; PROCEDURE _DISPOSE* (p: INTEGER): INTEGER; RETURN Free(p) END _DISPOSE; PROCEDURE init* (reserved, code: INTEGER); BEGIN eol[0] := 0DX; eol[1] := 0AX; eol[2] := 0X; base := code - 4096 END init; PROCEDURE exit* (code: INTEGER); BEGIN ExitProcess(code) END exit; PROCEDURE exit_thread* (code: INTEGER); BEGIN ExitThread(code) END exit_thread; END API.