¦b³o¤@³¹ùØ¡A¤p¤ì°¸±N¤¶²Ðø»s¹Ï§Î¡A¦ý¬O¶È¶Èø»s¹Ï§Î«o¤S¤Ó¹L²³æ¡A¦]¦¹¦A¥[¤W©w®É°e°T®§µ¹¦Û¤vªºµ{¦¡¤ù¬q¡A¥H¤Îµ²§ôµ{¦¡®É·|¸ß°Ý¬O§_¯uªº°h¥X³o¨Ç¥\¯à¡C¥ý»¡²Ä¤@ÂI¡Aø¹Ï¡A¦¹µ{¦¡¬O¦b¤@Óµøµ¡¤W´yø¥X©ßª«½u¡A¦¹©ßª«½uªº¼Æ¾Ç¤èµ{¦¡¬O y=(x¡Ð200)2¡A·íµM¤p¤ì°¸¶Èµe¥X x=0 ¶}©l¨ì 399 ªº³o¬q½d³ò¡A©Ò¥H y ªº½d³ò¬O±q 0 ¨ì 200¡A¦@ 400 ÂI¡Cµe¥X¹Ï§Î¦p¤U¹Ï¡G
¹Ï¤¤ÂŦ⪺®y¼Ð¨Ã¤£¬Oµ{¦¡©ÒÅã¥Üªº¡A¦Ó¬O¤p¤ì°¸µe¤W¥hªº¡A±zÀ³·í¥i¥Hª`·N¨ì¡A¦bµøµ¡ªº¤u§@°Ïùتº®y¼Ð©M¼Æ¾Ç¤Wªº®y¼Ð¤£¤Ó¬Û¦P¡A¤u§@°Ï¤¤¥ª¤W¨¤®y¼Ð¬° (0¡A0)¡Ax ®y¼Ð¦V¥k¼W¥[¡A¦ý y ®y¼Ð«o¬O¦V¤U¼W¥[¡C²Ä¤G¡A¤p¤ì°¸¤£¥´ºâ¥ß¨è´Nµe¥X¾ãÓµe±¡A¦Ó¬O¨C¹j 0.1 ¬íµe¥X¤@ÂI¡A³o¼Ë§Ú̪ºµ{¦¡´N¥²¶·¨Ï¨t²Î¨C¹j 0.1 ¬í¹ï¦Û¤vµo¥X°T®§¡A¦Ó§Ú̪ºµ{¦¡¦A¥[¥H³B²z¡C²Ä¤T¬O«ö¤U¥k¤W¨¤ªº°h¥X¶s°h¥Xµ{¦¡®É·|¼u¥X¤@Óµøµ¡¡A¸ß°Ý¬O§_¯unÂ÷¶}¡A¦p¤U¹Ï©Ò¥Ü¡G
³oÓµ{¦¡ªº¤j³¡¤Àì²z³£¦b«e±±Ôz¹L¤F¡A·sªº³¡¥÷¬O¦p¦ó¨C¹j 0.1 ¬íµe¥X¤@ÂI¡C°²¦p¬O¦b DOS Àô¹Ò¤U¡A§Ṳ́j·§·|¥Î¤@Ó°j°é¤£Â_Àˬd¬O§_¤w¸g¨ì¹F®É¶¡¡C¦ý¬O¦b Win32 Àô¹Òªº«ä¦Ò¤è¦¡¤£¬O³o¼Ë¡A¦b Win32 Àô¹ÒùØÀ³¸Ó¥H°T®§ÅX°Êªº¤è¦¡«ä¦Ò¡A¤]´N¬O¯à°÷¨Ï¨t²Î¦b¨C¹j¤@¬q®É¶¡®Éµo¥X¤@Ó°T®§µ¹§Ú̪ºµ{¦¡¡An¹F¨ì³oӥتº¥i¥H¨Ï¥Î SetTimer API¡C
³oÓ API «Ø¥ß¤@Óp®É¾¹¡A¦¹p®É¾¹¨C¹j¤@¬q«ü©wªº®É¶¡¡A¦V¬YÓ«ü©wªºµøµ¡°e¥X WM_TIMER °T®§¡C¨ä쫬¦p¤U¡G
UINT SetTimer( HWND hWnd, // handle of window for timer messages UINT nIDEvent, // timer identifier UINT uElapse, // time-out value TIMERPROC lpTimerFunc // address of timer procedure );
hWnd ¬Op®É¾¹©ÒÄݪºµøµ¡¥N½X¡CnIDEvent ¬Op®É¾¹ªºÃѧO½X¡A¥ô·Nµ¹¤@Ó«D¹sȧY¥i¡CuElapse ¬O©Ò³]©wªº®É¶¡¡A³æ¦ì¬O²@¬í¡ClpTimerFunc ¬O³B²z WM_TIMER ªº¨ç¦¡¡A°²¦p lpTimerFunc ¬° NULL ªº¸Ü¡A´N¬O«ü¥Ñ hWnd ªºµøµ¡¨ç¦¡¨Ó³B²z WM_TIMER¡A¤]´N¬O»¡ WM_TIMER ·|³Qµo°e¨ì hWnd ªºµøµ¡¨ç¦¡¡C
·í¥Î¤£µÛp®É¾¹®É¡AÀ³¸ÓÄÀ©ñp®É¾¹¡A¦¹®É´N¥Î KillTimer¡A¨ä쫬¦p¤U¡G
BOOL KillTimer( HWND hWnd, // handle of window that installed timer UINT uIDEvent // timer identifier );
hWnd ¬Op®É¾¹©ÒÄݪºµøµ¡¥N½X¡CuIDEvent ¬Op®É¾¹ªºÃѧO½X¡C³o¨âӰѼÆÀ³¸Ó©M SetTimer ªº«e¨âӰѼƬۦP¡C°²¦pÄÀ©ñ¦¨¥\ªº¸Ü¡A¦¹ API ·|¶Ç¦^«D¹sÈ¡A¥¢±Ñªº¸Ü¡A·|¶Ç¦^¹s¡C
¦¹µ{¦¡¤p¤ì°¸¦W¤§¬° PARABOLA.ASM¡A¤º®e¦p¤U¡G
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32
33 34 35 36
37 38 39 40
41 42 43 44
45 46 47 48
49 50 51 52
53 54 55 56
57 58 59 60
61 62 63 64
65 66 67 68
69 70 71 72
73 74 75 76
77 78 79 80
81 82 83 84
85 86 87 88
89 90 91 92
93 94 95 96
97 98 99 100
101 102 103 104
105 106 107 108
109 110 111 112
113 114 115 116
117 |
.386
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE
INCLUDE WINDOWS.INC
INCLUDE USER32.INC
INCLUDE GDI32.INC
INCLUDE KERNEL32.INC
INCLUDELIB USER32.LIB
INCLUDELIB GDI32.LIB
INCLUDELIB KERNEL32.LIB
TimerID EQU 74 ;p®É¾¹ID
color EQU 0ffh ;ÃC¦â½X
WndProc PROTO :HWND,:UINT,:WPARAM,:LPARAM
;*******************************************************************************
.DATA
ClassName db 'SimpleWinClass',0
AppName db '©ßª«½u',0
AskExit db '¬O§_°h¥X¦¹µ{¦¡¡H',0
AskExitTitle db '¸ß°Ý',0
x dd 0 ;©ßª«½uªº x ®y¼Ð
y dd ? ;©ßª«½uªº y ®y¼Ð
two_hundred dw 200 ;±`¼Æ
hInstance HINSTANCE ?
hwnd HWND ?
CommandLine LPSTR ?
wc WNDCLASSEX <30h,?,?,0,0,?,?,?,?,0,OFFSET ClassName,?>
msg MSG <?>
;*******************************************************************************
.CODE
start: INVOKE GetModuleHandle,NULL
mov hInstance,eax
INVOKE GetCommandLine
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,OFFSET WndProc
mov eax,hInstance
mov wc.hInstance,eax
mov wc.hbrBackground,COLOR_WINDOW+1
INVOKE LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
INVOKE LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
INVOKE RegisterClassEx,OFFSET wc
INVOKE CreateWindowEx,NULL,OFFSET ClassName,OFFSET AppName,\
WS_OVERLAPPEDWINDOW,0,10,410,250,0,0,hInstance,NULL
mov hwnd,eax
INVOKE ShowWindow,hwnd,SW_SHOWDEFAULT
INVOKE UpdateWindow,hwnd
gt_msg: INVOKE GetMessage,OFFSET msg,NULL,0,0
or eax,eax
jz wm_qut
INVOKE TranslateMessage,OFFSET msg
INVOKE DispatchMessage,OFFSET msg
jmp gt_msg
wm_qut: mov eax,msg.wParam
INVOKE ExitProcess,eax
;-------------------------------------------------------------------------------
WndProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL PS:PAINTSTRUCT
LOCAL invalid:RECT
cmp uMsg,WM_CREATE ;¦¬¨ì WM_CREATE
jne nx_wm0
INVOKE SetTimer,hWnd,TimerID,100,NULL ;«Ø¥ßp®É¾¹
jmp exit
nx_wm0: cmp uMsg,WM_TIMER ;¦¬¨ì WM_TIMER
jne nx_wm1
cmp x,400 ;Y x ¤j©ó©Îµ¥©ó 400 «h¤£³B²z
je no_pnt
mov invalid.top,0 ;pºâ©ßª«½uªº x ¤Î y ®y¼Ð¡A¥H¤ÎµL®Ä°Ï
mov invalid.bottom,250
mov eax,x
finit ;---st ---;---st1---;
fild x ; x ; ;
fisub two_hundred ; x-200 ; ;
fmul st,st ; (x-200)2; ;
fidiv two_hundred ; y ; ;
fistp y
mov invalid.left,eax
add eax,2
mov invalid.right,eax
INVOKE InvalidateRect,hWnd,ADDR invalid,FALSE
inc x ;¨Ï x ¼W¥[¤@
no_pnt: jmp exit
nx_wm1: cmp uMsg,WM_PAINT ;³B²z WM_PAINT
jne nx_wm2
INVOKE BeginPaint,hWnd,ADDR PS
INVOKE SetPixel,eax,x,y,color ;µe¥X¤@ÂI
INVOKE EndPaint,hWnd,ADDR PS
jmp exit
nx_wm2: cmp uMsg,WM_CLOSE ;³B²z WM_CLOSE
jne nx_wm3
INVOKE MessageBox,hWnd,ADDR AskExit,\ ;¼u¥X¸ß°Ýµøµ¡
ADDR AskExitTitle,MB_YESNO or MB_ICONQUESTION
cmp eax,IDYES
jne exit
INVOKE KillTimer,hWnd,TimerID ;ÄÀ©ñp®É¾¹
INVOKE DestroyWindow,hWnd ;ºR·´µøµ¡
jmp exit
nx_wm3: cmp uMsg,WM_DESTROY
jne nx_wm4
INVOKE PostQuitMessage,NULL
jmp exit
nx_wm4: INVOKE DefWindowProc,hWnd,uMsg,wParam,lParam
ret
exit: xor eax,eax
ret
WndProc ENDP
;*******************************************************************************
END start
|
³oÓµ{¦¡¤j³¡¤Àªº©M«e±¬Û¦P¡A¤p¤ì°¸¶È¸ÑÄÀ¤£¦Pªº¦a¤è¡Cµ{¦¡²Ä 12 ¦æ¬Op®É¾¹ÃѧO½X¡A¥ô·Nªº«D¹sȧY¥i¡C
µ{¦¡²Ä 13 ¦æ¬OÃC¦â¡C¦b Windows ¨t²ÎùتºÃC¦â¬O¥H¤@Ó 32 ¦ì¤¸ ( ¤]´N¬O 4 Ӧ줸²Õ ) ªø«×ªº¼ÆȪí¥Ü¡A¨ä®æ¦¡¦p¤U¡G
00BBGGRRh
³Ì°ª¦ì§}ªº¦ì¤¸²Õ¥²³]¬°¹s¡A³Ñ¤Uªº¤TӦ줸²Õ¨Ì¦ì§}¥Ñ§C¦Ó°ª¡A¤À§Oªí¥Ü¬õ¡Bºñ¡BÂÅ¡A¤]´N¬O¥úªº¤Tì¦â¡C¨C¤@ºØ¦â¥úªº±j«×¥Ñ 0 ¨ì 255¡A¦¹¼ÆȶV¤jªí¥Ü¸Ó¦â¥ú¶V±j¡A0 ªí¥Ü¤£§t¸ÓºØ¦â¥ú¡C©Ò¥H 00000000 ªí¥Ü¶Â¦â¡A00FFFFFFh ªí¥Ü¥Õ¦â¡A00FF0000h ªí¥ÜÂŦâ¡A0000FF00h ªí¥Üºñ¦â¡A000000FFh ªí¥Ü¬õ¦â¡C
²Ä 21 ¦æ¨ì²Ä 23 ¦æ¬O©w¸qÅÜ¼Æ x¡By ©M±`¼Æ 200 ªº¦a¤è¡Cnª`·Nªº¬OÅÜ¼Æ x µLªk³]¦b WndProc ùر·í°µ°Ï°ìÅܼơA¦]¬°¨C¤@¦¸°T®§´`Àô°Ï°ìÅܼƳ£·|³Q««Ø¤Î¾P·´¡A©Ò¥HµLªk«O«ù¨ä¼ÆÈ¡C¦]¦¹¤p¤ì°¸§â x ³]¬°¥þ°ìÅܼơA¦b¸ê®Æ¬q¤¤©w¸q¡C¦¹¥~¡Ax¡By ³Ì¦n¬O³]¬°Âù¦r²Õªº¤j¤p¡A§_«h¦b²Ä 92 ¦æ©I¥s SetPixel ®Éªº°Ñ¼Æ¤j¤p·|¤£¦X¡A¦ý²ÕĶ¾¹«o¤£·|³qª¾¿ù»~¡A¦Ó¦]¥Î¤F¿ù»~ªº¸ê®Æ¡A¥HPµ²ªG¬O¿ùªº¡C
·íÀ³¥Îµ{¦¡©I¥s CreateWindow ©Î CreateWindowEx «Ø¥ßµøµ¡®É¡ACreateWindow ©Î CreateWindowEx ·|§â WM_CREATE °T®§¶Çµ¹·s«Ø¥ßµøµ¡ªºµøµ¡¨ç¦¡¡C§Y¨Ï³oÓµøµ¡¨Ã¨S¦³¥ß§YÅã¥Ü¥X¨Ó¡AWM_CREATE ÁÙ¬O·|³Qµo°e¨ì¸Óµøµ¡ªºµøµ¡¨ç¦¡¤¤¡C³oÓ°T®§¤]¥u·|¦bµøµ¡«Ø¥ß®É¡A¥Ñ CreateWindow ©Î CreateWindowEx °e¥X¤@¦¸µ¹µøµ¡¨ç¦¡¡A¦]¦¹³\¦hµ{¦¡±`±`¦b WM_CREATE °T®§¤¤¡A³B²zµ{¦¡¤@¶}©l¥²¶·n§¹¦¨ªº¤u§@¡A¨Ò¦pªì©l¤Æ¬Y¨ÇÅܼƵ¥µ¥¡C
¦b PARABOLA.ASM µ{¦¡ùØ¡Ap®É¾¹¥u»Ý¦bµ{¦¡¶}©l®É«Ø¥ß¤@¦¸§Y¥i¡A¦]¦¹³B²z WM_CREATE °T®§ªº¨BÆJ´N¬O«Ø¥ßp®É¾¹¡C¦b²Ä 66 ¦æ´N¬O«Ø¥ß¤@Óp®É¾¹¡A¦¹p®É¾¹¨C¹j 0.1 ¬í( 100 ²@¬íµ¥©ó 0.1 ¬í )¦V¦Û¤vµo¥X¤@Ó WM_TIMER °T®§¡C
·íp®É¾¹¦V©ßª«½uµ{¦¡ªºµøµ¡¨ç¦¡µo¥X WM_TIMER °T®§®É¡An³B²zªº¤u§@¬O³]©wµL®Ä°Ï¡A¦³¤FµL®Ä°Ï«á¡A¨t²Î·|¦A¦V¸Óµøµ¡¨ç¦¡µo¥X WM_PAINT °T®§¡A¦Ó«á´N¯à¶i¦æ´yÂIªºÃ¸¹Ï¥ô°È¤F¡C
¦Ü©óµL®Ä°Ïªº³]©w¬O§Q¥Î«e¤@³¹©Ò´£¨ìªº InvalidateRect API¡A¦ý¦¹³B¤£³]©w¾ãÓ¤u§@°Ï³£¬OµL®Ä°Ï¡A³o¼Ën«Ã¸ªº³¡¥÷¤Ó¦h·|°§C®Ä²v¡A¤p¤ì°¸¶È§â¤u§@°Ïªº¬Y³¡¥÷³]¬°µL®Ä°Ï¡C¸Ó°Ï°ìªº¦ì¸m¬O¨Ì¾Ú©ßª«½uªº x ®y¼Ð¨M©w¡A¨ä½d³ò¬O¥Ñ¥ª¤W¨¤®y¼Ð ( x¡A0 ) ¨ì¥k¤U¨¤®y¼Ð ( x¡Ï2¡A250 ) ³o¼Ë¤@¶ô¯Uªø§Îªº°Ï°ì¡A³o¶ô½d³ò©ñ¦b invalid µ²ºcÅéùØ¡CµL®Ä°Ï³]©w«á¡Aµ{¦¡±N¦¬¨ì WM_PAINT °T®§´N¥i¥H´yÂI¤F¡C
SetPixel ¬O¥Î¨Ó¦bµøµ¡¤W´yø¤@ÓÂIªº API¡A쫬¬°¡G
COLORREF SetPixel( HDC hdc, // handle of device context int X, // x-coordinate of pixel int Y, // y-coordinate of pixel COLORREF crColor // pixel color );
hdc ¬O³]³Æ¤º®e¡A¦¹³Bª½±µ¥Ñ¤W¤@¦æªº BeginPaint ªð¦^ȶñ¤J¡CX ¬On´y¥XÂIªº X ®y¼Ð¡AY ¬On´y¥XÂIªº Y ®y¼Ð¡AcrColor ªí¥Ün³]´yøÂIªºÃC¦â¡C°²¦p¦¨¥\¡A·|¶Ç¦^³Qµe¥XÂIªºÃC¦â¡A§Y crColor¡A©ó EAX¡FY¥¢±Ñ EAX ¬°¡Ð1¡C
²Ä¤G¡B¤T³¹ªºµ{¦¡¡A·í¨Ï¥ÎªÌ«ö¤UÃö³¬¶s©ÎªÌ¥Ñ¿ï³æªº¡yÀɮסz¿ï¾Ü¡yÂ÷¶}¡z®É¡A¤p¤ì°¸³£¬O§Q¥Î DefWindowProc ¨Ó³B²zºR·´µøµ¡ªº¤u§@¡AWM_CLOSE ¶Ç°e¨ì DefWinProc ·|¤Þµo¤@³s¦êªº°T®§¡A¦p WM_DESTROY¡BWM_QUIT¡C°Ñ¦Ò²Ä¤G³¹µ²§ôµ{¦¡¡C
°£¤F¥Î¤º©wªº DefWindowProc ³B²z WM_CLOSE °T®§¥~¡A·íµM§Ṳ́]¥i¥H¦Û¤v³B²z WM_CLOSE¡CPARABOLA.ASM ³oÓµ{¦¡´N¬O¤@Ó¨Ò¤l¡C
¦¹³B¤p¤ì°¸¥Î«Ü²³æªº¤è¦¡¡AMessageBox ¨Ó¸ß°Ý¬O§_¯uªºÂ÷¶}µ{¦¡¡C°²¦p¨Ï¥ÎªÌ«ö¤U¡y§_¡zªº¸Ü¡Aªí¥Ü¤£¬O¯uªºnµ²§ôµ{¦¡¡A©Ò¥H¡A©ó¬O¤°»ò¨Æ¤]¤£°µª½±µ¸õ¨ì exit ¼Ð°O³B¡C
°²¦p¨Ï¥ÎªÌ«ö¤U¡y¬O¡zªº¸Ü¡A¨º»òªí¥Ünµ²§ôµ{¦¡¤F¡C´N¥²¶·ÄÀ©ñp®É¾¹¤ÎºR·´µøµ¡¡C©M¥H«e¤£¦Pªº¬O¡A²Ä¤G¡B¤T³¹ªºµ{¦¡¬O¥Ñ DefWindowProc ¦Û°Ê³B²z¡A¦ý¦b³oÓµ{¦¡ùØ´N¥²¶·¦Û¤v³B²zºR·´µøµ¡ªº¤u§@¤F¡C¦³Ó API ¨ç¦¡¡ADestroyWindow¡A¥i¥H¹F¦¨³oӥتº¡C
¨ä»yªk¦p¤U¡G
BOOL DestroyWindow( HWND hWnd // handle to window to destroy );
³oÓ API ¬OºR·´«ü©wªºµøµ¡ªº¡A¥¦¥u¦³¤@ӰѼơA´N¬O±N³QºR·´µøµ¡ªºµøµ¡¥N½X¡A°²¦p¦¨¥\ªº¸Ü¡A EAX ·|¶Ç¦^«D¹sÈ¡A¨Ã¥Bµo¥X WM_DESTROY ©M WM_NCDESTROY °T®§¨Ã¥B¨Ï¸Óµøµ¡Åܦ¨¤£¬O¦b³Ì¤W¼hªºÃöª`µJÂI¤W¡C°²¦p¥¢±Ñªº¸Ü EAX ¶Ç¦^¹s¡C
§ÚÌ¥i¥H³o¼Ë»¡¡A·íµøµ¡¨ç¦¡¦¬¨ì WM_DESTROY °T®§®É¡Aµøµ¡¤w³QºR·´¡Aµ{¦¡µLªk¦A¤Ï®¬¡C·íµøµ¡¨ç¦¡¦¬¨ì WM_CLOSE ®É¡Aµøµ¡ÁÙ¥¼³QºR·´¡A³oÓ°T®§¥u¬O§iª¾¨Ã¥¼¯uªº¦æ°Ê¡Aµ{¦¡¥i¥H¦A½T©w¬O§_¯uªºn°õ¦æºR·´°Ê§@¡C
¥Î MASM 6.x ²ÕĶ¾¹ÁÙ¥i¥H¨Ï¥Î³\¦hºØ°ª¯Åªº±ø¥ó§PÂ_¦¡¤Î±ø¥ó¸õÅDªº°²«ü¥O¡A³o¨Ç°²«ü¥O¨Ï±o MASM 6.x ¶V¨Ó¶V¹³ PASCAL ©Î C/C¡Ï¡Ï¡A¤]¨Ï±oµ{¦¡³]p®v±o¥H§ó®e©öºûÅ@ì©lµ{¦¡¡C¥LÌ·|³Q MASM 6.x ²ÕĶ¾¹¦Û°Ê¦a²ÕĶ¦¨¾A·íªº¾÷±ñ½X¥H²Å¦Xµ{¦¡³]p®v©Ò·Qnªº±±¨î¬yµ{¡A¦Óµ{¦¡³]p®v´N¥i¥H¤£¥²¦A®ö¶O¤ß¤O©ó³o¨Ç·Ðº¾ªº²Ó¸`¡C°²¦p±z·Q¦b DOS ¨t²Î¤U¼¶¼g²Õ¦X»y¨¥¡A³o¨Ç°ª¯Åªº±±¨î¬yµ{°²«ü¥O¤]¯à°÷¨Ï¥Î¡A³o¼Ë±zªºµ{¦¡´N¤ñ§O¤H¦nºûÅ@±o¦h¡C
¦b²Õ¦X»y¨¥±Ð¾Çªº²Ä 26 ³¹¥¨¶°»P²Ä 27 ³¹±ø¥ó²ÕĶ¨â³¹ùØ¡A´¿¸g´£¨ì IF/ELSE/ENDIF °²«ü¥O¡A³o¨Ç«ü¥O«e¨S¦³¤p¼ÆÂI¡A¦Ó¥B¦b·N¸q¤W©M©³¤U¤p¤ì°¸±N¤¶²Ðªº¨âºØ°ª¯Å¬yµ{±±¨î§¹¥þ¤£¦P¡C
¥ý¨Ó¬Ý¬Ý¥¦ªº»yªk¡J
.WHILE §PÂ_¦¡ µ{¦¡ .ENDW
³oÓ .WHILE/.ENDW °j°éªº°õ¦æ¹Lµ{¦p¤U¡J·íµ{¦¡°õ¦æ¨ì .WHILE ®É¡A·|Àˬd§PÂ_¦¡¬O§_¬°¯u¡A°²¦p¬°¯u¡A«h°õ¦æ .WHILE »P .ENDW ¤§¶¡ªºµ{¦¡¡Aª½¨ì¹J¨ì .ENDW ®É¡A¦A¦^¨ì¶}ÀY .WHILE ³BÀˬd§PÂ_¦¡¬O§_¬°¯u¡AY¬°¯u®É¡A¦A«×°õ¦æ .WHILE »P .ENDW ¤§¶¡ªºµ{¦¡¡AY¬°°²¡A«h¸õ¨ì .ENDW ¤U¤@¦æµ{¦¡°õ¦æ¡C©Ò¥H¬Ý°_¨Ó¡A.WHILE/.ENDW ´N¹³¬O C/C¡Ï¡Ï ªº WHILE {} °j°é¤@¼Ë¡C
¦Ü©ó§PÂ_¦¡ªº¼Ò¼Ë¡A¤jP¥i¤À¬°¨âºØ¡J
¼È¦s¾¹©ÎÅÜ¼Æ ÅÞ¿è¹Bºâ¤l ¼È¦s¾¹©Î¼ÆÈ ¼È¦s¾¹©ÎÅܼƩμÆÈ
¤W±¨º¤@ºØ±¡§Î®É¡A¹Bºâ¤l¥ª¥k¨âÃä¥i¥H¦P®É¬°¼È¦s¾¹¡A¦ý¤£¯à¦P®É¬°ÅܼơA³o¬O¦]¬°¦b 80X86 «ü¥OùØ¡A¥i¥H¦³ cmp ax,bx¡A¦ý¨S¦³ cmp a,b ³o¼Ëªº«ü¥O¡C°²¦p¬°¤U±¨º¤@ºØ±¡§Î®É¡A¼È¦s¾¹¡BÅܼơB¼ÆȬ°«D¹s®É¡A·|³Q²ÕĶ¾¹»{¬°¡y¯u¡z¡F¬°¹s®É¡A³Q»{¬°¡y°°¡z¡C
±`¥ÎªºÅÞ¿è¹Bºâ¤l¦p¤Uªí¡J
¹Bºâ¤l | ´yz | ¹Bºâ¤l | ´yz |
== | µ¥©ó | != | ¤£µ¥©ó |
> | ¤j©ó | >= | ¤j©óµ¥©ó |
< | ¤p©ó | <= | ¤p©óµ¥©ó |
&& | ¥B | ¦¦ | ©Î |
! | «D |
°£¤F³o¨ÇÅÞ¿è¹Bºâ¤l¤§¥~¡A¨âÓ§PÂ_¦¡¤§¶¡¤]¥i¥H°µ¡y©Î¡z»P¡y¥B¡zªºÅÞ¿è¹Bºâ¡A³o®É¡y©Î¡zn¥Î¦¦¡A¡y¥B¡zn¥Î&&¡A¨Ó³s±µ¨âÓ§PÂ_¦¡¡A¨Ã¥B³o¨âÓ§PÂ_¦¡À³¸Ó¥Î¨â¹ï¤p¬A¸¹¬A°_¨Ó¡C¨Ò¦p¡A©³¤Uªº¨Ò¤l¬O·í AX ¤j©ó SI ¥B BX ¤j©ó DI ®É¡A¨Ï CX ¼W¥[¤@¡A¨Ã¨Ï BX ´î¤@¡Aª½¨ì¤Wz±ø¥ó¤£¦¨¥ß®É¡J
.WHILE (ax>si)&&(bx>di) inc cx dec bx .ENDW
©³¤Uªº¨Ò¤l¬O·í AX ¤£µ¥©ó¹s®É¡A§â BX ©Ò«ü¦ì§}¤§¼ÆȲ¾¤J AX¡Aª½¨ì AX µ¥©ó¹s®É°±¤î¡J
.WHILE AX mov ax,[bx] inc bx inc bx .ENDW
¦b .WHILE/.ENDW °j°éùØ¡A¤]¥i¥H¥[¤W .BREAK °²«ü¥O¡A±j¨î°h¥X°j°é¡A°²¦p¦b .BREAK «á¥[¤W .IF ªí¥Ü¥u¦³¦b .IF ¤§«áªº±ø¥ó¬°¡y¯u¡z®É¡A¤~°h¥X°j°é¡C¨Ò¦p¡J
.WHILE TRUE lodsw .BREAK .IF !AX add bx,ax .ENDW
¤W±³oÓ¨Ò¤l¬O§â SI ©Ò«üªº°O¾ÐÅé¼ÆȲ¾¤J AX ¤¤¡A¦P®É SI ¦Û°Ê«ü¦V¤U¤@¦ì§}¡A¨Ã¨Ï BX ¤§¼ÆÈ»P AX ¬Û¥[¡A¦A¦s¤J AX ùØ¡Aª½¨ì AX µ¥©ó¹s®É°h¥X .WHILE/.ENDW °j°é¡C
³Ì²³æªº±¡§Î¬O¡J
.IF §PÂ_¦¡ µ{¦¡¤@ .ELSE µ{¦¡¤G .ENDIF
³oÀ³¸Ó«Ü®e©ö¤F¸Ñ¡A·í§PÂ_¦¡¬°¡y¯u¡z®É°õ¦æµ{¦¡¤@ùتº«ü¥O¡F¬°¡y°°¡z®É´N°õ¦æµ{¦¡¤Gùتº«ü¥O¡A°²¦p¬°¡y°°¡z®É¤£¥Î°õ¦æ¥ô¦ó«ü¥O¡A«h .ELSE ¥H¤Îµ{¦¡¤G¥i¥H§R°£¡C©³¤U¬O¤@Ó¤ñ¸û½ÆÂøªº¨Ò¤l¡A
.IF §PÂ_¦¡¤@ µ{¦¡¤@ .ELSEIF §PÂ_¦¡¤G µ{¦¡¤G .ELSEIF §PÂ_¦¡¤T µ{¦¡¤T .ELSE µ{¦¡¥| .ENDIF
³o¬O¤À¤ä«ü¥O¡A°²¦p§PÂ_¦¡¤@¬°¯u¡A«h°õ¦æµ{¦¡¤@ªº«ü¥O¡F°²¦p§PÂ_¦¡¤G¬°¯u¡A«h°õ¦æµ{¦¡¤Gªº«ü¥O¡F°²¦p§PÂ_¦¡¤T¬°¯u¡A«h°õ¦æµ{¦¡¤Tªº«ü¥O¡K¡K¡A°²¦p³£¤£¬O¤W±ªº±¡§Î¡A«h°õ¦æ .ELSE ¤§«áªºµ{¦¡¡C
¦¹³B¤p¤ì°¸±N¥H .WHILE/.ENDW ©M .IF/.ELSEIF/.ELSE/.ENDIF קï PARABOLA.ASM ¨Ï¦¨ PARABOL1.ASM¡Aקï«áÅܱo§ó¨ã¥iŪ©Ê¡J
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32
33 34 35 36
37 38 39 40
41 42 43 44
45 46 47 48
49 50 51 52
53 54 55 56
57 58 59 60
61 62 63 64
65 66 67 68
69 70 71 72
73 74 75 76
77 78 79 80
81 82 83 84
85 86 87 88
89 90 91 92
93 94 95 96
97 98 99 100
101 102 103 104
105 106 107 108
109 110 |
.386
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE
INCLUDE WINDOWS.INC
INCLUDE USER32.INC
INCLUDE GDI32.INC
INCLUDE KERNEL32.INC
INCLUDELIB USER32.LIB
INCLUDELIB GDI32.LIB
INCLUDELIB KERNEL32.LIB
TimerID EQU 74
color EQU 0ffh
WndProc PROTO :HWND,:UINT,:WPARAM,:LPARAM
;*******************************************************************************
.DATA
ClassName DB 'SimpleWinClass',0
AppName DB '©ßª«½u',0
AskExit DB '¬O§_°h¥X¦¹µ{¦¡¡H',0
AskExitTitle DB '¸ß°Ý',0
x DD 0
y DD ?
two_hundred DW 200
hInstance HINSTANCE ?
hwnd HWND ?
CommandLine LPSTR ?
wc WNDCLASSEX <30h,?,?,0,0,?,?,?,?,0,OFFSET ClassName,?>
msg MSG <?>
;*******************************************************************************
.CODE
;-------------------------------------------------------------------------------
start: INVOKE GetModuleHandle,NULL
mov hInstance,eax
INVOKE GetCommandLine
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,OFFSET WndProc
mov eax,hInstance
mov wc.hInstance,eax
mov wc.hbrBackground,COLOR_WINDOW+1
INVOKE LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
INVOKE LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
INVOKE RegisterClassEx,OFFSET wc
INVOKE CreateWindowEx,NULL,OFFSET ClassName,OFFSET AppName,\
WS_OVERLAPPEDWINDOW,0,10,410,250,0,0,hInstance,NULL
mov hwnd,eax
INVOKE ShowWindow,hwnd,SW_SHOWDEFAULT
INVOKE UpdateWindow,hwnd
.WHILE TRUE
INVOKE GetMessage,OFFSET msg,NULL,0,0
.BREAK .IF !eax
INVOKE TranslateMessage,OFFSET msg
INVOKE DispatchMessage,OFFSET msg
.ENDW
mov eax,msg.wParam
INVOKE ExitProcess,eax
;-------------------------------------------------------------------------------
WndProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL PS:PAINTSTRUCT
LOCAL invalid:RECT
.IF uMsg==WM_CREATE
INVOKE SetTimer,hWnd,TimerID,100,NULL
.ELSEIF uMsg==WM_TIMER
.IF x<400
mov invalid.top,0
mov invalid.bottom,250
mov eax,x
finit
fild x
fisub two_hundred
fmul st,st
fidiv two_hundred
fistp y
mov invalid.left,eax
add eax,2
mov invalid.right,eax
INVOKE InvalidateRect,hWnd,addr invalid,FALSE
inc x
.ENDIF
.ELSEIF uMsg==WM_PAINT
INVOKE BeginPaint,hWnd,addr PS
INVOKE SetPixel,eax,x,y,color
INVOKE EndPaint,hWnd,addr PS
.ELSEIF uMsg==WM_CLOSE
INVOKE MessageBox,hWnd,addr AskExit,\
addr AskExitTitle,MB_YESNO or MB_ICONQUESTION
.if eax==IDYES
INVOKE KillTimer,hWnd,TimerID
INVOKE DestroyWindow,hWnd
.endif
.ELSEIF uMsg==WM_DESTROY
INVOKE PostQuitMessage,NULL
.ELSE
INVOKE DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc ENDP
;*******************************************************************************
END start
|
³oÓ PARABOL1.ASM µ{¦¡©M¤W± PARABOLA.ASM µ{¦¡¬O¤@¼Ëªº¡A¥u¬O¥H¸û¨ã¥iŪ©Êªº¤è¦¡¼¶¼gµ{¦¡¡CPARAMBOL1.ASM µ{¦¡¤p¤ì°¸´N¤£¥[¥H¸ÑÄÀ¤F¡C