ªþ¿ý¤T¡@¥H¹ï¸Ü²°¬°¬É­±ªºµ{¦¡


³Ìªñ¦³¤H°Ý§Ú³o»ò¤@¹D¼Æ¾ÇÃD¡G¡y100¡I¡×100¡Ñ99¡Ñ98¡Ñ97¡Ñ¡K¡K¡Ñ2¡Ñ1 ªº­¼¿n¥½¦ì¼Æ¦³´X­Ó¹s¡H¦Ó¥Ñ³Ì¥½¤@¦ì©¹«eºâ¡A²Ä¤@­Ó«D¹sªº¼Æ¬O¤°»ò¡H¡z¡C¦b¼Æ¾Ç¤Wªº·Qªk«Ü²³æ¡A¥u­n 2¡Ñ5 ´N·|±o¨ì 10¡A´N·|¨Ï¥½¦ì¦h¤@­Ó¹s¡A¦Ó¦b 100¡Iªº­¼ªkùØ¡A2 ªº¦]¼Æ¤ñ 5 ¦h±o¦h¡A©Ò¥H¥u­nºâ¥X 100¡B99¡B98¡K¡K3¡B2¡B1 ³o¨Ç¼Æùئ³´X­Ó 5 ªº¦]¼Æ§Y¥i¡C±q¤@¨ì¤Q¦³ 5¡B10 §t¦³¨â­Ó 5 ªº¦]¼Æ¡A11 ¨ì 20 ¤]¦³¨â­Ó 5 ªº¦]¼Æ¡K¡K¬G¨C¤Q­Ó¼Æ¦³¨â­Ó¤­¡A©Ò¥H 1 ¨ì 100 ¦Ü¤Ö¦³ 20 ­Ó 5 ªº¦]¼Æ¡A°£¦¹¤§¥~¡A¹³ 25¡B50¡B75¡B100 ³o¥|­Ó¼Æ§t¦³¨â­Ó 5 ªº¦]¼Æ¡A¦©°£«e­±¤w¸gºâ¹Lªº¡A¥u³Ñ 4 ­Ó 5 ªº¦]¼Æ¡A³Ì«áÁ`¥[°_¨Ó¡A100¡I¦³24 ­Ó¦]¼Æ 5¡A©Ò¥H¥½¦ì¼Æ¦³ 24 ­Ó 0¡C

¦Ü©ó 100¡I ªº¥½¦ì¼Æ²Ä¤@­Ó«D¹sªº¼Æ¬O¤°»ò¡H·Qªk¤]¬O¥H¨C 10 ­Ó¼Æ¬°¤@²Õ¡A¨C²Õ­¼°_¨Óªº¥½¦ì¼Æ³£¬Û¦P¡A³£¬O 1¡Ñ2¡Ñ3¡Ñ4¡Ñ¡K¡K9¡Ñ10¡A¥½¦ì²Ä¤@­Ó«D¹sªº¼Æ¬O 8¡A810ªº­Ó¦ì¼Æ¬O 4¡A¬G²Ä¤G­Óµª®×¬O 4¡CÁöµM¦³¤Fµ²ªG¡A¦ý¬OÁ`·Q¥Hµ{¦¡¹ê»Úºâ¥X¨Óµª®×¬O§_¥¿½T¡A¾ú¸g¤@¬q«ä¯Á¡A³Ì«á²×©ó§â³o­Ó­pºâ¶¥­¼ªºµ{¦¡¡AFACTORIAL.ASM¡A¼g¦n¤F¡A©ó¬O¦³¤F³o­Óªþ¿ý¡C³o­Óµ{¦¡°õ¦æµe­±¦p¤U¡A¤@¶}©l¨Ï¥ÎªÌ¥¼¿é¤J¼Æ¦r¡A¬G¨S¦³­pºâµ²ªG¡A¡y«þ¨©µ²ªG¡z»P¡y¦s¦¨¡K¡z«ö¶s¬O¸T¥Îªº¡C·í¨Ï¥ÎªÌ¿é¤J¦n¼Æ¦r¡A¨Ò¦p 100¡A¦A«ö¤U¡y­pºâ¡z«ö¶s¡AFACTORIAL ·|­pºâ 100¡I¨Ã±Nµ²ªGÅã¥Ü¦b©³¤Uªº°ßŪ½s¿è®ØùØ¡C

FACTORIAL.EXE °õ¦æµe­±

¨Ï¥ÎªÌ¤]¥i¥H«ö¤U¡y«þ¨©µ²ªG¡z«ö¶s§âµ²ªG«þ¨©¶i¡y°Å¶Kï ( clipboard )¡z¡A¤]¥i¥H«ö¤U¡y¦s¦¨100!.TXT¡z«ö¶s¡A§â­pºâµ²ªG¦s¨ì®à­±¤W¡C¦pªG¨Ï¥ÎªÌÁÙ­n¦Aºâ¥t¤@¼Æªº¶¥­¼¡A§â·Æ¹«²¾¨ì½s¿è®Ø¨Ã«ö¤U·Æ¹«¥ªÁä©Î§ïÅܽs¿è®Øªº¤º®e®É¡A¡y«þ¨©µ²ªG¡z»P¡y¦s¦¨¡K¡z«ö¶s·|Åܦ¨¸T¥Îªº¼Ë¤l¡A·í¿é¤J¦n¼Æ¦r¦A«ö¤U¡y­pºâ¡z«ö¶s«á¡A¡y«þ¨©µ²ªG¡z»P¡y¦s¦¨¡K¡z«ö¶s¤S·|¦A«×³Q±Ò¥Î¡C

