2: 2004-12-15 (水) 18:06:26 [6] | 3: 2004-12-15 (水) 18:06:26 [7] | ||
---|---|---|---|
Line 8: | Line 8: | ||
*** countdown | *** countdown | ||
- | -C版:"cntdwnc1.c" [osa_dir2では バイト] | + | -C版:"cntdwnc1.c" [osa_dir2では 616バイト] |
/* "cntdwnc1.c":countdwnをC言語で記述した例 */ | /* "cntdwnc1.c":countdwnをC言語で記述した例 */ | ||
/* stack:20k malloc:1k */ | /* stack:20k malloc:1k */ | ||
Line 61: | Line 61: | ||
- | -''以下未完成'' | + | -ASKA版:"cntdwna1.ask" [osa_dir2では 249バイト] |
- | + | ||
- | + | ||
- | -ASKA版:"cntdwna1.ask" [osa_dir2では バイト] | + | |
/* "cntdwna1.ask":countdwnをASKAで記述した例 */ | /* "cntdwna1.ask":countdwnをASKAで記述した例 */ | ||
/* stack:20k malloc:0k */ | /* stack:20k malloc:0k */ | ||
Line 70: | Line 67: | ||
asmout("GLOBAL _OsaskMain"); | asmout("GLOBAL _OsaskMain"); | ||
- | void setdec3(); /* ALをDS:ESIに書き込む */ | + | void setdec3(); /* EAXをDS:ESIに書き込む */ |
void _OsaskMain() | void _OsaskMain() | ||
{ | { | ||
asmout("MOV EBX,data.init"); CALL(0xc7, 0); | asmout("MOV EBX,data.init"); CALL(0xc7, 0); | ||
- | // | ||
- | unsigned char i == AL, x == CL, y == CH; | ||
- | i = 0; | ||
- | do { | ||
- | asmout("MOV EBX,data.putstr"); | ||
- | x = 10; | ||
- | y = i; | ||
- | y /= 2; | ||
- | if (CF == 0) | ||
- | x = 0; /* yが割り切れたらxは0に */ | ||
- | [EBX + 8] = x; | ||
- | [EBX + 12] = y; | ||
- | [EBX + 20] = i; | ||
- | LEA(ESI, [EBX + 42]); | ||
- | setdec2(); | ||
- | CALL(0xc7, 0); | ||
- | i++; | ||
- | } while (i < 16); | ||
- | asmout("MOV EBX,data.sleep"); CALL(0xc7, 0); | + | for (;;) { |
+ | unsigned int count == EAX; | ||
+ | count = 100; | ||
+ | do { | ||
+ | asmout("MOV EBX,data.putnum"); | ||
+ | LEA(ESI, [EBX + 36]); | ||
+ | setdec3(); | ||
+ | CALL(0xc7, 0); | ||
+ | count--; | ||
+ | } while (!= 0); | ||
+ | asmout("MOV EBX,data.putgo"); | ||
+ | CALL(0xc7, 0); | ||
+ | } | ||
} | } | ||
- | void setdec2() | + | void setdec3() |
{ | { | ||
char *s == DS:ESI; | char *s == DS:ESI; | ||
+ | PUSH(EDX); | ||
PUSH(ECX); | PUSH(ECX); | ||
PUSH(EAX); | PUSH(EAX); | ||
- | CL = 10; | + | EDX = 0; |
- | AH = 0; | + | ECX = 10; |
- | DIV(CL); /* AX / CL = AL ... AH */ | + | DIV(ECX); /* EDX:EAX / ECX = EAX ... EDX */ |
+ | DIV(CL); /* AX / CL = AL ... AH */ | ||
EAX |= 0x3030; /* '00' */ | EAX |= 0x3030; /* '00' */ | ||
- | if (AL == 0x30) | + | DL |= 0x30; |
+ | if (AL == 0x30) { | ||
AL = 0x20; /* ' ' */ | AL = 0x20; /* ' ' */ | ||
+ | if (AH == 0x30) | ||
+ | AH = 0x20; | ||
+ | } | ||
s[0] = AL; | s[0] = AL; | ||
s[1] = AH; | s[1] = AH; | ||
+ | s[2] = DL; | ||
POP(EAX); | POP(EAX); | ||
POP(ECX); | POP(ECX); | ||
+ | POP(EDX); | ||
return; | return; | ||
} | } | ||
Line 122: | Line 121: | ||
init: | init: | ||
asmout("DD 0x0004, data.work"); /* lib_init */ | asmout("DD 0x0004, data.work"); /* lib_init */ | ||
- | asmout("DD 0x0020, data.window, 0x0200, 20 * 8, 8 * 16"); /* lib_openwindow */ | + | asmout("DD 0x0020, data.window, 0x0200, 18 * 8, 1 * 16"); /* lib_openwindow */ |
- | asmout("DD 0x0028, 0x1000, data.wintitle, 0, 7, 1, 0, 0, data.window, 0x00c0, 0"); /* lib_opentextbox */ | + | asmout("DD 0x0028, 0x1000, data.wintitle, 0, 8, 1, 0, 0, data.window, 0x00c0, 0"); /* lib_opentextbox */ |
- | asmout("DD 0x0028, 0x0001, data.textbox, 0, 20, 8, 0, 0, data.window, 0x00c0, 0"); /* lib_opentextbox */ | + | asmout("DD 0x0028, 0x0000, data.textbox, 0, 3, 1, 56, 0, data.window, 0x00c0, 0"); /* lib_opentextbox */ |
- | asmout("DD 0x0040, 0x1000, 0, 0, data.wintitle, 0, 0, 0, 7, 'colora1'"); /* lib_putstring1 */ | + | asmout("DD 0x0040, 0x1000, 0, 0, data.wintitle, 0, 0, 0, 8, 'cntdwna1'"); /* lib_putstring1 */ |
DD(0x0000); /* end of functions */ | DD(0x0000); /* end of functions */ | ||
- | putstr: | + | putnum: |
- | asmout("DD 0x0040, 0x1000, 0, 0, data.textbox, 0, 0, 0, 8, 'color '"); /* lib_putstring1 */ | + | asmout("DD 0x0040, 0x1000, 0, 0, data.textbox, 0, 0, 0, 3, '000'"); /* lib_putstring1 */ |
+ | DD(0x0018, 0x0007, 0, 0, 0, 1, 0); /* lib_waitsignaltime */ | ||
DD(0x0000); /* end of functions */ | DD(0x0000); /* end of functions */ | ||
- | sleep: | + | putgo: |
- | DD(0x0018, 0x0001, 0, 0); /* lib_waitsignal */ | + | asmout("DD 0x0040, 0x1000, 0, 0, data.textbox, 0, 0, 0, 3, 'GO!'"); /* lib_putstring1 */ |
+ | DD(0x0018, 0x0007, 0, 0, 0, 10, 0); /* lib_waitsignaltime */ | ||
DD(0x0000); /* end of functions */ | DD(0x0000); /* end of functions */ | ||
Line 144: | Line 145: | ||
textbox: | textbox: | ||
RESB(64); /* テキストボックス構造体 */ | RESB(64); /* テキストボックス構造体 */ | ||
- | RESB(1280); /* 20x8文字分 (20 * 8 * 8) */ | + | RESB(24); /* 3x1文字分 (3 * 1 * 8) */ |
} | } | ||
- | -nask版:"colorn1.nas" [osa_dir2では 238バイト] | + | -''以下未完成'' |
- | ; "colorn1.nas":colorをnaskで記述した例 | + | |
+ | -nask版:"cntdwnn1.nas" [osa_dir2では バイト] | ||
+ | ; "cntdwnn1.nas":countdwnをnaskで記述した例 | ||
; stack:20k malloc:0k | ; stack:20k malloc:0k | ||
Line 157: | Line 160: | ||
[OPTION 1] | [OPTION 1] | ||
[BITS 32] | [BITS 32] | ||
- | [FILE "colorn1.nas"] | + | [FILE "cntdwnn1.nas"] |
[SECTION .text] | [SECTION .text] | ||
GLOBAL _OsaskMain | GLOBAL _OsaskMain | ||
+ | ;;; | ||
_OsaskMain: | _OsaskMain: | ||
MOV EBX,init | MOV EBX,init |
(This host) = http://osask.net