Необходимые инструменты:
Code: Select all
tasm32 — Turbo Assembler
link — линкер от Microsoft
ld — GNU линкер
objcopy — утилита для преобразования объектных файлов
Spoiler:
Code: Select all
COMMENT * ----------------------------------+
| |
| Example for KolibriOS on Turbo Assembler |
| |
+------------------------------------------ *
P586
MODEL Flat, StdCall
OPTION CaseMap: none
PUBLIC @Main
; Event Constants
REDRAW_EVENT = 1
KEY_EVENT = 2
BUTTON_EVENT = 3
MOUSE_EVENT = 6
; Window Style Constants
WS_SKINNED_FIXED = 4000000H
WS_SKINNED_SIZABLE = 3000000H
WS_FIXED = 0000000H
WS_SIZABLE = 2000000H
WS_FILL_TRANSPARENT = 40000000H
WS_FILL_GRADIENT = 80000000H
WS_COORD_CLIENT = 20000000H
WS_CAPTION = 10000000H
; Caption Style Constants
CS_MOVABLE = 00000000H
CS_IMMOVABLE = 01000000H
; Event Mask Constants
EM_REDRAW = 01H
EM_KEY = 02H
EM_BUTTON = 04H
EM_MOUSE = 020H
.DATA
szHello:
db "Hello from Turbo Assembler!",0
.CODE
@Main:
call SetEventMask, EM_REDRAW + EM_BUTTON
.REPEAT
call DrawWindow, 200, 150, 300, 250, WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION + WS_FILL_GRADIENT, 07777FFH, OFFSET szHello, CS_MOVABLE
call WaitEvent
.UNTIL eax != REDRAW_EVENT
call ThreadTerminate
; *********************************************************************************** ;
WaitEvent PROC
mov eax, 10
int 64
ret
ENDP
; *********************************************************************************** ;
SetEventMask PROC EventMask:Dword
USES ebx
mov eax, 40
mov ebx, EventMask
int 64
ret
ENDP
; *********************************************************************************** ;
DrawWindow PROC L:Dword, T:Dword, W:Dword, H:Dword, Style:Dword, BackColor:Dword, Caption:Ptr, CapStyle:Dword
USES ebx, esi, edi
; BeginDraw
mov eax, 12
mov ebx, 1
int 64
; DrawWindow
xor eax, eax
mov ebx, L
shl ebx, 16
add ebx, W
mov ecx, T
shl ecx, 16
add ecx, H
mov edx, Style
or edx, BackColor
mov edi, Caption
mov esi, CapStyle
int 64
; EndDraw
mov eax, 12
mov ebx, 2
int 64
ret
ENDP
; *********************************************************************************** ;
ThreadTerminate PROC
mov eax, -1
int 64
ENDP
; *********************************************************************************** ;
END
Spoiler:
Code: Select all
PATH_SIZE = 1024;
PARAMS_SIZE = 256;
STACK_SIZE = 1024;
SECTIONS
{
.all : {
LONG(0x554e454D);
LONG(0x31305445);
LONG(1);
LONG("@Main");
LONG(END);
LONG($END + PATH_SIZE + PARAMS_SIZE + STACK_SIZE);
LONG($END + PATH_SIZE + PARAMS_SIZE + STACK_SIZE);
LONG($END + PATH_SIZE);
LONG($END);
. = ALIGN(16);
*(.text)
. = ALIGN(16);
*(.data)
END = .;
. = ALIGN(16);
*(.bss)
. = ALIGN(16);
$END = .;
}
}
Spoiler:
Code: Select all
Set NAME=test
tasm32 %NAME%.asm
link -edit %NAME%.obj
LD -T LScript.x %NAME%.obj -o %NAME%.kex
objcopy -O binary -j .all %NAME%.kex
Del %NAME%.obj
Pause