¤p¤ì°¸¦b¼¶¼g³o­Óµ{¦¡®É¡A°£¤F³o­Óµ{¦¡¬O¡y¥H¹ï¸Ü²°¬°¬É­±ªºµ{¦¡¡z¡A¦ý¬O¹ê»Ú¤WÁÙ²o¯A¨ì©³¤U´X­Ó¥DÃD¡G¡y¤j¼Æªº­¼ªk¡z¡B¡y§â½s¿è®Øªº¸ê®Æ«þ¨©¨ì°Å¶Kï¡z¡B¡y¨ú±o®à­±¸ô®|¡z¥H¤Î¡y½s¿è®Øªº³qª¾½X¡zµ¥¡A©Ò¥H¤£ª¾¹D¦p¦ó­q¥X³o½g¥Ø¿ýªºÃD¥Ø¡G)


¥H¹ï¸Ü²°¬°¬É­±ªºµ{¦¡

FACTORIAL ¬O¤@­Ó¹ï¸Ü²°·í¦¨¬É­±ªºµ{¦¡¡A³o¤@Ãþµ{¦¡¥»¨­´N¬O¤@­Ó¹ï¸Ü²°¡A¨ä¤º³¡¦³³\¦h±±¨î¤¸¥ó²Õ¦¨¡A¥¦¬OÂÇ¥Ñ DialogBoxParam ²£¥Íªº¡A§Ú­Ì¦b¼¶¼gµ{¦¡®É¡A¥u»Ý­n¦b¸ê·½´y­zÀɤ¤ªº¹ï¸Ü²°­±ªO¬q¸¨ùØ»¡©ú³o¨Ç±±¨î¤¸¥ó¦p¦ó¦w±Æ¡A¥H¤Î¼¶¼g¹ï¸Ü²°¨ç¦¡ ( ¹ï¸Ü²°¨ç¦¡»Pµøµ¡¨ç¦¡³£¬OÄÝ©ó¡ycall back¡z¨ç¦¡¡AÃö©ó¤°»ò¬O call back ¨ç¦¡¡A½Ð°Ñ¦Ò²Ä¤G³¹³B²z°T®§ªºµøµ¡¨ç¦¡²Ä¤T¬q ) §Y¥i¡C¨t²Î´N·|¬°§Ú­Ì«Ø¥ß¦n¦U±±¨î¤¸¥ó¡AµM«á¹ï¸Ü²°ºÞ²z¾¹·|©I¥s§Ú­Ì¦Û¦æ¼¶¼gªº¹ï¸Ü²°¨ç¦¡¡A¦¹¹ï¸Ü²°¨ç¦¡±N³B²z§Ú­Ì·P¿³½ìªº°T®§¡C·íµM¡A³o¨Ç°T®§³B²z§¹¤§«á¡Aªð¦^­È¬° TRUE¡Aªí¥Ü¤w³B²z¹L¤F¡F§Ú­Ì¤£·P¿³½ì¦Ó¤£³B²zªº°T®§¡A«hªð¦^­È¬° FALSE¡A¥Ñ¨t²Î¤º³¡ªº¹ï¸Ü²°ºÞ²z¾¹¥h³B²z¡C¦b²Ä¤Q³¹¤]´£¨ì¹L³oÃþªº¹ï¸Ü²°¡AºÙ¬°¼Ò¦¡¹ï¸Ü²°¡A©Ò¤£¦Pªº¬O¦b²Ä¤Q³¹ªº¼Ò¦¡¹ï¸Ü²°¬O¥Ñ¥t¤@­Óµøµ¡©Ò«Ø¥ß¡A¦Ó¦¹³B¥H¹ï¸Ü²°¬°¬É­±ªºµ{¦¡«h¬Oª½±µ©I¥s DialogBoxParam «Ø¥ß¡C¨ä¤j­Pªº°©¬[¹³©³¤U³o¼Ë¡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
                OPTION  CASEMAP:NONE
                .586
                .MODEL  FLAT,STDCALL
INCLUDE         WINDOWS.INC
INCLUDE         COMCTL32.INC
INCLUDE         KERNEL32.INC
INCLUDE         USER32.INC
INCLUDELIB      COMCTL32.LIB
INCLUDELIB      KERNEL32.LIB
INCLUDELIB      USER32.LIB
;*************************************************************************************************************
.DATA
hInstance       HANDLE  ?
szDlgName       BYTE    "DIALOG",0      ;¹ï¸Ü²°­±ªO¦WºÙ
;¨ä¥L¸ê®Æ
;*************************************************************************************************************
.CODE
;-------------------------------------------------------------------------------------------------------------
;¹ï¸Ü²°¨ç¦¡
DlgProc         PROC    hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.IF uMsg==WM_INITDIALOG
 
.ELSEIF uMsg==WM_COMMAND
 
.ELSEIF uMsg==WM_CLOSE
                INVOKE  EndDialog,hDlg,NULL
 
.ELSE           ;¨ä¥L¥¼³B²zªº°T®§ªð¦^ FALSE
                mov     eax,FALSE
                ret
 
.ENDIF          ;¤w³B²zªº°T®§¡Aªð¦^ TRUE
                mov     eax,TRUE   
                ret
DlgProc         ENDP
;-------------------------------------------------------------------------------------------------------------
start:          INVOKE  GetModuleHandle,NULL
                mov     hInstance,eax
                INVOKE  DialogBoxParam,hInstance,OFFSET szDlgName,NULL,OFFSET DlgProc,NULL
                INVOKE  ExitProcess,eax
                INVOKE  InitCommonControls
;*************************************************************************************************************
END             start

¤W­±ªºµ{¦¡¡A´N¬O¥H¹ï¸Ü²°¬°¥Dªºµ{¦¡¡A¨ä¤¤¶È³B²z WM_INITDIALOG ¡BWM_COMMAND¡BWM_CLOSE ³o¤T­Ó°T®§¡A³B²z¹L¦¹¤T­Ó°T®§«áªð¦^ TRUE¡A§_«hªð¦^ FALSE¡C»P¤W­z²Õ¦X»y¨¥­ì©lµ{¦¡¤§°t¦Xªº¸ê·½´y­zÀÉ¡A¤@¯ë¦p¤U­±¡G

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "c:\masm32\include\resource.h"
 
#define  RT_MANIFEST     24
 
//¨ä¥L±±¨î¤¸¥óªºÃѧO½X
 
¹ï¸Ü²°­±ªO¦WºÙ  DIALOG  x, y, cx, cy
STYLE   ­·®æ
FONT    ¤j¤p ,"¦r«¬"
CAPTION "¼ÐÃD¦W"
BEGIN
  ±±¨î¤¸¥ó
END
1       RT_MANIFEST MOVEABLE PURE "µ{¦¡¦W.exe.manifest"

«Ü©úÅã¡A¥H¹ï¸Ü²°¬°¬É­±ªºµ{¦¡¬Ù²¤¤F¹³µù¥Uµøµ¡Ãþ§O¡B«Ø¥ß°T®§°j°éµ¥µ{¦¡½X¡A¦P®É¤]¤£»Ý­n©I¥s DefWindowProc ³B²z§Ú­Ì¤£­«µøªº°T®§¡A¥i¥H»¡¬O¤è«K¤S²¼ä¡C

ÁöµM¦p¦¹¡A¦ý¬O¦pªG­n¦bµøµ¡¤¤¨Ï¥Î¹Ï¥Ü¡A´N±o¦b³B²z WM_INITDIALOG °T®§®É¡A©I¥s LoadIcon ¦Û¸ê·½¸ü¤J¹Ï¥Ü¡C§Ú­Ì±`¦b³B²z WM_INITDIALOG °T®§®É¡A°µ¤@¨Çªì©l¤Æªº°Ê§@¡A¨Ò¦p¨ú±o±±¨î¤¸¥ó¥N½Xµ¥µ¥¡A¨ú¥N¤@¯ëµøµ¡ªº WM_CREATE °T®§¡C¦bÃö³¬¹ï¸Ü²°®É¡A«h¬O³B²z WM_CLOSE °T®§¡A¨Ã¦b³B²z¦¹°T®§®É©I¥s EndDialog Ãö³¬¹ï¸Ü²°¡C¦¹¥~¡A¥H¹ï¸Ü²°¬°¬É­±ªºµ{¦¡¬O¥Ñ¹ï¸Ü²°ºÞ²z¾¹³B²z«öÁä°T®§¡A¦]¦¹¹ï©ó§Ö±¶Á䪺¨Ï¥Î¡A´N±o¦h¶O¤u¤Ò¤F¡C


¤j¼Æªº­¼ªk

§Y¨Ï¬O¨Ï¥Î 128 ¦ì¤¸ªº­¼ªk«ü¥O¡A¤]¥u¯àºâ¨ì 39 ¦ì¼Æ¡A¦ý¬O¹ï¶¥­¼¨ÓÁ¿ 34¡I´N¤w¸g¬O 39 ¦ì¼Æ¤F¡A34 À³¸Ó»¡¬O«Ü¤pªº¼Æ§a¡H¦]¦¹¥H 128 ¦ì¤¸ªº­¼ªk«ü¥O¡AµLªkº¡¨¬»Ý¨D¡C¦pªG­nºâ¤ñ¸û¤jªº¼Æªº¶¥­¼¡A¥i¥H¥Î´µ¯SªL¤½¦¡¨D±o¡A¦ý¬O¦pªG­nºâ±o¤@²@¤£®t¡A´N±o¦Û¦æ¼¶¼g¤@­Ó­¼ªk°Æµ{¦¡¤F¡A¦Ó³o­Ó­¼ªk°Æµ{¦¡¯à°µ«Ü¤j¼Æ¦rªº­¼ªk¡A¦A§Q¥Î°j°é´N¯à«Ü§Öªº ( ¤]¥i¯à¬O«ÜºCªº ) ¨D¥X¸û¤j¼Æªº¶¥­¼¡C

¦¹¤@¤j¼Æ­¼ªk°Æµ{¦¡ºÙ¬° ubcd_mul¡A¨ä­ì²z«Ü²³æ¡A¨ä¹ê´N¬O¤p¾Ç¦Ñ®v©Ò±Ðªºª½¦¡­¼ªk¡C¤p¤ì°¸¥H 987654¡Ñ912¡×900740448 ¬°¨ÒÆ[¹î¡G

 ³Q­¼¼Æ     987654
 ­¼¼Æ     x    912
        ----------
        001975308
 ¼È¦s°Ï  009876540
        888888600
        ----------
        900740448

³Q­¼¼Æ¦@¦³ 6 ¦ì¼Æ¡A­¼¼Æ¬° 3 ¦ì¼Æ¡A©Ò±oªº­¼¿n¬O¥H¨C¤@¦ì­¼¼Æ©M³Q­¼¼Æ¬Û­¼©Ò±o¤§µ²ªG¡A¥ý¼È®É¦s©ó¼È¦s°Ï¡A«Ý¤T¦ì­¼¼Æ³£½ü¬y»P³Q­¼¼Æ¬Û­¼¤§«á¦A¬Û¥[¡C¦b¼È¦s°Ïùتº¨C¤@¦Cªº¦ì¼Æ¬Ý°_¨Ó¦n¹³³£¬O³Q­¼¼Æªº¦ì¼Æ¦A¥[¤@¡A¦ý¹ê»Ú«o¤£¬O¦p¦¹¡A¦Ò¼{¤§«áÁÙ­n§â¼È¦s°Ï¤¤ªº¤T¦C¼Æ¬Û¥[¡A©Ò¥H²Ä¤@¦C¤§«eÀ³¸ÓÁÙ¦³¨â­Ó¹s¡A¦P²z¨ä¥L¦C¤]³£¬O¤@¼Ë¡A¦]¦¹¼È¦s°Ïªº¤j¤pÀ³¸Ó¬O¡y­¼¿n¦ì¼Æ¡Ñ­¼¼Æ¦ì¼Æ¡z¡C¦Ó­¼¿n¦ì¼ÆÀ³¸Ó¬O¡y³Q­¼¼Æ¦ì¼Æ¡Ï­¼¼Æ¦ì¼Æ¡z¡C´«¥y¸Ü»¡¡A¦pªG­nºâ¤j¼Æªº­¼ªk¡A¼È¦s°Ï¥i¯à»Ý­n«Ü¤jªº°O¾ÐÅé¡A­n°t¸m¦h¤Ö°O¾ÐÅé©O¡H¥H 987654¡Ñ912¡×900740448 ¬°¨Ò»¡©ú¡A¼È¦s°Ï­n¦û¥Î 3¡Ñ(3¡Ï6) ¦ì¡A­¼¿n­n¦A¦û¥Î (3¡Ï6) ¦ì¡A³Q­¼¼Æ»P­¼¼Æ¤S­n¦A¥[¤W (3¡Ï6) ¦ì¡A¬GÁ`¦@­n¦û¥Î 5¡Ñ(3¡Ï6) ¦ì¡A¦pªG¨C­Ó¼Æ¦û¥Î¤@­Ó¦ì¤¸²Õ¡A¨º»ò´N±o°t¸m 90 ­Ó¦ì¤¸²Õ¡C

FACTORIAL ³Q³]­p¦¨¥i¥H­pºâ³Ì¦h 65536 ¶¥­¼¡A¥Ñ¡y¶}©l¡z¡B¡y©Ò¦³µ{¦¡¡z¡B¡yªþÄÝÀ³¥Îµ{¦¡¡z¡y¤pºâ½L¡z¥iºâ¥X 65536¡I¦³ 287194 ¦ì¼Æ¡A¥ç§Y 16 ¶i¦ìªº 461DAH¡A¦ý¬O¤p¤ì°¸¥´ºâÀx¦s­¼¿nªº°O¾ÐÅé¤ñ 461DAH µy·L¤j¤@¨Ç¡A¬O 461E0H¡A´«¦¨¤Q¶i¦ì´N¬O 287200 ­Ó¦ì¤¸²Õ¡A¤p¤ì°¸¦b FACTORIAL ¤¤©w¸q¤F¤@­Ó±`¼Æ¡ALARGEST¡A¨Óªí¥Ü­¼¿nªº¦ì¼Æ¡G

        LARGEST EQU     461E0h

FACTORIAL ¥i¥H­pºâ¤­¦ì¼Æ ( 65536 ¬°¤­¦ì¼Æ ) ¥H¤Uªº¶¥­¼¡A¦]¦¹¼È¦s°Ï³Ì¦h¶È¤­¦C¡A¦Ó¨C¤@¦C»Ý­n®e¯Ç 461E0H ¦ì¼Æ¡A¬G¼È¦s°Ï»Ý­n 461E0H¡Ñ5 ­Ó¦ì¤¸²Õ¡A¦A¥[¤W­¼¿n±o¦û¥Î 461E0H ¥H¤Î­¼¼Æ¦û¥Î 10H ¦ì¤¸²Õ ( ¦h¤@ÂIÂI¤]¬OµL§« )¡A©Ò¥H±z·|¦b­pºâ¶¥­¼ªº Factorial °Æµ{¦¡¬Ý¨ì©I¥s GlobalAlloc ¦V¨t²Î¥Ó½Ð°t¸m°O¾ÐÅé¡G

        INVOKE  GlobalAlloc,GPTR,LARGEST*6h+10H ;¦V¨t²Î­n¨DLARGEST*6+10Hªº°O¾ÐÅé¤j¤p

FACTORIAL ³Ì«á­n§âµ²ªGÅã¥Ü¦b¤@­Ó¦h¦æªº½s¿è®Ø±±¨î¤¸¥óùØ¡A¦Ó¦h¦æªº½s¿è®Ø±±¨î¤¸¥ó¤º©w¥i¥H®e¯Ç¬ù 32K ¦ì¤¸²Õ ( ³o¬O«ü Win XP ¨t²Î¦Ó¨¥¡Aºë½Tªº¼Æ¦r¬O 30000 ­Ó¦ì¤¸²Õ¡C¦³Ãö½s¿è®Ø±±¨î¤¸¥óªº°T®§¡A½Ð°Ñ¦Ò²Ä¤E³¹ªº»¡©ú )¡A¤£¹L³o­Ó­­¨î¬O¥i¥H§ó§ïªº¡A¦Ó¥B§@·~¨t²Î·|¦Û°ÊÀ°À³¥Îµ{¦¡ÂX¤j®e¶q¡A©Ò¥H¨Ã¤£¶·¾á¤ß¦h¦æ½s¿è®Ø®e¶q¤£¨¬ªº°ÝÃD¡C

¥Ñ©ó¶¥­¼¬O³sÄòªº­¼ªk¡A¤p¤ì°¸¥´ºâ§â³Q­¼¼Æ©ñ¦b©Ò¥Ó½Ð°O¾ÐÅ骺³Ì§C¦ì§}¡A­¼¼Æ©ñ¦b³Q­¼¼Æ¤§«áªº¸û°ª¦ì§}¡A¦Ó©Ò±o­¼¿n´N©ñ¦b­ì¨Ó³Q­¼¼Æªº¦a¤è¡C¦p¦¹¤@¨Ó¡A¥ý¨Ï­¼¿n¬° 1¡A¨Ï­¼¼Æ¬°¨Ï¥ÎªÌ¿é¤Jªº¼Æ¡A©I¥s ubcd_mul °Æµ{¦¡±o¨ì²Ä¤@¦¸¬Û­¼ªºµ²ªG¡A±µµÛ¨Ï­¼¼Æ´î¤@¡A¦A©I¥s ubcd_mul ´N¥i±o²Ä¤G¦¸¬Û­¼¡A¦p¦¹¨C¤@¦¸¨Ï­¼¼Æ´î¤@¡Aª½¨ì¹s¬°¤î¡A´N¥i±o¶¥­¼¤F¡C

¤U¹Ï¬O¥H­pºâ 14350 ¶¥­¼»¡©ú°O¾ÐÅé³W¹º¡A¤p¤ì°¸¦V§@·~¨t²Î¥Ó½Ð°t¸m¤F LARGEST*6h+10H ( 1A4B50H¡A¬Û·í©ó¤Q¶i¦ìªº 1723216 ) ¦ì¤¸²Õ¡A¦p¤W­z©Ò¨¥¤À¦¨¤T­Ó°Ï¶ô¡G

  1. ³Q­¼¼Æ©Î­¼¿n ( ¥Ñ¦ì§} 0 ¨ì 461DFH¡A¦@ 287200 ¦ì¤¸²Õ )¡A¥Hµµ¦â­I´ºªí¥Ü¡C
  2. ­¼¼Æ ( ¥Ñ¦ì§} 461E0H ¨ì 461EFH¡A¦@ 16 ­Ó¦ì¤¸²Õ )¡A¥HÂŦâ­I´ºªí¥Ü¡C
  3. ¼È¦s°Ï ( ¥Ñ¦ì§} 461F0H ¨ì 1A4B4FH¡A¦@ 1436000 ¦ì¤¸²Õ )¡A¥H¶Â¦â­I´ºªí¥Ü¡C

¦b°t¸m°O¾ÐÅ餧«á¡A¥ý¨Ï­¼¿n¬° 1¡A¦s©ó¦¹°t¸m°O¾ÐÅ骺³Ì§C¦ì§}¡AµM«á§â 14350 Åܦ¨¥¼»E¶°ªº BCD ¼Æ¡A¦s©ó©Ò°t¸m°O¾ÐÅé°¾²¾¦ì§}ªº 461E0H ³B¡A¦¹³B§Ú°²³]­¼¼Æ¦³ 10 ¦ì¼Æ¡A±µµÛ¥Ñ­¼¼Æ°ª¦ì§}¶}©l¡A´M§ä²Ä¤@­Ó«D¹sªº¼Æ¡A´N¥i¥H§ä¨ì­¼¼Æ¯u¥¿¦ì¼Æ¡CµM«á©I¥s ubcd_mul °Æµ{¦¡¡A­pºâ¨ä­¼¿n¡A¨Ã¦s©ó©Ò°t¸m°O¾ÐÅ骺³Ì§C¦ì§}¡C´«¥y¸Ü»¡¡A·í ubcd_mul ªð¦^«á¡A©Ò°t¸mªº°O¾ÐÅé³Ì§C¦ì§}·|Åܦ¨ 0¡B5¡B3¡B4¡B1¡A¨ä¹ê³o´N¬O¥Nªí 14350¡Ñ1 ¤§«áªºµ²ªG¡A¦¹¼Æ¦s©ó°O¾ÐÅé¦ì§}ªº 0H ®É¡A¬O¥H¦ì¼Æ¤pªº¼Æ¦w±Æ¦b§C¦ì§}³B ( ¹³³oºØ¦w±Æ¤è¦¡ºÙ¬° Little-Endian )¡C¦p¤U¹Ïªº¤W¥b³¡©Ò¥Ü¡A¬O ubcd_mul ªð¦^«áªºµ²ªG¡A¼È¦s°Ï¤¤ªº¼Æ­È¤wÅܱo¤£­«­n¤F¡C

°O¾ÐÅé¤À°t

±µµÛ¨Ï­¼¼Æ´î¤@Åܦ¨ 14349¡A¦s©ó°O¾ÐÅé¦ì§} 461E0H ³B¡A¦¹®É³Q­¼¼Æ¤w¦s©ó©Ò°t¸m°O¾ÐÅé¦ì§} 0 ªº¦a¤è¤F¡A¦A©I¥s umbc_mul¡A·íªð¦^®É¡Aµ²ªG¦p¤W¹Ïªº¤U¥b³¡¥÷¡C¤S¬°¨ÏŪªÌ§ó²M·¡ ubcd_mul ¦b°O¾ÐÅ餤¹B§@¡A¤p¤ì°¸¦C¥X¨äª½¦¡­¼ªk¦p¤U¡G

       14350
x      14349
-------------
  0000129150
  0000574000
  0004305000
  0057400000
  0143500000
-------------
  0205908150

±z¥i¬Ý¨£¡A¼È¦s°Ïªº³Ì§C°¾²¾¦ì§}¡A461F0H¡A¦sµÛªº¬O 14350¡Ñ9 ¤§«áªºµ²ªG¡A¦] 14350¡Ñ14349 ¤§­¼¿n¦³ 10 ¦ì¼Æ ( °²·Q¥]§t¨S¦³¶i¦ìªº¹s )¡A¬G 14350¡Ñ4 ¦s©ñ¦ì§}¤ñ 14350¡Ñ9 °ª 10 ­Ó¦ì¤¸²Õ¡C¸Ó¹Ïªº¤U¥b³¡ÂŦ⪺¹s¬O¤j¦ì¼Æ³¡¥÷¡A¾ï¦âªº¹s¬O¤p¦ì¼Æªº³¡¥÷¡A¨C¤@­Ó­¼¼Æ­¼³Q­¼¼Æ®É¡A¦³¤T³¡¥÷¡C¼g¦¨ª½¦¡«Ü¦n¤À¿ë¡A¦ý¦b°O¾ÐÅé«Ü¤£®e©ö¬Ý±o¥X¨Ó¡C¦p¦¹¨C·í ubcd_mul ªð¦^®É¡A¨Ï­¼¼Æ´î¤@¡Aª½¨ì¬°¹s¬°¤î¡A­Y­¼¼Æ¬°¹s¥ß§Y¸õ¥X°j°é¡C

ubcd_mul °Æµ{¦¡¬O°õ¦æ¨â­Ó¥¼»E¶° BCD ¼Æ¬Û­¼ªº°Æµ{¦¡¡A³o­Ó°Æµ{¦¡¥D­n¦³¨â­Ó°j°é²Õ¦¨¡A²Ä¤@­Ó°j°é¬O°õ¦æ¨C¤@¦ì­¼¼Æ»P³Q­¼¼Æ¬Û­¼«áªºµ²ªG¡C¨C¤@¦ì­¼¼Æ»P³Q­¼¼Æ¬Û­¼³£¤À¦¨¤T­Ó³¡¥÷¡A½Ð¦^¨ì¤W­± 987654¡Ñ912¡×900740448 ªº¨Ò¤l¡A¨C¤@¦ì­¼¼Æ»P³Q­¼¼Æ¬Û­¼®É¡A¥²¶·¦b«e­±©Î«á­±¥[¤W­Y¤z¦ì¼Æ¹s¡C¦]¬°¬O¨Ï¥Î¥¼»E¶°ªº BCD ¼Æ¬Û­¼¡A©Ò¥H AAM «ü¥O¡A¦A¥H AAA ¥[¤W¶i¦ì¡C

²Ä¤G­Ó°j°é¬O¨Ï¼È¦s°Ï¤¤ªº¸ê®Æ¬Û¥[¡A¸Ô²Ó±¡§Î½Ð°Ñ¦Ò²Õ¦X»y¨¥ªº²Ä 13 ³¹¤Î²Ä 14 ³¹¡C


§â¸ê®Æ«þ¨©¨ì°Å¶Kï

­n§â¬Y¨Ç¸ê®Æ«þ¨©¨ì°Å¶KïùØ¡A¶·¶i¦æ¤U­±¨BÆJ¡G

  1. ¥Î OpenClipboard ¶}±Ò°Å¶Kï¡C
  2. ¥Î EmptyClipboard ²MªÅ°Å¶Kï¡C
  3. ¥Î SetClipboardData §â¸ê®Æ³]©w¶i°Å¶KïùØ¡C
  4. ¥Î CloseClipboard Ãö³¬°Å¶Kï¡C

OpenClipboard

OpenClipboard ¬O¥Î¨Ó¶}±Ò°Å¶Kï¡A³o­Ó·N«ä¨Ã«D§â°Å¶K諸¤º®eÅã¥Ü¦b¿Ã¹õ¤W¡A¦Ó¬Oªí¥Ü¨t²Î¤w·Ç³Æ¦n°Å¶Kï¤F¡C¨ä­ì«¬¬°¡G

BOOL OpenClipboard(
   HWND   hWndNewOwner  // handle to window opening clipboard  
   );

°Ñ¼Æ hWndNewOwner ¬O¬Y­Óµøµ¡¥N½X¡A³o­Óµøµ¡¬O«ü¶}±Ò°Å¶K諸µøµ¡¡A¥ç§Y¦¹µøµ¡¥i¥H¦s¨ú°Å¶Kï¡A°²¦p hWndNewOwner ¬O NULL¡Aªí¥Ü¬O©I¥s OpenClipboard ªºµøµ¡©Ò¶}±Ò¡COpenClipboard ¦pªG¦¨¥\¶}±Ò¡Aªð¦^®É¡AEAX ­È¤£µ¥©ó¹s¡F¦pªG¥¢±Ñ¡AEAX ¬° NULL¡C·íÀ³¥Îµ{¦¡­n¦s¨ú°Å¶K諸¸ê®Æ®É¡A¥²¶·¥Î OpenClipboard ¶}±Ò°Å¶Kï¡F·í¤£»Ý­n¦s¨ú°Å¶K鷺ªº¸ê®Æ«á¡A´NÀ³¸Ó­n©I¥s CloseClipboard Ãö³¬°Å¶Kï¡C

EmptyClipboard API

²Ä¤G­Ó¨BÆJ¬O°õ¦æ EmptyClipboard¡A²MªÅ°Å¶Kï¡A³o­Ó¹Lµ{¬O§â­ì¨Ó¦b°Å¶K諸¤º®e²M°£¡CEmptyClipboard ¨S¦³°Ñ¼Æ¡CEmptyClipboard ¦pªG¦¨¥\²M°£¸ê®Æ¡Aªð¦^®É¡AEAX ­È¤£µ¥©ó¹s¡F¦pªG¥¢±Ñ¡AEAX ¬° NULL¡C¦ý¦pªG±z·Q¨Ï¥Î°Å¶Kïùئ³ªº¸ê®Æ¡A¥i¥H¤£°µ³o¤@¨B¡A³o¼Ëªº¸Ü¡A¦pªG¦A§â¥t¤@¥÷¸ê®Æ²¾¶i°Å¶Kï¡A¨º»ò¦³ªº¸ê®Æ¨Ã¤£·|®ø¥¢¡C

SetClipboardData API

SetClipboardData ¬O§â¸ê®Æ²¾¤J°Å¶KïùØ¡A¨ä­ì«¬¬°¡G

HANDLE SetClipboardData(
    UINT    uFormat,    // clipboard format  
    HANDLE  hMem        // data handle 
   );

°Ñ¼Æ hMem ¬O°O¾ÐÅé°Ï¶ô¥N½X¡A¥¦¬O¥Ñ GlobalAlloc API ©Ò°t¸mªº°O¾ÐÅé°Ï¶ô¡A½Ð°Ñ¦Ò²Ä 14 ³¹ªº¡y°t¸m°O¾ÐÅé¡z¡C°Ñ¼Æ uFormat ¬O«ü²¾¤J°Å¶Kï¸Ì­±ªº¸ê®ÆÄݩ󨺤@ºØ¸ê®Æ¡A¥i¥H¬O¤å¦r¡B¹Ï¤ù¬Æ¦ÜÁn­µ¡K¡K¡A±`¨£ªº´XºØ¦p¤U¡G

¦pªG¶¶§Qªº§â¸ê®Æ²¾¤J°Å¶Kï¡A«h SetClipboardData ·|¶Ç¦^«D¹s­È¡F§_«h¶Ç¦^ NULL¡C

CloseClipboard API

CloseClipboard ¤£»Ý­n°Ñ¼Æ¡C¨C·íµ{¦¡§ïÅܰŶK鷺ªº¸ê®Æ¡A´NÀ³¸Ó©I¥s CloseClipboard Ãö³¬°Å¶Kï¡A¨Ï¨ä¥LÀ³¥Îµ{¦¡¯à¦s¨ú°Å¶Kï¡C¦pªG¦¨¥\ªºÃö³¬°Å¶Kï¡A«h CloseClipboard ·|¶Ç¦^«D¹s­È¡F§_«h¶Ç¦^ NULL¡C


¨ú±o®à­±¸ô®|

¦b Windows §@·~¨t²ÎùØ¡A¦³¤@¨Ç¯S®íªº¸ê®Æ§¨¡A¨Ò¦p¡y§Úªº¤å¥ó¡z¡B¡y±Ò°Ê¡z¡K¡Kµ¥µ¥¡A­n¨ú±o³o¨Ç¯S®íªº¸ê®Æ§¨¦bµwºÐ¤¤ªº¸ô®|¦WºÙ¡A±o¥ý¨ú±o¤@­ÓºÙ¬° item identifier list ªºÃѧO½X¡AµM«á¦b¥H¦¹ÃѧO½X¨ú±o§¹¾ã¸ô®|¦r¦ê¡C¨ú±o item identifier list ÃѧO½X¥i¥Î SHGetSpecialFolderLocation API¡A³o­Ó API ¬O¥]§t¦b SHELL32.DLL ùØ­±¡A¦]¦¹±o¥]§t SHELL32.INC ¤Î SHELL32.DLL¡A¨ä­ì«¬¦p¤U¡G

WINSHELLAPI HRESULT WINAPI SHGetSpecialFolderLocation(;
    HWND            hwndOwner,
    int             nFolder,
    LPITEMIDLIST    *ppidl
    );

²Ä¤@­Ó°Ñ¼Æ¡AhwndOwner «ü©w¤F©Ò¦³ªÌµøµ¡¡A¥ç§Y©I¥s SHGetSpecialFolderLocation ªºµøµ¡©Î¹ï¸Ü²°¡C²Ä¤G­Ó°Ñ¼Æ¬O nFolder¡A¨M©w­n¨ú±o¨º¤@­Ó¤l¥Ø¿ýªº¸ô®|¡AnFolder »P¨ä©Ò¥Nªíªº·N¸q¦p¤Uªí¡G

nFolder·N¡@¡@¸q¨Ò¡@¡@¤l
CSIDL_DESKTOP®à­±C:\Documents and Settings\wanker\®à­±
CSIDL_DESKTOPDIRECTORY®à­±C:\Documents and Settings\wanker\®à­±
CSIDL_FONTS¦r«¬C:\WINDOWS\Fonts
CSIDL_NETHOODºô¸ô¤WªºªÚ¾FC:\Documents and Settings\wanker\NetHood
CSIDL_PERSONAL§Úªº¤å¥óC:\Documents and Settings\wanker\My Documents
CSIDL_PROGRAMS¡u¶}©l¡v¥\¯àªíªº
¡y©Ò¦³µ{¦¡¡z
C:\Documents and Settings\wanker\¡u¶}©l¡v¥\¯àªí\µ{¦¡¶°
CSIDL_RECENT§Ú³Ìªñªº¤å¥óC:\Documents and Settings\wanker\Recent
CSIDL_SENDTO¡@C:\Documents and Settings\wanker\SendTo
CSIDL_STARTMENU¡u¶}©l¡v¥\¯àªíC:\Documents and Settings\wanker\¡u¶}©l¡v¥\¯àªí
CSIDL_STARTUP±Ò°ÊC:\Documents and Settings\wanker\¡u¶}©l¡v¥\¯àªí\µ{¦¡¶°\±Ò°Ê
CSIDL_SYSTEM¡@C:\WINDOWS\system32
CSIDL_TEMPLATES¡@C:\Documents and Settings\wanker\Templates

²Ä¤T­Ó°Ñ¼Æ¬O item identifier list ÃѧO½Xªº¦ì§}«ü¼Ð¡A¦b©I¥s SHGetSpecialFolderLocation ¤§«e¡A§â³o­Ó¦ì§}¥H°Ñ¼Æ¤è¦¡¶Çµ¹ SHGetSpecialFolderLocation¡ASHGetSpecialFolderLocation ªð¦^®É¡A·|§â item identifier list ÃѧO½X¦s¤J¦¹¦ì§}¡A¦pªG SHGetSpecialFolderLocation ¦¨¥\ªº¨ú±oÃѧO½X¡A«h¶Ç¦^ S_OK¡Cµy«á¦A¥H³o­ÓÃѧO½X©I¥s SHGetPathFromIDList API ´N¥i¥H±o¨ì¯S®í¸ê®Æ§¨§¹¾ãªº¸ô®|¦WºÙ¡CSHGetPathFromIDList ªº­ì«¬¬O¡G

WINSHELLAPI BOOL WINAPI SHGetPathFromIDList(
    LPCITEMIDLIST       pidl, 	
    LPSTR               pszPath	
   );

°Ñ¼Æ pidl ¬O©I¥s SHGetSpecialFolderLocation «á¡A©Ò±oªº item identifier list ÃѧO½X¡ApszPath «h¬O«ü¦V¯S®í¸ê®Æ§¨§¹¾ãªº¸ô®|¦ì§}¡A¤@¯ë¦Ó¨¥¨ä¤j¤p¬° MAX_PATH ¦ì¤¸²Õ ( ¦pªG±z¶}±Ò WINDOWS.INC¡A¥i¥H§ä¨ì MAX_PATH µ¥©ó 260 )¡C­Y SHGetPathFromIDList °õ¦æ¦¨¥\¡A«hªð¦^ TRUE¡A¨Ã¥B·|§â§¹¾ã¸ô®|¦WºÙ¦s¨ì pszPath ©Ò«üªº¦ì§}ùØ¡C


½s¿è®Ø»P«ö¶s¨â±±¨î¤¸¥óªº³qª¾½X

·í½s¿è®Øªº¤º®e³Q§ïÅܮɡA¤]´N¬O¨Ï¥ÎªÌ§ïÅÜ­n¨Dªº¶¥­¼®É¡A´NÀ³¸Ó¨Ï¡y«þ¨©µ²ªG¡z«ö¶s»P¡y¦s¦¨¡K¡z«ö¶s¸T¥Î¡A§_«h©Ò±oµ²ªG¬O¿ù»~ªº¡A¸T¥Î«ö¶s©Î±Ò¥Î«ö¶s¥i¥H¥Î EnableWindow ¨Ó¹F¨ì¥Øªº¡A­n¦b¨º¤@­Ó®É¾÷¸T¥Î©Î±Ò¥Î¡A«h¥²¶·ºÊµø½s¿è®Øªº³qª¾½X¡C

·í¨Ï¥ÎªÌ§â·Æ¹«²¾¨ì½s¿è®Ø¨Ã«ö¤U·Æ¹«¥ªÁä®É¡A½s¿è®Ø·|µo¥X WM_COMMAND °T®§µ¹¤÷µøµ¡¡A¨Ã¦b lParam ¤¤¶ñ¤J½s¿è®Øªº¥N½X¡AwParam ªº§C¦r²Õ¶ñ¤J½s¿è®ØªºÃѧO½X ( identifier )¡AwParam ªº°ª¦r²Õ¶ñ¤J³qª¾½X ( notification )¡C³qª¾½X¬O§i¶D¤÷µøµ¡¨Ï¥ÎªÌ°µ¤F¨º¨Ç°Ê§@¡A¥H¨Ïµ{¦¡°µ¥X¬Û¹ïÀ³ªº°Ê§@¡C©³¤U¬O±`¨£ªº³qª¾½X¡G

¦P¼Ëªº¡A«ö¶s±±¨î¤¸¥ó¤]·|§â¤@¨Ç³qª¾½X¶Ç»¼µ¹¤÷µøµ¡¡A¥HÅý¤÷µøµ¡°µ³B²z¡A©³¤U¬O±`¥Î³qª¾½X¡G

·í§Ú­Ì§â·Æ¹«´å¼Ð²¾¨ì«ö¶s¤W«á¡A«ö¤U·Æ¹«¥ªÁ䤣©ñ®É ( ©ÎªÌ«ö¶s±o¨ìÁä½L¿é¤JµJÂI¡A¨Ï¥ÎªÌ«ö¤UªÅ¥ÕÁ䤣©ñ®É )¡A³o®É«ö¶s·|Åã¥Ü³QÀ£¤Uªº¼Ë¤l¡A¦¹¨è«ö¶s·|µo¥X BN_PUSHED ³qª¾½X¡C·í©ñ¶}·Æ¹«¥ªÁä ( ©Î©ñ¶}ªÅ¥ÕÁä )¡A«ö¶s·|Åã¥Ü¼u°_¨Óªº¼Ë¤l¡A¦¹¨è«ö¶s·|µo¥X BN_UNPUSHED¡C§¹¦¨¤@¦¸À£¤U«á¦A¼u°_ªº¹Lµ{ ( §Y©Ò¿×ÂI«ö )¡A«ö¶sµo¥X BN_CLICKED ³qª¾½X¡C

¤£ºÞ¤°»ò­·®æªº«ö¶s¡A³£·|µo¥X BN_CLICKED¡A¦ý¬O¥u¦³¨ã¦³ BS_NOTIFY ­·®æªº«ö¶s¡A¤~·|µo¥X BN_DISABLE¡BBN_PUSHED¡BBN_KILLFOCUS¡BBN_PAINT¡BBN_SETFOCUS ©M BN_UNPUSHED ³qª¾½X¡C¨ã¦³ BS_USERBUTTON¡BBS_RADIOBUTTON ©Î BS_OWNERDRAW ­·®æªº«ö¶s¡A·|¦Û°Êµo¥X BN_DBLCLK ³qª¾½X¡A¦Ó¨ä¥L­·®æªº«ö¶s«h»Ý­n¨ã¦³ BS_NOTIFY ­·®æ¡A¤~·|µo¥X BN_DBLCLK ³qª¾½X¡C

¦b FACTORIAL µ{¦¡³B²z WM_COMMAND ¹Lµ{ùØ¡A¤p¤ì°¸¥u»Ý³B²z«ö¶sµo¥Xªº BN_CLICKED ©M½s¿è®Øµo¥Xªº EN_CHANGE ³qª¾½X¡A¨ä¾lªº³£¤£³B²z¡C¥ý¨Ï³qª¾½X¦s©ó EDX¡A¦Ó±±¨î¤¸¥óªºÃѧO½X¦s©ó EAX¡AµM«á¥ýÀˬd³qª¾½X¬O BN_CLICKED ÁÙ¬O EN_CHANGE¡C¦pªG¬O BN_CLICKED¡A¦AÀˬd¨º¤@­Ó«ö¶sµo¥Xªº¡A¥H«K§@¥X¬Û¹ïÀ³ªº³B²z¡F¦pªG¬O EN_CHANGE¡Aªí¥Ü¬O½s¿è®Øµo¥Xªº¡A¨Ï¡y«þ¨©µ²ªG¡z»P¡y¦s¦¨¡K¡z¨â«ö¶s¸T¥Î¡C¨äµ²ºc¦p¤U¡G

.ELSEIF uMsg==WM_COMMAND
                mov     edx,wParam
                mov     eax,wParam
                shr     edx,10h         ;EDX=³qª¾½X
                and     eax,0ffffh      ;EAX=±±¨î¤¸¥óÃѧO½X
   .IF dx==BN_CLICKED
       .IF ax==IDC_CALC
                ;¨Ï¥ÎªÌ«ö¤U¡y­pºâ¡z«ö¶s
       .ELSEIF ax==IDC_COPY
                ;¨Ï¥ÎªÌ«ö¤U¡y«þ¨©µ²ªG¡z«ö¶s
       .ELSEIF ax==IDC_SAVE
                ;¨Ï¥ÎªÌ«ö¤U¡y¦s¦¨¡K¡z«ö¶s
       .ENDIF
   .ELSEIF dx==EN_CHANGE
       .IF ax==IDC_OPERAND
                ;¨Ï¥ÎªÌ§ïÅܽs¿è®Ø¤º®e
       .ENDIF
   .ENDIF

­ì©l½X

©³¤U´N¬O FACTORIAL.ASM ªº­ì©l½X¡G

;FACTORIAL.ASM¥i¥H­pºâ¤£¤j©ó65536ªº¶¥­¼(65536!=5.1629485231E+287193)
        .586
        .model  flat,stdcall
        option  casemap:none

include         windows.inc
include         user32.inc
include         kernel32.inc
include         shell32.inc
includelib      user32.lib
includelib      kernel32.lib
includelib      shell32.lib

IDC_COPY        EQU     2001
IDC_CALC        EQU     2002
IDC_SAVE        EQU     2003
IDC_OPERAND     EQU     2004
IDC_ANSWER      EQU     2005
IDC_SCIENCE     EQU     2006
IDC_SPEND       EQU     2007

LARGEST         EQU     461E0h  ;461d9h=287193
BIGGEST_NUMBER  EQU     65536
EFFECT          EQU     40
;**********************************************************
.DATA
hInstance       HANDLE  ?
lpTemp          LPSTR   ?
nAnswer         DWORD   ?               ;­¼¿n¦r¦ê¦ì¤¸²Õ¼Æ
hCopy           HANDLE  ?               ;¡y«þ¨©µ²ªG¡z«ö¶sªº¥N½X
hSave           HANDLE  ?               ;¡y¦s¦¨¡K¡z«ö¶s¥N½X
hMemProduct     HANDLE  ?
nBytesWritten   DWORD   ?
dwDesktop       DWORD   ?
lpEndPath       LPSTR   ?
lpEndFileName   LPSTR   ?
szDlgName       BYTE    'Factorial',0
szIcon          BYTE    'Factorial',0
szFormat        BYTE    'E%d',0
szSciNotation   BYTE    EFFECT DUP (0)  ;¬ì¾Ç°O¸¹(Scientific notation)
szSaveAs        BYTE    '¦s¦¨',0dh,0ah
szFileName      BYTE    11 DUP (0)
szOverMsg       BYTE    '¤Ó¤j¤F¡AµLªkÅã¥Ü',0
szPathName      BYTE    MAX_PATH dup (0)
szErrorFile     BYTE    'ÀÉ®×'
szFileExisted   BYTE    '¤w¦s¦b¡I',0
szFmtSpend      BYTE    '¦@ªá¶O%d²@¬í',0
szSpendTime     BYTE    30 DUP (0)
;***********************************************************
.CODE
;-----------------------------------------------------------
ubcd_add        PROC    USES ebx edx esi edi lpLow1,lpLow2,lpSum,n1,n2
;­pºâ¨â«D»E¶°BCD¼Æ¤§©M
;¿é¤J¡GlpLow1¡G³Q¥[¼Æ³Ì§C¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§}
;      lpLow2¡G¥[¼Æ³Ì§C¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§}
;      lpSum¡G©M³Ì§C¦ì§}
;      n1¡G³Q¥[¼Æ¦ì¼Æ
;      n2¡G¥[¼Æ¦ì¼Æ
;¿é¥X¡GEAX¡G¬°©M©ÒÀx¦sªº¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§}
;      ECX¡G©Mªºªø«×¡A§Y¦ì¼Æ
;      EBX¡BEDX¡BESI¡BEDI§¡³Q«O¦s°_¨Ó
        mov     esi,lpLow1      ;ESI=³Q¥[¼Æ³Ì§C¦ì§}
        mov     ebx,lpLow2      ;EBX=¥[¼Æ³Ì§C¦ì§}
        mov     eax,n1
        cmp     eax,n2  ;¤ñ¸û³Q¥[¼Æ»P¥[¼Æ¨º¤@­Ó¦ì¼Æ¤j
        jae     u_a0
        xchg    eax,n2  ;­Y¥[¼Æ¦ì¼Æ¤j¡A«h¨Ï³Q¥[¼Æ»P¥[¼Æ¥æ´«³Ì§C¦ì§}
        xchg    esi,ebx ;(ESI»PEBX)¡A¦P®É¤]¥æ´«¦ì¼Æ(n1¡Nn2)
        mov     n1,eax
        mov     lpLow2,esi
        mov     lpLow1,ebx

;¶}©l¬Û¥[®É¡AESI«ü¦V¨â¼Æ¦ì¼Æ¸û¤jªÌªº¦ì§}¡An1¬°¨ä¦ì¼Æ
u_a0:   sub     eax,n2
        mov     n1,eax  ;n1¡×­«Å|³¡¥÷ªº¦ì¼Æ
        mov     edi,lpSum

;­pºâ­«Å|³¡¥÷¡A¨Ò¦p
;  987654
;+    912
;---------
;  988566
;³Q¥[¼Æ¡B¥[¼Æ³£¦³­Ó¦ì¡B¤Q¦ì¡B¦Ê¦ì¼Æ¡A©Ò¥H¬O­«Å|ªº³¡¥÷¡C
        clc
        sub     eax,eax
u_a1:   lodsb           ;¨ú±o¥[¼Æ¤¤ªº¤@¦ì
        add     al,ah   ;¥[¤W¶i¦ìªº¼Æ
        cbw
        add     al,[ebx]
        aaa             ;¥[ªk½Õ¾ã¡A­Y¦³¶i¦ì¡A·|¦s¦bAHùØ
        stosb           ;¦s¤J©M¤º
        inc     ebx
        dec     n2
        jnz     u_a1
        cmp     n1,0
        jz      u_a3    ;°²¦p³Q¥[¼Æ»P¥[¼Æ¦ì¼Æ¬Û¦P®É¡An1·|µ¥©ó¹s

;­pºâ¥u¦³¸û¤j¦ì¼Æ³¡¥÷¡A¥H¤W­±¬°¨Ò¡A§Y­pºâ
;  987654
;+ 000912
;---------
;  988566
;987+000ªº³¡¥÷
u_a2:   lodsb
        add     al,ah    ;AH¡×­pºâ­«Å|³¡¥÷«áªº¶i¦ì
        cbw
        aaa
        stosb
        dec     n1
        jnz     u_a2

;³B²z³Ì¤j¦ì¼Æ¶i¦ì
u_a3:   sub     al,al   ;¨ÏALµ¥©ó¹s
        add     al,ah   ;AH¡×¶i¦ì¡A¥[¤W¶i¦ì
        or      al,al
        jz      u_a4
        stosb
u_a4:   mov     ecx,edi
        mov     eax,lpSum
        sub     ecx,eax
        ret
ubcd_add        ENDP
;-----------------------------------------------------------
ubcd_mul        PROC    USES ebx esi edi,lpLow1,lpLow2,Product,n1,n2
;­pºâ¨â«D»E¶°BCD¾ã¼Æ¤§­¼¿n
;¿é¤J¡GlpLow1¡G³Q­¼¼Æ³Ì§C¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§}
;      lpLow2¡G­¼¼Æ(multiplier)³Ì§C¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§}
;      Product¡G­¼¿n³Ì§C¦ì§}
;      n1¡G³Q­¼¼Æ¦ì¼Æ
;      n2¡G­¼¼Æ¦ì¼Æ
;¿é¥X¡GEAX¡G¬°­¼¿n©ÒÀx¦s¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§}
;      ECX¡G­¼¿nªº¦ì¼Æ
;      EDX³Q¯}Ãa
;­ì²z¡G¥H987654*912=900740448¬°¨Ò¡G
;         987654 ³Q­¼¼Æ¡A¦s©ó©Ò°t¸m°O¾ÐÅé¦ì§}ªº0¡ã(LARGEST-1)³B¡A¤]¬O­¼¿n©Ò¦s©ñ³B¡A¦@¦³n1¦ì¼Æ
;       x    912 ­¼¼Æ¡A¦s©ó©Ò°t¸m°O¾ÐÅé¦ì§}ªºLARGEST¡ã(LARGEST+3FH)³B¡A¦@¦³n2¦ì¼Æ¡A¦¹¨Òn2=3
;      ----------
;      zz1975308 ¼È¦s°Ï¡A¥Ñ©Ò°t¸m°O¾ÐÅé¦ì§}ªº(LARFEST+40H)³B¶}©l¡A¹ï¨C¤@¦ì­¼¼Æ¦Ó¨¥
;      z0987654z ¡A§¡¦û¾Ún1+n2¦ì¼Æ¡A¦¹¨Òn1+n2¦@9¦ì¼Æ¡A­¼¿n¤]¬O9¦ì¼Æ
;      8888886zz
;      ----------
;      900740448
;³Q­¼¼Æ·|³Q¤T¦ì­¼¼Æ­¼¤T¦¸¡A¨C¤@¦¸³£¥i¤À¦¨¤T³¡¥÷¡G³Ì¥kÃä­n¶ñ¤J0¡A¬Û­¼¡A°µ¥ªÃä¤]­n¶ñ¤J0
;©³¤Uªº°Ï°ìÅܼơAlpHi1,lpHi2,nProduct¤À§Oªí¥Ü³Q­¼¼Æ³Ì°ª¦ì§}¡B­¼¼Æ³Ì°ª¦ì§}¡B­¼¿n¦ì¼Æ
        LOCAL   lpHi1,lpHi2,nProduct:DWORD
        mov     eax,lpLow1      ;­pºâ³Q­¼¼Æ¡B­¼¼Æ³Ì¤j¦ì¼Æ©Ò¦b¦ì§}¡A
        mov     ebx,lpLow2      ;¨Ã¦s©ólpHi1¡BlpHi2
        add     eax,n1
        add     ebx,n2
        mov     lpHi1,eax
        mov     lpHi2,ebx
        mov     ecx,n1          ;­pºâ­¼¿n¦ì¼Æ¡A¨Ã¦s©ó nProduct
        add     ecx,n2
        mov     nProduct,ecx

