/* "helloc4.c":helloをC言語で記述した例 */
/* stack:4k malloc:1k */
#include <guigui00.h>
#define AUTO_MALLOC 0
void OsaskMain()
{
struct LIB_WINDOW *window;
struct LIB_TEXTBOX *wintitle, *textbox;
/* ライブラリの初期化(必ず最初にやらなければならない) */
lib_init(AUTO_MALLOC);
/* ウィンドウのオープン */
window = lib_openwindow(AUTO_MALLOC, 0x0200, 136, 48);
/* ウィンドウタイトル用のテキストボックスをオープン */
wintitle = lib_opentextbox(0x1000, AUTO_MALLOC, 0, 7, 1, 0, 0, window, 0x00c0, 0);
/* "hello, world"を表示するためのテキストボックスをオープン */
textbox = lib_opentextbox(0x0000, AUTO_MALLOC, 0, 12, 1, 16, 16, window, 0x00c0, 0);
/* ウィンドウタイトルを表示 */
lib_putstring_ASCII(0x0000, 0, 0, wintitle, 0, 0, "helloc4");
/* メッセージを表示 */
lib_putstring_ASCII(0x0000, 0, 0, textbox, 0, 0, "hello, world");
/* 終了 */
lib_waitsignal(0x0001, 0, 0);
}
/* "helloa4.ask":helloをASKAで記述した例 */
/* stack:4k malloc:0k */
segment CODE(USE32, PARA); default(code == CODE); asmout("[FILE 'helloa4.ask']");
asmout("GLOBAL _OsaskMain");
void _OsaskMain()
{
asmout("MOV EBX,data.funcs"); CALL(0xc7, 0);
}
asmout("[SECTION .data]");
void data()
{
ALIGNB(4);
funcs:
asmout("DD 0x0004, data.work"); /* lib_init */
asmout("DD 0x0020, data.window, 0x0200, 136, 48"); /* lib_openwindow */
asmout("DD 0x0028, 0x1000, data.wintitle, 0, 7, 1, 0, 0, data.window, 0x00c0, 0"); /* lib_opentextbox */
asmout("DD 0x0028, 0x0000, data.textbox, 0, 12, 1, 16, 16, data.window, 0x00c0, 0"); /* lib_opentextbox */
asmout("DD 0x0040, 0x1000, 0, 0, data.wintitle, 0, 0, 0, 7, 'helloa4'"); /* lib_putstring1 */
asmout("DD 0x0040, 0x1000, 0, 0, data.textbox, 0, 0, 0, 12, 'hello, world'"); /* lib_putstring1 */
DD(0x0018, 0x0001, 0, 0); /* lib_waitsignal */
DD(0x0000); /* end of functions */
ALIGNB(8);
work:
RESB(256); /* func_initに必要な256バイトのワークエリア */
window:
RESB(128); /* ウィンドウ構造体 */
wintitle:
RESB(64); /* テキストボックス構造体 */
RESB(56); /* 7x1文字分 (7 * 1 * 8) */
textbox:
RESB(64); /* テキストボックス構造体 */
RESB(96); /* 12x1文字分 (12 * 1 * 8) */
}
; "hellon4.nas":helloをnaskで記述した例
; stack:4k malloc:0k
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[OPTIMIZE 1]
[OPTION 1]
[BITS 32]
[FILE "hellon4.nas"]
; 新出のOPTIONについて。定数計算をデフォルトでは符号付き整数でおこなえという意味。
; 指定しないとデフォルトは符号無し整数でおこなうことになっている。
[SECTION .text]
GLOBAL _OsaskMain
_OsaskMain:
MOV EBX,funcs
CALL 0xc7:0
[SECTION .data]
ALIGNB 4
funcs:
DD 0x0004, work ; lib_init
DD 0x0020, window, 0x0200, 18 * 8, 3 * 16 ; lib_openwindow
DD 0x0028, 0x1000, wintitle, 0, 7, 1, 0, 0, window, 0x00c0, 0 ; lib_opentextbox
DD 0x0028, 0x0000, textbox, 0, 12, 1, 16, 16, window, 0x00c0, 0 ; lib_opentextbox
DD 0x0040, 0x1000, 0, 0, wintitle, 0, 0, 0, 7, 'hellon4' ; lib_putstring1
DD 0x0040, 0x1000, 0, 0, textbox, 0, 0, 0, 12, 'hello, world' ; lib_putstring1
DD 0x0018, 0x0001, 0, 0 ; lib_waitsignal
DD 0x0000 ; end of functions
ALIGNB 8
work:
RESB 256 ; func_initに必要な256バイトのワークエリア
window:
RESB 128 ; ウィンドウ構造体
wintitle:
RESB 64 + 7 * 1 * 8; テキストボックス構造体(7x1文字分)
textbox:
RESB 64 + 12 * 1 * 8; テキストボックス構造体(12x1文字分)
タイトルのx_size * 8 + 80 <= ウィンドウのx_size