;²Ä¤@­Ó¤j°j°é¡A³B²z¨C¤@¦ì­¼¼Æ¥h­¼³Q­¼¼Æ
        mov     edi,lpTemp      ;EDI«ü¦V¼È¦s°Ï(¦s©ñ¨C¤@¦ì­¼¼Æ¬Û­¼«áªºµ²ªG)
        mov     esi,lpLow2      ;¨C¦¸­pºâ­¼¼Æ¤@¦ì¼Æ­¼³Q­¼¼Æµ²ªG¤§°j°é¶}©l
m1:     sub     eax,eax         ;²M°£EAX¡NEDX¨Ï©¹«áªºAAM¡NAAA«ü¥O¯à¥¿½T¹Bºâ
        mov     edx,eax

        mov     ecx,esi         ;¤p¦ì¼Æªº¶ñ¹s³¡¤À¡AECX¬°¶ñ¹sªº­Ó¼Æ
        sub     ecx,lpLow2
        mov     ebx,lpLow1      ;­pºâ­¼¼Æ¨C¦ì¼Æ­¼³Q­¼¼Æ³¡¤À
        push    ecx
        jcxz    m3
m2:     mov     [edi],al
        inc     edi
        loop    m2

m3:     mov     al,[ebx]        ;BX«ü¦V³Q­¼¼Æ
        mul     BYTE PTR [esi]
        aam
        add     al,dh           ;¥[¤W«e¤@¦¸ªº¶i¦ì
        aaa
        mov     dh,ah           ;¶i¦ì¦s©óDH
        mov     [edi],al
        inc     ebx
        inc     edi
        cmp     ebx,lpHi1
        jne     m3

        mov     [edi],dh        ;³B²z¶i¦ì³¡¤À
        inc     edi

        pop     eax             ;³B²z¤j¦ì¼Æ¶ñ¹s³¡¤À
        mov     ecx,nProduct
        sub     ebx,lpLow1
        sub     ecx,eax
        sub     ecx,ebx
        dec     ecx             ;ECX¬°¶ñ¹sªº­Ó¼Æ
        jcxz    m5
m4:     mov     BYTE PTR [edi],0
        inc     edi
        loop    m4

m5:     inc     esi             ;«ü¦V­¼¼Æªº¤U¤@¦ì
        cmp     esi,lpHi2       ;Àˬd­¼¼Æ¬O§_³£¤wºâ§¹
        jne     m1

;²Ä¤G­Ó¤j°j°é¡A³B²z¦b¼È¦s°Ï¤¤¨C¤@¦ì­¼¼Æ­¼¿n¤§©M
        mov     edi,Product
        mov     ecx,nProduct
        xor     eax,eax
        inc     ecx
        rep     stosb           ;²M°£­¼¿nªº©U§£¸ê®Æ

        mov     ecx,lpLow2
        mov     esi,Product     ;ESI=­¼¿n¦ì§}
        sub     lpHi2,ecx       ;lpHi2=­¼¼Æ¦ì¼Æ¡A§Y­n¬Û¥[¦¸¼Æ
        mov     ebx,lpTemp      ;EBX¬°¼È¦s°Ï¦ì§}
        mov     edx,nProduct
m6:     INVOKE  ubcd_add,esi,ebx,esi,edx,edx    ;ESI=ESI+EBX
        add     ebx,edx
        dec     lpHi2
        jnz     m6
        mov     eax,Product
        mov     ecx,nProduct
        cmp     BYTE PTR [eax+ecx-1],0  ;Àˬd³Ì°ª¦ì¼Æ¬O§_¬°¹s
        jnz     m7
        dec     ecx             ;­Y¨S¦³¶i¦ì¡A«h­¼¿n¦ì¼Æ´î¤@
m7:     ret
ubcd_mul        ENDP
;-----------------------------------------------------------
;¦¹°Æµ{¦¡¬O­pºâeaxªº¶¥­¼
;¿é¤J¡GEAX¡Ð­n­pºâ¶¥­¼ªº¹Bºâ¤¸
;      EDX¡Ð«ü©w©Ò±oµ²ªG¦ì§}
;¿é¥X¡GEAX¡Ð©Ò±oµ²ªG¦ì§}¡A¦¹µ²ªG¥HASCII¦r¦êÀx¦s¡A¥H0µ²§À
;      ECX¡Ð­¼¿n¦³´X¦ì¼Æ¡A22!¡×¡y1124000727 7776076800 00¡z¦³22¦ì¼Æ
;      EDX¡Ð­¼¿n¦r¦ê¦ì¤¸²Õ¼Æ¡A22!¡×¡y1124000727 7776076800 00¡z§tªÅ¥Õ¡B´«¦æ¦r¤¸¦û¦³24­Ó¦ì¤¸²Õ
;­ì²z¡G­Y¨Ï¥ÎªÌ¿é¤J¤£¬O0!¡A¥ý­n¨D°t¸mªº°O¾ÐÅé¡A°O¾ÐÅé¤À°t¦p¤U¡G
;°¾²¾¦ì§}¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@·N¸q
;0¡ãLARGEEST¡Ð1¡@¡@¡@¡@¡@¡@ ³Q­¼¼Æ¡B­¼¿n¦s©ñ¦ì§}
;LARGEST¡ãLARGEST¡Ï10H¡@¡@¡@­¼¼Æ¦s©ñ¦ì§}
;LARGEST¡Ï0FH¡ãLARGEST*8H¡@ ¼È¦s°Ï
Factorial       PROC    USES esi edi
        LOCAL   factorial:DWORD
        LOCAL   hMemory:HANDLE  ;¦V¨t²Î­n¨D°t¸mªº°O¾ÐÅé¦ì§}
        LOCAL   lpMul2:LPSTR    ;­¼¼Æ¥H¥¼»E¶°BCD¼Æ¦s©ólpMul2©Ò«ü¦ì§}¡A°ª¦ì¼Æ¦s©ó°ª¦ì§}
        LOCAL   lpProduct:LPSTR ;­¼¿n¦ì§}
        LOCAL   dwDigMul1,dwDigMul2:DWORD       ;³Q­¼¼Æ¡B­¼¼Æ¦ì¼Æ
        LOCAL   dwTick:DWORD
        mov     factorial,eax   ;­n­pºâ¶¥­¼ªº¼Æ¦s©ófactorial
        mov     lpProduct,edx   ;­¼¿n¦ì§}¦s©ólpProduct

        INVOKE  GetTickCount    ;¨ú±o®É¶¡¡A¦Û¶}¾÷¨ì²{¦b¸g¹L´X­Ó²@¬í
        mov     dwTick,eax

        mov     edx,lpProduct
        mov     ecx,1
        mov     [edx],cx
        cmp     factorial,0     ;­Y¤£¬O¨D0!¡A«h¸õ¦Ünot_0:³B
        jnz     not_0

;­Y¬O­pºâ0!¡A«hµ²ªG¬°0!=1
        add     BYTE PTR [edx],'0'
        mov     DWORD PTR [szSciNotation],45302e31h
        push    edx
        mov     WORD PTR [szSciNotation+4],30h
        INVOKE  GetTickCount
        sub     eax,dwTick
        INVOKE  wsprintf,OFFSET szSpendTime,OFFSET szFmtSpend,eax
        sub     ecx,ecx
        pop     eax
        inc     ecx
        mov     edx,ecx
        inc     edx
        jmp     finish

;­Y¤£¬O­pºâ0!
not_0:  mov     dwDigMul1,ecx                   ;­¼¿n¦ì¼Æ¤@¶}©l¥u¦³¤@¦ì¡A¨ä¹ê­¼¿n´N¬O1
        INVOKE  GlobalAlloc,GPTR,LARGEST*6h+10H ;¦V¨t²Î­n¨DLARGEST*6+10Hªº°O¾ÐÅé¤j¤p
        mov     hMemory,eax
        mov     BYTE PTR [eax],1;¥ý¨Ï­¼¿n¬°1
        add     eax,LARGEST     ;©Ò°t¸mªº°O¾ÐÅ餤¡A³Ì§CªºLARGEST¦ì¤¸²Õ¬°³Q­¼¼Æ¦s©ñ³B
        mov     lpMul2,eax
        add     eax,10h         ;¤ñ³Q­¼¼Æ°ª¦ì§}ªº10H¦ì¤¸²Õ¬°­¼¼Æªº¦s©ñ³B
        mov     lpTemp,eax      ;¼È¦s°Ï¦ì§}

;§â­¼¼Æ¥H¥¼»E¶°BCD¼Æ¦s¤JlpMul2©Ò«ü¦ì§}¡A°ª¦ì§}¦s©ñ°ª¦ì¼Æ
next:   mov     eax,factorial
        mov     edi,lpMul2
        mov     ebx,10          ;³Ì¦h¥u¯à¨D10¦ì¼Æªº¶¥­¼
        mov     ecx,ebx
@@:     sub     edx,edx
        div     ebx
        mov     [edi],dl
        inc     edi
        loop    @b
        dec     edi
        std
        mov     ecx,ebx         ;¥Ñ­¼¼Æ°ª¦ì§}¶}©l¡A´M§ä²Ä¤@­Ó«D¹sªº¼Æ
        repe    scasb
        inc     ecx
        cld
        mov     dwDigMul2,ecx   ;ECX=­¼¼Æ¦ì¼Æ

;¤j¼Æ­¼ªk¡AhMemory=hMomory*lpMul2
        INVOKE  ubcd_mul,hMemory,lpMul2,hMemory,dwDigMul1,ecx
        mov     dwDigMul1,ecx   ;¤U¦¸ªº³Q­¼¼Æ¦ì¼Æ´N¬O³o¦¸ªº­¼¿n¦ì¼Æ
        dec     factorial
        jnz     next

;§â¦ì§}hMemory©Ò¦sªº­¼¿n¡A¥HBig-Endian¡BASCII¦r¦ê¦s¤JlpProduct©Ò«ü¦ì§}
;¦ì§}hMemoryªº­¼¿n¬O¥HLittle-Endian¡B¥¼»E¶°BCD¤è¦¡Àx¦s
        mov     esi,hMemory
        mov     edi,lpProduct
        add     esi,ecx
        xor     edx,edx
        push    esi
@@:     dec     esi
        mov     al,[esi]
        or      al,'0'
        inc     edx
        stosb
  .IF (dl==10)||(dl==20)||(dl==30)||(dl==40)
        mov     al,20h          ;¨C10¦ì¼Æ¦r¥HªÅ¥Õ¹j¶}
        stosb
  .ELSEIF dl==50
        xor     edx,edx
        mov     ax,0a0dh        ;¨C50¦ì¼Æ¦r´«¦æ
        stosw
  .ENDIF
        loop    @b
        mov     al,cl           ;AL=NULL¦r¤¸
        stosb
        sub     edi,lpProduct
        mov     dwDigMul2,edi   ;EDI¡×­¼¿n¦r¦ê¦ì¤¸²Õ¼Æ¡A¼È¦s©ódwDigMul2

;§â¦ì§}hMemory©Ò¦sªº­¼¿n¡A¥H¬ì¾Ç°O¸¹¤è¦¡(ASCII¦r¦ê)¦s©ószSciNotation©Ò«ü¦ì§}
        pop     esi
        mov     ecx,dwDigMul1
        mov     edi,OFFSET szSciNotation
        dec     esi
        mov     al,[esi]
        dec     ecx
        add     al,'0'
        dec     esi
        mov     ah,'.'
        stosw
        mov     edx,ecx
  .IF ecx>=EFFECT-10            ;­Y­¼¿n¦ì¼Æ¤j©ó(EFFECT-10)¦ì¡A
        mov     ecx,EFFECT-10   ;¶È¦L¥X«e(EFFECT-10)¦ì(¥]§t¤@¦ì¾ã¼Æ)
  .ELSEIF ecx==0
        mov     al,'0'
        stosb
        jmp     ok
  .ENDIF
@@:     mov     al,[esi]
        add     al,'0'
        stosb
        dec     esi
        loop    @b
ok:     INVOKE  wsprintf,edi,OFFSET szFormat,edx
        INVOKE  GetTickCount
        sub     eax,dwTick
        INVOKE  wsprintf,OFFSET szSpendTime,OFFSET szFmtSpend,eax
        INVOKE  GlobalFree,hMemory
        mov     eax,lpProduct
        mov     ecx,dwDigMul1   ;ECX¡×­¼¿n¦ì¼Æ
        mov     edx,dwDigMul2   ;EDX¡×­¼¿n¦r¦ê¦ì¤¸²Õ¼Æ
finish: ret
Factorial       ENDP
;-----------------------------------------------------------
DlgProc PROC    hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
                LOCAL   hMem:HANDLE,hFile:HANDLE
.IF uMsg==WM_INITDIALOG
        ;¸ü¤J¹Ï¥Ü
                INVOKE  LoadIcon,hInstance,OFFSET szIcon
                INVOKE  SendMessage,hDlg,WM_SETICON,ICON_SMALL,eax
        ;¨ú±o¡y«þ¨©µ²ªG¡z¡B¡y¦s¦¨¡K¡z«ö¶s¥N½X¡A¨Ã¨Ï¨ä¸T¥Î
                INVOKE  GetDlgItem,hDlg,IDC_COPY
                mov     hCopy,eax
                INVOKE  EnableWindow,eax,FALSE
                INVOKE  GetDlgItem,hDlg,IDC_SAVE
                mov     hSave,eax
                INVOKE  EnableWindow,eax,FALSE
        ;°t¸m321658­Ó¦ì¤¸²Õªº°O¾ÐÅéªÅ¶¡¡A¥H¦s©ñ­¼¿n¡A­¼¿n³Ì¦h¬°287194¦ì¼Æ¡A¦Ó¨C10¦ì¼Æ
        ;¦h¶ñ¤@­ÓªÅ®æ¡A¨C50¦ì¼Æ¦h¤@­Ó´«¦æ¦r¤¸(¨â­Ó¦ì¤¸²Õ)¡A¬G¨C50¦ì¼Æ¦h6­Ó¦ì¤¸²Õ
        ;287194¡Ò50¡×5743¡K¡K44¡@¡@¡@50¦ì¼Æ¤@¦æ¡A¦@¦³5744¦æ
        ;287194¡Ï5744¡Ñ6¡×321658   ¨C¦æ¦h6­Ó¦ì¤¸²Õ¡A¬G¦h¤F5744¡Ñ6­Ó¦ì¤¸²Õ
                INVOKE  GlobalAlloc,GMEM_SHARE or GPTR,321658
                mov     hMemProduct,eax
        ;¨ú±o¨Ï¥ÎªÌ®à­±¸ô®|
                INVOKE  SHGetSpecialFolderLocation,hDlg,CSIDL_DESKTOP,OFFSET dwDesktop
                INVOKE  SHGetPathFromIDList,dwDesktop,OFFSET szPathName
                mov     edx,OFFSET szPathName
@@:             cmp     BYTE PTR [edx],0
                je      found_zero
                inc     edx
                jmp     @b
found_zero:     mov     BYTE PTR [edx],'\'
                inc     edx
                mov     lpEndPath,edx

.ELSEIF uMsg==WM_COMMAND
                mov     edx,wParam
                mov     eax,wParam
                shr     edx,10h         ;EDX=³qª¾½X
                and     eax,0ffffh      ;EAX=±±¨î¤¸¥óÃѧO½X
   .IF dx==BN_CLICKED
       .IF ax==IDC_CALC
                INVOKE  GetDlgItemInt,hDlg,IDC_OPERAND,NULL,FALSE
           .IF eax<=BIGGEST_NUMBER
                mov     edx,hMemProduct
                call    Factorial
                mov     nAnswer,edx             ;nAnswer¡×­¼¿n¦r¦ê¦ì¤¸²Õ¼Æ
                push    eax
                INVOKE  EnableWindow,hCopy,TRUE
                INVOKE  EnableWindow,hSave,TRUE
                pop     eax
                mov     edx,OFFSET szSciNotation
           .ELSE
                mov     eax,OFFSET szOverMsg
                mov     nAnswer,0               ;nAnswer¡×0
                mov     edx,eax                 ;EDX¡×¬ì¾Ç°O¸¹¦r¦ê¦ì§}
           .ENDIF
                push    edx
                INVOKE  SetDlgItemText,hDlg,IDC_ANSWER,eax
                push    IDC_SCIENCE
                push    hDlg
                call    SetDlgItemText
                INVOKE  GetDlgItemText,hDlg,IDC_OPERAND,OFFSET szFileName,8
                mov     edx,OFFSET szFileName
                mov     ecx,lpEndPath
@@:             mov     ah,[edx]
                mov     [ecx],ah
                inc     edx
                inc     ecx
                dec     al
                jnz     @b
                mov     DWORD PTR[edx],58542e21h        ;¶ñ¤JÀɦWªº¨ä¾l³¡¥÷
                mov     WORD PTR [edx+4],54h            ;¡A¡y!.TXT¡z,0
                mov     DWORD PTR[ecx],58542e21h
                add     ecx,4
                mov     WORD PTR [ecx],54h
                inc     ecx
                mov     lpEndFileName,ecx
                INVOKE  SetDlgItemText,hDlg,IDC_SAVE,OFFSET szSaveAs
                INVOKE  SetDlgItemText,hDlg,IDC_SPEND,OFFSET szSpendTime
       .ELSEIF ax==IDC_COPY
                INVOKE  OpenClipboard,NULL      ;¶}±Ò°Å¶Kï
                call    EmptyClipboard          ;²MªÅ°Å¶Kï
                INVOKE  GlobalAlloc,GMEM_SHARE or GPTR,nAnswer
                mov     esi,hMemProduct
                mov     edi,eax
                mov     hMem,eax
                mov     ecx,nAnswer
                rep     movsb
                INVOKE  SetClipboardData,CF_TEXT,eax
                INVOKE  GlobalFree,hMem
                call    CloseClipboard
       .ELSEIF ax==IDC_SAVE
                INVOKE  CreateFile,OFFSET szPathName,GENERIC_WRITE,0,0,CREATE_NEW,\
                        FILE_ATTRIBUTE_NORMAL or FILE_FLAG_WRITE_THROUGH,NULL
           .IF eax==INVALID_HANDLE_VALUE
                mov     ah,LENGTHOF szFileExisted
                mov     ecx,OFFSET szFileExisted
                mov     edx,lpEndFileName
@@:             mov     al,[ecx]
                mov     [edx],al
                inc     ecx
                inc     edx
                dec     ah
                jnz     @b
                INVOKE  MessageBox,hDlg,OFFSET szPathName,OFFSET szErrorFile,MB_OK
           .ELSE
                mov     hFile,eax
                INVOKE  WriteFile,eax,hMemProduct,nAnswer,OFFSET nBytesWritten,NULL
                INVOKE  CloseHandle,hFile
           .ENDIF
                INVOKE  EnableWindow,hSave,FALSE
       .ENDIF
   .ELSEIF dx==EN_CHANGE
       .IF ax==IDC_OPERAND
                INVOKE  EnableWindow,hCopy,FALSE
                INVOKE  EnableWindow,hSave,FALSE
       .ENDIF
   .ENDIF

.ELSEIF uMsg==WM_CLOSE
                INVOKE  GlobalFree,hMemProduct
                INVOKE  EndDialog,hDlg,NULL

.ELSE
        mov     eax,FALSE
        ret
.ENDIF
        mov     eax,TRUE
        ret
DlgProc	ENDP
;-----------------------------------------------------------
start:  INVOKE  GetModuleHandle,NULL
        mov     hInstance,eax
        INVOKE  DialogBoxParam,hInstance,OFFSET szDlgName,NULL,\
                OFFSET DlgProc,NULL
        INVOKE  ExitProcess,eax
;***********************************************************
        END     start

©³¤U¬O FACTORIAL.RC Àɪº¤º®e¡G

#include "c:\masm32\include\resource.h"

#define IDC_COPY    2001
#define IDC_CALC    2002
#define IDC_SAVE    2003
#define IDC_OPERAND 2004
#define IDC_ANSWER  2005
#define IDC_SCIENCE 2006
#define IDC_SPEND   2007

Factorial       ICON    exclamation01.ico

Factorial       DIALOG  6, 15, 280, 132
STYLE           DS_MODALFRAME|WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU
CAPTION         "­pºâ¬Y¾ã¼Æ¶¥­¼"
FONT            8,"MS Sans Serif"
{
 CONTROL        "! =",         -1,"static",SS_LEFT|WS_CHILD|WS_VISIBLE|WS_GROUP, 63, 12, 30, 14
 CONTROL        ""   ,IDC_SCIENCE,"static",SS_LEFT|WS_CHILD|WS_VISIBLE|WS_GROUP, 77, 12,160, 14
 RTEXT          "=",     -1, 6, 27, 15, 12
 EDITTEXT       IDC_OPERAND,23, 10, 38, 12, WS_TABSTOP|ES_NUMBER|ES_RIGHT
 EDITTEXT       IDC_ANSWER, 23, 27,238, 55, WS_BORDER|WS_TABSTOP|ES_MULTILINE|ES_AUTOVSCROLL|
                                            ES_READONLY|WS_VSCROLL
 CONTROL        "",IDC_SPEND,"static",SS_LEFT|WS_CHILD|WS_VISIBLE|WS_GROUP,23,87,100,14
 DEFPUSHBUTTON  "­pºâ"       ,IDC_CALC, 10,103, 80, 22
 PUSHBUTTON     "«þ¨©µ²ªG"   ,IDC_COPY,100,103, 80, 22
 PUSHBUTTON     "¦s¦¨\n!.TXT",IDC_SAVE,190,103, 80, 22,BS_MULTILINE
}

¹Ï¥ÜÀÉ¡Aexclamation01.ico¡A¥i¥H«ö¤U³oùؤU¸ü¡A¦³¤F FACTORIAL.ASM¡BFACTORIAL.RC¡B¥H¤Î exclamation01.ico ¤T­ÓÀɮסA§â¥¦­Ì³£©ñ¦b¦P¤@­Ó¤l¥Ø¿ý¡A¨Ò¦p³£©ñ¦b¡yE:\Homepage\SOURCE\FACTORIAL\¡zùØ¡A´N¥i¥H¨Ì©³¤U¨BÆJ²ÕĶ¦Ó±o¨ì FACTORIAL.EXE ¥i°õ¦æÀÉ¡G

E:\>cd homepage\source\factorial [Enter]

E:\HomePage\SOURCE\FACTORIAL>rc factorial.rc [Enter]

E:\HomePage\SOURCE\FACTORIAL>ml factorial.asm /link factorial.res [Enter]
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: FACTORIAL.ASM
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/SUBSYSTEM:WINDOWS
"FACTORIAL.obj"
"/OUT:FACTORIAL.exe"
"FACTORIAL.res"

E:\HomePage\SOURCE\FACTORIAL>

GetTickCount

³o­Ó API ¬O¥Î¨Ó­pºâ¹q¸£±q¨t²Î¶}©l¹B§@¨ì¥Ø«e¬°¤î¸g¹L¤F¦h¤Ö²@¬í¡A¨Ã§â³o­Ó®É¶¡¦s¦b EAX ùضǦ^¨Ó¡C¦]¬°µ²ªG¬O¥H 32 ¦ì¤¸¤j¤p°O¿ý¡A©Ò¥H³Ì¦h¥i¥H°O¿ý¨ì 49.7 ¤Ñ¡A¦pªG¶W¹L«hÂk¹s¶}©l­p®É¡C¦¹¥~³o­Ó API ¨S¦³°Ñ¼Æ¡C

¤p¤ì°¸§Q¥Î³o­Ó API ´ú¶q­pºâ¬Y¼Æªº¶¥­¼ªá¤F¦h¤Ö®É¶¡¡C¤p¤ì°¸©Ò¨Ï¥Îªº CPU ¬O AMD Athlon 64X2 3600¡Ï¡A­pºâ 100¡I¦ü¥G¤£¶·ªá¤°»ò®É¶¡¡A¦U¦ìŪªÌ¥i¬Ý¥»³¹¤@¶}©lªº¹Ï´Nª¾¹D¡F­pºâ 1000¡I¥uªá¤F 0.14 ¬í¡F­pºâ 10000¡Iªá¤F 11.9 ¬í¡F¦ý¬O­pºâ 65536¡I³ºªá¤F 13 ¤À 4 ¬í (¥Î¥t¤@¥x CPU ¬O Core(TM) Due T7250 2.00GHz ªºµ§°O«¬¹q¸£¶O®É 6 ¤À 57 ¬í )¡C¥i¨£©Òªáªº®É¶¡¨Ã«D¦¨½u©Êµ¥¤ñÃö«Y¡A¦Ó¬Oªá§ó¦h­¿ªº®É¶¡¡C