«e¤@³¹¤w¸g«Ø¥ß¦n¨ã¦³¤TӰƵ{¦¡ªº PRIMEDLL.DLL¡A³o¤@³¹»¡©ú¦p¦ó§Q¥Î³o¤TӰƵ{¦¡¡Cº¥ý§Q¥Î is_prime¡A¼¶¼g½è¦]¼Æ¤À¸Ñµ{¦¡¡APF.ASM¡C
§â¤@¼Æ¤À¸Ñ¦¨½è¦]¼Æ¼¿n¡A¬O¤p¾Ç°ò¥»ªº¼Æ¾Ç¯à¤O¡A¤]¬O°ö¾i©â¶H«ä¦Òªº°ò¥»¹Lµ{¡C¦]¼Æ¤À¸Ñ¬O«ü§â¤@ӼƼg¦¨´XÓ¦]¼Æ¬Û¼ªº§Î¦¡¡A¨Ò¦p 10¡×2¡Ñ5 ©Î 36¡×2¡Ñ3¡Ñ6¡C¦pªG³o¨Ç¦]¼Æ³£¬O½è¼Æ¡A¨º»ò´N¥s¡u½è¦]¼Æ¤À¸Ñ¡v¡A¨Ò¦p 36¡×22¡Ñ33¡C½è¼ÆµLªk¤À¸Ñ¦¨¤j©ó¤@ªº¨â¥¿¾ã¼Æ¤§¼¿n¡A¦]¦¹§â¤@¥¿¾ã¼Æ°µ½è¦]¼Æ¤À¸Ñ¡A©Ò±oªºµª®×¬°°ß¤@ªº¡C©³¤U¤p¤ì°¸´N§Q¥Î is_prime ¥h¼¶¼g PF.ASM µ{¦¡¡A¥h°µ½è¦]¼Æ¤À¸Ñ¡Aµ²ªG¦p¤U¡G
¦b»¡©ú PF.ASM µ{¦¡¤§«e¡A¥ý»¡»¡¥¦ªº¨î¡C¥¿¾ã¼Æ¦³µLÓ¡A¦]¦¹§Ų́Sªk¤l°µ¥X¡u¯à§â¥ô·N¥¿¾ã¼Æ¤À¸Ñ¦¨½è¦]¼Æ¼¿n¡vªºµ{¦¡¨Ó¡C¦Ó 64 ¦ì¤¸¹q¸£ªº¼È¦s¾¹¡A¯àªí¥Ü³Ì¤jªº¥¿¾ã¼Æ¬O 264¡Ð1¡A©Ò¥H¤p¤ì°¸¦X²zªº§â PF.ASM ¨î¦b¡A¯àºâ¥X¤p©ó 264¡Ð1 ªº½è¦]¼Æ¼¿n¡C¦b PF.ASM µ{¦¡¤¤¡A³ÌÃöÁ䪺³¡¥÷¬Opºâ¥X½è¦]¼Æªº°Æµ{¦¡¡Ais_prime¡C¥¦¯à§PÂ_¬YÓ¥¿¾ã¼Æ¬O§_¬°½è¼Æ¡F¦pªG¤£¬O½è¼Æªº¸Ü¡AÁÙ¯àpºâ¥X³oÓ¥¿¾ã¼Æ³Ì¤pªº½è¦]¼Æ¡C§Q¥Î¦¹¶µ¯S©Ê¡A«Ü®e©ö´N¯à°÷§â¤@Ó¥¿¾ã¼Æ¤À¸Ñ¦¨½è¦]¼Æ¼¿n¡C¨ãÅ骺¬yµ{¦p¤U¡G
¡@①¥ý¥H¨Ï¥ÎªÌ©Ò¿é¤Jªº¥¿¾ã¼Æ¬°°Ñ¼Æ¡A©I¥s is_prime¡A¥H§PÂ_¸Ó¥¿¾ã¼Æ¬O§_¬°½è¼Æ¡A¦pªG¬Oªº¸Ü¡A¸õ¨ì⑤¡F¦pªG¤£¬Oªº¸Ü¡A¸õ¦Ü¨BÆJ②¡C
¡@②§Q¥Î is_prime pºâ¥Xªº³Ì¤p½è¦]¼Æ¡C¥H¦¹½è¦]¼Æ¥h°£¨Ï¥ÎªÌ©Òµ¹ªº¥¿¾ã¼Æ¡A¨Ã°O¿ý¯à¾ã°£´X¦¸¡A¦¹¯à¾ã°£ªº¦¸¼Æ´N¬O¦¹½è¦]¼Æªº«ü¼Æ¡C½è¦]¼Æ»P«ü¼Æ³£±o¬ö¿ý©ó¤@°}¦CùØ¡C
¡@③µ¥¨ì¤£¯à¾ã°£®É¡A´N¥H³Ì«á¯à¾ã°£ªº°Ó¡A¥N´Àì¨Ó¨Ï¥ÎªÌ©Òµ¹ªº¥¿¾ã¼Æ¡A¥H¦¹°Ó¼Æ¬°°Ñ¼Æ¡A¦A¦¸©I¥s is_prime¡C
¡@④«½Æ②¡ã③¨BÆJ¡Aª½¨ì©Ò°£ªº°Ó¬° 1¡A¸õ¨ì⑤¡C
¡@⑤µ²§ô¡C
¦b¾ãÓ¹Lµ{¤¤¡A½è¦]¼Æ»P¨ä«ü¼Æ¥²¶·«O¦s°_¨Ó¡A¤p¤ì°¸©w¸q¤F¤@Ó 216 Ӧ줸²Õªº°}¦C«O¦s¥¦Ì¡CPF.ASM ¯à³B²zªº³Ì¤j¥¿¾ã¼Æ¬O 264¡A¦³ 20 ¦ì¼Æ¨º»ò¤j¡F¦Ó³Ì¤pªº 16 Ó½è¼Æ ( 2¡B3¡B5¡B7¡K¡K53 ) ¬Û¼©Ò±o¤§¿n¡A¤w¸g¶W¹L 264 ¤F¡C¤]´N¬O»¡¡APA.ASM ¯à³B²zªº³Ì¤jªº¥¿¾ã¼Æ¡A³Ì¦h¤]¥u¯à¬O 16 Ó½è¦]¼Æ¬Û¼¡C´«¥y¸Ü»¡¡A¥un·Ç³Æ¦n¯à®e¯Ç 16 µ§¸ê®Æ´N¥i¥H¤F¡F¦Ó¨C¤@µ§³£¬O¥Ñ½è¦]¼Æ¸ò¨ä«ü¼Æ©Òºc¦¨ªº¡C¦ý¬°¤F¹ï»ô 8 Ӧ줸²Õ¡A¦]¦¹·Ç³Æ¤F¯à®e¯Ç 24 µ§¸ê®Æ¡C½è¦]¼Æ¥i¯à¬O 64 ¦ì¤¸ªø¡A¥ç§Y¤KӦ줸²Õªø¡F«ü¼Æ¥u»Ý¤@Ӧ줸²Õ´N°÷¤F ( ¤@Ӧ줸²Õ¤w¯àªí¥Ü 255 ¦¸¤è )¡C¦]¦¹¡A¤@µ§¸ê®Æ¦³¤EӦ줸²Õªø¡A24 µ§¸ê®Æ¡A´N¦³ 216 Ӧ줸²Õªø¡C
©³¤U¥H 14872¡×23¡Ñ11¡Ñ132 ¬°¨Ò¡A°õ¦æ§¹¤W±¨BÆJ¤§«á¡A³o 216 Ӧ줸²Õªº«e´XӦ줸²Õ¤º®eÅܦ¨
00000001'40004050 -02 00 00 00 00 00 00 00 .:.............. 00000001'40004060 03 0b 00 00 00 00 00 00-00 01 0d 00 00 00 00 00 ................ 00000001'40004070 00 00 02 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00000001'40004080 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00
¤W±ªº¸ê®Æ¡A¥Õ¦âªº³¡¤À¬O½è¦]¼Æ¡A¦Ó¬õ¦âªº³¡¤À¬°¨ä«ü¼Æ¡Cµ²§Àªº°O¸¹¬O³sÄò 9 Ó 0¡C
Windows ¨t²Î¤º«Ø¤F³\¦h±±¨î¤¸¥ó ( control¡A²ºÙ±±¥ó )¡A¨Ò¦p«ö¶s¡B½s¿è®Ø¡BÀRºA±±¥ó¡K¡Kµ¥¡A³o¨Ç±±¥ó¤j´T²¤Æ¤Fµ{¦¡³]p®vªº¤u§@¡A§_«hµ{¦¡³]p®v´N±oªá¶O¤ß¤O¡A¬°³o¨Ç±±¥ó¯S§O³]p±MÄݪºµ{¦¡¡C¨ä¹ê¡A³o¨Ç±±¥ó³£¬O¤@ºØ¤lµøµ¡¡A©Ò¥H¤]¦³µøµ¡ªº¦æ¬°¡C§Ú̱`±`·|¦b³]pµ{¦¡®É¡A¹J¨ì¬YÓ±±¥ó¡A²Å¦X§Ú̩ҧƱ檺¤j³¡¤À¥\¯à¡A¦ý¤S¯Ê¤Ö¨º»ò¤@ÂI¨à¡A³o®É¥i¥H§Q¥Î¤lÃþ¤Æ ( subclass ) §Þ³N¹F¨ì³oӥتº¡C
¤@¯ë¦Ó¨¥¡A¨Ï¥ÎªÌ¦b³æ¦æªº½s¿è®ØùØ¿é¤J¸ê®Æ¡A¦pªG«ö¤UÁä½L¤Wªº¡uEnter¡vÁä®É¡A¨t²Î·|©¿²¤³oÓ«öÁä¡C¤p¤ì°¸·Qn¦b PF µ{¦¡ùØ¡A·Qn¦h¼W¥[©³¤Uªº¥\¯à¡G·í¨Ï¥ÎªÌ¦b½s¿è®Ø¤º¿é§¹¼Æ¦r¡A«ö¤UÁä½L¤Wªº¡uEnter¡vÁä«á¡A´N¬Û·í©ó¨Ï¥Î·Æ¹«¥ªÁäÂIÀ»¡upºâ¡v«ö¶s¡A³o¼Ë¨Ï¥ÎªÌ´N¤£¥²¦A²¾°Ê·Æ¹«¡A´N·|Åܱo¤è«K³\¦h¡C³o®É¥i§Q¥Î¤lÃþ¤Æ§Þ³N¡A¹F¨ì³oӥتº¡C
¨Æ¹ê¤W¡A¤lÃþ¤Æ§Þ³Nªºì²z¨Ã¤£§xÃø¡C²³©Ò©Pª¾¡A½s¿è®Ø¨ä¹ê¤]¬OÓµøµ¡¡A¤]¦³¦Û¤vªºµøµ¡¨ç¦¡ ( window procedure )¡C¦]¦¹¥un§ä¨ì½s¿è®Øªºµøµ¡¨ç¦¡ªº¦ì§}¡AµM«á¥H·sªº½s¿è®Øµøµ¡¨ç¦¡¨ú¥N¡C¦b³o·sªºµøµ¡¨ç¦¡¤¤¡A¥²¶·¥]§t¤F³B²z¡uEnter¡vÁä°T®§ªºµ{¦¡¡A°£¦¹¤§¥~¡A¨ä¥Lªº°T®§¡A³Ì¦n³£¥æµ¹ì¦³ªº½s¿è®Øµøµ¡¨ç¦¡³B²z¡C¨º»ò¡An¦p¦ó¨ú±o½s¿è®Øªºµøµ¡¨ç¦¡ªº¦ì§}©O¡H¦b Win32 API ùئ³Ó SetWindowLong¡A¦ý·L³n«Øij¥Î·sªº SetWindowLongPtr ¨ú¥N¥¦¡C
SetWindowLongPtr ªº¥\¥Î¬O³]©wµøµ¡ªº¬Y¨ÇÄÝ©Ê¡A³o¨ÇÄÝ©Ê¥]§tµøµ¡ªº©µ¦ù·®æ¡Bµøµ¡¨ç¦¡µ¥µ¥¸ê®Æ¡A°£³]©wµøµ¡ÄÝ©Ê¥~¡A¥¦ÁÙ·|¶Ç¦^ì¨ÓªºÄÝ©Ê¡A³o¨ÇÄݩʨä¹ê³£¬O¼ÆÈ¡C©³¤U¬O SetWindowLongPtr API ªºì«¬¡G
LONG_PTR SetWindowLongPtr ( HWND hWnd, int nIndex, LONG_PTR dwNewLong );
hWnd ¬On³]©wÄݩʪºµøµ¡¥N½X¡A¥²¶·¦b©I¥s SetWindowLongPtr «e³]©w¦n¡CnIndex ¬On³]©wªºµøµ¡ÄÝ©Ê¡A¥i¥H¬O¤U±´XºØ¡F·Qn³]©wªº·sÄÝ©Ê¡A¦b©I¥s«e¦s¤J²Ä¤TӰѼơAdwNewLong¡AùØ¡C
nIndex | ¼ÆÈ | »¡¡@¡@©ú |
GWL_EXSTYLE | -20 | ³]©wµøµ¡ªº©µ¦ù·®æ ( extended window styles ) |
GWL_STYLE | -16 | ³]©w·sªºµøµ¡·®æ |
GWLP_WNDPROC | -4 | ³]©w·sªºµøµ¡¨ç¦¡ |
GWLP_HINSTANCE | -6 | ³]©w·sªº¼Ò²Õ¥N½X |
GWLP_ID | -12 | ³]©w·sªºµøµ¡ÃѧO½X |
GWLP_USERDATA | -21 | ³]©w»Pµøµ¡¤fÃöÁpªº¨Ï¥ÎªÌ¸ê®Æ¡A¦¹¸ê®Æ¥Øªº¦b´£¨Ñ«Ø¥ß¸Óµøµ¡ªºµ{¦¡¨Ï¥Î¡A¨äªì©lȬ°¹s |
DWLP_MSGRESULT | 0 | ³]©w¹ï¸Ü²°¨ç¦¡¤º¡A¤w³B²z¹L°T®§¤§ªð¦^È¡ChWnd ¬°¹ï¸Ü²°¥N½X®É¡A¤~¯à¨Ï¥Î³oÓ°Ñ¼Æ |
DWLP_DLGPROC | ³]©w·sªº¹ï¸Ü²°¨ç¦¡¡ChWnd ¬°¹ï¸Ü²°¥N½X®É¡A¤~¯à¨Ï¥Î³oÓ°Ñ¼Æ | |
DWLP_USER | ³]©w¹ï¸Ü²°µ{¦¡ÃB¥~ªº¸ê®Æ¡ChWnd ¬°¹ï¸Ü²°¥N½X®É¡A¤~¯à¨Ï¥Î³oÓ°Ñ¼Æ |
¦pªG©I¥s SetWindowLongPtr ¦¨¥\¡A¶Ç¦^ȬOì¨ÓªºÄÝ©Ê¡F¦pªG©I¥s¥¢±Ñ¡Aªð¦^ȬO 0¡C¦pªGì¨ÓÄÝ©ÊȬ° 0¡A©I¥s¦¨¥\®É¶Ç¦^Ȥ´¬° 0¡A¦ý¬O¤£·|²M°£¿ù»~½X¡C¦]¦¹¦pªGn½T©w©I¥s¥¢±Ñ©Î¦¨¥\¡A³Ì¦nªº¤èªk¬O¥ý©I¥s SetLastError ³]©w¿ù»~½X¬° 0¡A¦A©I¥s SetWindowLongPtr¡A¦pªG©I¥s¿ù»~¡A¨º»ò¶Ç¦^Ȭ° 0¡A¥B©I¥s GetLastError ±o¨ìªº¿ù»~½X«D¹s¡C
©³¤U¤p¤ì°¸±NµÛ«¦b¦p¦ó¨Ï¥Î¤lÃþ¤Æ§Þ³N¡A§Ú·Q¥H·s¼W³B²z«ö¤U¡uEnter¡vÁ䪺°T®§¬°¨Ò¡A»¡©ú¤jPªº¹Lµ{¡C²Ä¤@¨B¡A·íµM¬O³]©w·sªº½s¿è®Øµøµ¡¨ç¦¡¡A·í¦¨¥\ªº©I¥s SetWindowLongPtr «á¡A´N¯à³]©w·sªº½s¿è®Øµøµ¡¨ç¦¡¡A¨ÃÀò±o즳ªºµøµ¡¨ç¦¡¦ì§}¡A³o¥ó¨ÆÀ³¸Ó¦b¥Dµ{¦¡ªºµøµ¡¨ç¦¡ùØ¡A¦b³B²z WM_CREATE °T®§®É§¹¦¨¡C©I¥s SetWindoiwLongPtr ®É¡A¦]¬°²Ä¤@ӰѼƬO½s¿è®Øªºµøµ¡¥N½X¡A²Ä¤GӰѼƬ° GWLP_WNDPROC¡A·N«ä´N¬On³]©w hEdit ªºµøµ¡¨ç¦¡¡A©Ò¥H²Ä¤TӰѼƬ°·sªº½s¿è®Øµøµ¡¨ç¦¡¦ì§}¡C¦pªG©I¥s¦¨¥\¡Aªð¦^È´N¬Oì¨Óªº½s¿è®Øµøµ¡¨ç¦¡ªº¦ì§}¡A§â¥¦Àx¦s°_¨Ó¡A¦b·sªº½s¿è®Øµøµ¡¨ç¦¡¤¤·|¥Î¨ì¡C¹³¤U±ªº¨Ò¤l¡G
;--------------------------------------------------------------------------------------------------- ;·sªº½s¿è®Øµøµ¡¨ç¦¡¡A¥Dn³B²zEnterÁä¡A¥iÅý¨Ï¥ÎªÌ¦b½s¿è®Ø«ö¤UEnterÁä¡A¬Û·í©ó¥H·Æ¹«ÂIÀ»¡upºâ¡v«ö¶s new_edit_proc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM .IF uMsg==WM_KEYDOWN ;³B²z¨Ï¥ÎªÌ«ö¤UÁä½L¤WªºÁä®É¡A¨t²Î¶Ç¨ÓªºWM_KEYDOWN°T®§ .IF wParam==VK_RETURN ;³B²z¨Ï¥ÎªÌ¿é¤JEnterÁä¡A¨ÏR8D¡×ÃѧO½X¡AR8ªº°ªÂù¦r²Õ¡×³qª¾½X¡AµM«á±NWM_COMMAND°T®§¶Ç ;µ¹hwndªºµøµ¡¨ç¦¡ mov r8,BN_CLICKED shl r8,32 add r8,IDB_CALC INVOKE SendMessage,hwnd,WM_COMMAND,r8,hBtnCalc .ELSE ;¨ä¥L«öÁä¡A«h¶Çµ¹ì¨Óªº½s¿è®Øµøµ¡¨ç¦¡³B²z INVOKE CallWindowProc,pOldEditProc,hWnd,uMsg,wParam,lParam jmp quit .ENDIF .ELSE ;³B²z°£¤FWM_KEYDOWN¥H¥~ªº°T®§ INVOKE CallWindowProc,pOldEditProc,hWnd,uMsg,wParam,lParam jmp quit .ENDIF xor rax,rax quit: ret new_edit_proc ENDP ;--------------------------------------------------------------------------------------------------- ;¥Dµ{¦¡ªºµøµ¡¨ç¦¡ WndProc PROC hWnd:QWORD,uMsg:UINT,wParam:QWORD,lParam:QWORD .IF rdx==WM_CREATE INVOKE SetWindowLongPtr,hEdit,GWLP_WNDPROC,OFFSET new_edit_proc mov pOldEditProc,rax ......
²Ä¤G¨B¡An«Ø¥ß·sªº½s¿è®Øµøµ¡¨ç¦¡¡C¨Æ¹ê¤W¡A©Ò¦³ªºµøµ¡¨ç¦¡¡A¥]§t½s¿è®Øµøµ¡¨ç¦¡¡A©Ò»Ý°Ñ¼Æ³£¤@¼Ë¡A³£¬O¥|Ó¡A¨º´N¬O hWnd¡BuMsg¡BwParam¡BlParam¡A¨ä·N¸q¤]¬Û¦P¡C¥t¥~¡A¦¹·sªºµøµ¡¨ç¦¡¤£¶ÈÀ³¥]§t즳¨ç¦¡ªº¥þ³¡¥\¯à¡A¦P®É¤]n¯à³B²z¡A·í¨Ï¥ÎªÌ«ö¤U¡uEnter¡vÁä¡A´N¬Û·í©ó¥H·Æ¹«¥ªÁäÂIÀ»«ö¶sªº¥\¯à¡C¦]¦¹³Ì¦nªº¤è¦¡¡A´N¬O°£¤F³B²z¦³Ãö«ö¤U¡uEnter¡vÁ䪺°T®§¥~¡A¨ä¾l°T®§³£¥æ¥Ñì¨Óªºµøµ¡¨ç¦¡³B²z¡C¦Ó«ö¤U¡uEnter¡vÁä®É¡A·|¨Ï¨t²Î¹ï½s¿è®Øµo¥X WM_KEYDOWN °T®§¡A¦]¦¹¤W±ªºµ{¦¡¤ù¬q´N¥H¤@Ó .IF/.ELSE/.ENDIF °²«ü¥O§PÂ_¤À¤ä¸ô½u¡C°£¤F WM_KEYDOWN °T®§¥Ñ new_edit_proc ³B²z¡A¨ä¥L°T®§³£¥æ¥Ñì¨Óªº½s¿è®Øµøµ¡¨ç¦¡³B²z¡C
¦ý¨Ã«D¥u¦³«ö¤U¡uEnter¡vÁä¤~·|²£¥Í WM_KEYDOWN °T®§¡A«ö¤UÁä½L¤Wªº¥ô¤@Áä³£·|¡C¦]¦¹³B²z WM_KEYDOWN °T®§®É¡A¥ýÀˬd¬O§_«ö¤Uªº¬O¡uEnter¡vÁä¡A¦pªG¬O¡A¹ï¥Dµøµ¡µo°e WM_COMMAND °T®§¡A³o¬O¦]¬°«ö¤U¡u«ö¶s¡v®É¡A¨t²Î´N·|¹ï¾Ö¦³¡u«ö¶s¡vªºµøµ¡µo°e WM_COMMAND¡F¥u¬O²{¦b¥Ñ½s¿è®Øªºµøµ¡¨ç¦¡¡A¹ï¥Dµøµ¡µo¥X WM_COMMAND¡C¨Ì Windows ¨t²Îªº³W©w¡A¤w³B²z§¹¦¨ªº°T®§¡Aªð¦^Ȭ° 0¡A©Ò¥H¹ï¥Dµøµ¡µo¥X WM_COMMAND «á¡Aªð¦^ 0¡C¦pªG«ö¤Uªº¤£¬O¡uEnter¡vÁä¡A´N¥æ¥Ñì¨Óªº½s¿è®Øµøµ¡¨ç¦¡³B²z¡C
¥Ñ¥H¤W»¡©ú¡A¥iª¾¹D°£¤F¦]¬°«ö¤U¡uEnter¡vÁä©Ò²£¥Íªº WM_KEYDOWN °T®§¤§¥~¡A¨ä¾l«öÁä²£¥Íªº WM_KEYDOWN¡A¤D¦Ü©ó¨ä¥L°T®§¡A³£¥æµ¹½s¿è®Ø즳ªºµøµ¡¨ç¦¡³B²z¡C¦p¦ó§â³o¨Ç°T®§¥æ¥Ñ½s¿è®Ø즳ªºµøµ¡¨ç¦¡©O¡H¨º´N±o©I¥s CallWindowProc¡C·í¨t²Î§¹¦¨³B²z³o¨Ç°T®§¤§«á¡A©Ò²£¥Íªºªð¦^È¡A¤]À³ì«Ê¤£°Êªºªð¦^¨t²Î¤¤¡A¦]¦¹©I¥s CallWindowProc «á¡A¤£§ïÅܪð¦^È¡A§ïÅÜ CallWindowProc ªºªð¦^È¡C
ÅU¦W«ä¸q¡ACallWindowProc ¬O¥Î¨Ó©I¥s¬YÓµøµ¡¨ç¦¡ªº¡A¨ä쫬¬O¡G
LRESULT CallWindowProc ( WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
³oÓ API ´N¬O¥Î¨Ó§â¥|ӰѼƶǵ¹¬YÓ¡A¦Ó¸Óµøµ¡¨ç¦¡ªº¦ì§}´N¬O²Ä¤@ӰѼơAlpPrevWndFunc¡F«á±¥|ӰѼơA´N¬Oµøµ¡¨ç¦¡©Ò»Ýªº¥|ӰѼơCªð¦^È«hµø©Ò³B²zªº°T®§¤£¦P¦Ó§ïÅÜ¡C
©³¤U¬O PF.ASM ªºì©l½X¡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 118 119 120
121 122 123 124
125 126 127 128
129 130 131 132
133 134 135 136
137 138 139 140
141 142 143 144
145 146 147 148
149 150 151 152
153 154 155 156
157 158 159 160
161 162 163 164
165 166 167 168
169 170 171 172
173 174 175 176
177 178 179 180
181 182 183 184
185 186 187 188
189 190 191 192
193 194 195 196
197 198 199 200
201 202 203 204
205 206 207 208
209 210 211 212
213 214 215 216
217 218 219 220
221 222 223 224
225 226 227 228
229 230 231 232
233 234 235 236
237 238 239 240
241 242 243 244
245 246 247 248
249 250 251 252
253 254 255 256
257 258 259 260
261 262 263 264
265 266 267 268
269 270 271 272
273 274 275 276
277 278 279 280
281 282 283 284
285 286 287 288
289 290 291 292
293 294 295 296
297 298 299 300
301 302 303 304
305 306 307 308
309 310 311 312
313 314 315 316
317 318 319 320
321 322 323 324
325 326 327 328
329 330 331 332
333 334 335 336
337 338 339 340
341 342 343 344
345 346 347 348
349 350 351 352
353 354 355 356
357 358 359 360
361 362 363 364
365 |
;PF¯àÅý¨Ï¥ÎªÌ¿é¤J¤@Ó¤p©ó18446744073709551616¡]¡×2^64¡^¥¿¾ã¼Æ¡AµM«á§â¸Ó¥¿¾ã¼Æ¤À¸Ñ¬°½è¦]¼Æ¤§¼¿n
;¦¹µ{¦¡©I¥sis_prime¨D¥X½è¦]¼Æ¡C
OPTION CASEMAP:NONE
OPTION WIN64:7
UNICODE EQU 1 ;¨Ï¥Î¸U°ê½X
IDB_EXIT EQU 32100
IDB_CALC EQU 32101
IDE_NUMBER EQU 32102
INCLUDE WINDOWS.INC
INCLUDELIB GDI32.LIB
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
INCLUDELIB PRIMEDLL.LIB ;is_prime°Æµ{¦¡¦bPRIMEDLLµ{¦¡®w¤º
is_prime PROTO :QWORD
;***************************************************************************************************
.CONST
rcHint RECT <5,5,328,36>
rcPrmFtrArea RECT <5,38,330,90>
AppName DW 8ceah,56e0h,6578h,5206h,89e3h,0 ;¤À¸Ñ¬°½è¦]¼Æ¼¿n
ClassName DW 50h,72h,69h,6dh,65h,46h,61h,63h,74h,6fh,72h,69h ;PrimeFactori
DW 7ah,61h,74h,69h,6fh,6eh,0h ;zation
IconName DW 50h,72h,69h,6dh,65h,46h,61h,63h,74h,6fh,72h,0h ;PrimeFactor
szFontFace DW 54h,69h,6dh,65h,73h,20h,4eh,65h,77h,20h,52h,6fh ;Times New Ro
DW 6dh,61h,6eh,0 ;man
EditClass DW 65h,64h,69h,74h,0h ;edit¡×½s¿è®Øµøµ¡Ãþ§O
ButtonClass DW 62h,75h,74h,74h,6fh,6eh,0h ;button¡×«ö¶sµøµ¡Ãþ§O
szBtnCalc DW 8a08h,7b97h,0h ;pºâ
szBtnExit DW 96e2h,958bh,0h ;Â÷¶}
szPrmFmt DW 25h,49h,36h,34h,75h,662fh,8ceah,6578h,3002h,0h ;%I64u¬O½è¼Æ¡C
szNumberFmt DW 25h,49h,36h,34h,75h,3dh,0h ;%I64u=
szPrmFtrFmt0 DW 25h,49h,36h,34h,75h,0h ;%I64u
szPrmFtrFmt1 DW 0d7h,25h,49h,36h,34h,75h,0h ;¡Ñ%I64u
szZeroOne DW 6b64h,6578h,662fh,8981h,600eh,9ebch,5206h,89e3h,0ff1fh,0h ;¦¹¼Æ¬On«ç»ò¤À¸Ñ¡H
szHint DW 8f38h,5165h,4e00h,500bh,6b63h,6574h,6578h,0ff0ch,50h,72h ;¿é¤J¤@Ó¥¿¾ã¼Æ¡APr
DW 69h,6dh,65h,46h,61h,63h,74h,6fh,72h,6703h,628ah,6b64h,6578h ;imeFactor·|§â¦¹¼Æ
DW 8868h,793ah,6210h,8ceah,56e0h,6578h,4e4bh,4e58h,7a4dh,3002h ;ªí¥Ü¦¨½è¦]¼Æ¤§¼¿n¡C
DW 8acbh,8f38h,5165h,4e00h,6b63h,6574h,6578h,0ff1ah,0h ;½Ð¿é¤J¤@¥¿¾ã¼Æ¡G
szOver2p64 DW 60a8h,8f38h,5165h,7684h,6578h,4e0dh,53efh,8d85h,904eh,31h ;±z¿é¤Jªº¼Æ¤£¥i¶W¹L1
DW 38h,34h,34h,36h,37h,34h,34h,30h,37h,33h,37h,30h,39h,35h,35h ;844674407370955
DW 31h,36h,31h,35h,0ff01h,0h ;1615¡I
;***************************************************************************************************
.DATA
hInstance HINSTANCE ? ;¼Ò²Õ¥N½X
hwnd HWND ? ;¥Dµøµ¡¥N½X
hEdit HANDLE ? ;½s¿è®Ø¥N½X
hBtnCalc HANDLE ? ;¡upºâ¡v«ö¶s¥N½X
hBtnExit HANDLE ? ;¡uÂ÷¶}¡v«ö¶s¥N½X
hFont HFONT ? ;½s¿è®Ø¡B¤u§@°Ï¦r§Î¥N½X
hBaseFont HFONT ? ;½è¦]¼Æªº¦r§Î¥N½X
hExpFont HFONT ? ;½è¦]¼Æªº«ü¼Æ¤§¦r§Î¥N½X
pOldEditProc QWORD ? ;ì¨Ó½s¿è®Øªºµøµ¡¨ç¦¡
;±Nn¦L¥X½è¦]¼Æ¼¿n®É¡Awhat_to_draw¡×1¡F¨Ï¥ÎªÌ¼Æ¤J¶W¹L2^64®É¡Awhat_to_draw¡×2¡F§_«hwhat_to_draw¡×0
what_to_draw DQ 0
number DQ ? ;¨Ï¥ÎªÌ¿é¤Jªº¼ÆÈ
;¥H9Ӧ줸²Õ¬°¤@³æ¦ì¡A¨C¤@³æ¦ìªº«e8Ӧ줸²Õ¬°½è¦]¼Æ¡A²Ä9Ӧ줸²Õ¬O¸Ó½è¦]¼Æªº¾¤è
aryPrmFtr DB 40*9 DUP (0)
msg MSG <>
;***************************************************************************************************
.CODE
;---------------------------------------------------------------------------------------------------
;prime_factorization¯à±Nnum¤À¸Ñ¬°½è¦]¼Æ¼¿n¡C©Ò¥Îì²z¬°©I¥sis_prime¡Ais_prime¯à§PÂ_¬Y¥¿¾ã¼Æ¬O§_¬°½è
;¼Æ¡A¦pªG¬O½è¼Æ¡Aªð¦^Ȭ°1¡F¦pªG¤£¬O½è¼Æ¡Aªð¦^Ȭ°¸Ó¥¿¾ã¼Æªº³Ì¤p¦]¼Æ(1°£¥~)¡C¦]¦¹¥un¨Ì§Ç¨D±o³Ì¤p½è
;¦]¼Æ¡A¦A¨Ì¦¸¥H¦¹½è¦]¼Æ°£¥H¸Ó¥¿¾ã¼Æ¡A¦A±N©Ò±o¤§°Ó´À´«¸Ó¥¿¾ã¼Æ¡Aª½¨ì°Ó¬°1¡A´N§¹¦¨¤F¡C
;¿é¤J¡Gnum¡Ðn¤À¸Ñ¬°½è¦]¼Æ¼¿nªº¥¿¾ã¼Æ
;¡@¡@¡@pPrmFtr¡ÐÀx¦s½è¦]¼Æ¼¿nªº¦ì§}¡A¦@¦³360Ӧ줸²Õ¡C¨C¤EӦ줸²Õ¬°¤@²Õ¡A«e±¥|¦r²Õ¬°½è¦]¼Æ¡A±µµÛ
;¡@¡@¡@¡@¡@¡@¡@ªº¤@Ӧ줸²Õ¬°¨ä«ü¼Æ¡Cµ²§À°O¸¹¬O³sÄò¤EӦ줸²Õ§¡¬°0
;¿é¥X¡GRAX¡ÐRAX¡×0¡Anum¬°0©Î1¡FRAX¡×1¡Anum¬°½è¼Æ¡FRAX¡×2¡Anum¥i¤À¸Ñ¦¨½è¦]¼Æ¼¿n
prime_factorization PROC USES rdi num:QWORD,pPrmFtr:QWORD
LOCAL input:QWORD ;¤@¶}©l¬°num¡AµM«á°£¥H½è¦]¼Æ«á¡A©Ò±oªº°Ó¡A¦s¦^input¡A´`
mov input,rcx ;Àô°£¥H½è¦]¼Æ¡Aª½¨ì°Ó¬°1¬°¤î
;§âpPrmFtr©Ò«ü¦ì§}ªº360Ӧ줸²Õ¡A§¡³]¬°0
mov rdi,rdx
xor rax,rax
mov rcx,45
rep stosq
mov rdi,rdx
;Àˬdnum¬O§_¬°½è¼Æ¡AYRAX¡×0¡Aªí¥Ünum¬°0©Î1¡FRAX¡×1¡Aªí¥Ünum¬°½è¼Æ¡FRAX¡×¨ä¥L¼Æ¡A
;ªí¥Ünum¤£¬O½è¼Æ¡A¥BRAX¬°¨ä³Ì¤p¤§½è¦]¼Æ
get_nxt_prm: INVOKE is_prime,input
or rax,rax ;¦pªGRAX¡×0¡Aªí¥Ünum¬°0©Î1¡A¤£¬O½è¼Æ
jz quit
cmp rax,1 ;¦pªGRAX¡×1¡Aªí¥Üinput¬°½è¼Æ
jne num_isnt_prm
mov r9,num ;¦pªGinput¬°½è¼Æ¡A¦A¤ñ¸ûinput»Pnum¬O§_¬Ûµ¥
cmp r9,input ;Yinput¡×num¡Aªí¥Üinput¥¼¸g½è¦]¼Æ°£
je num_is_prm ;¹L¡A¥ç§Ynum¬°½è¼Æ¡F§_«hnum¬°¦X¼Æ
;¥Dµ{¦¡©Òµ¹ªºnum¨Ã«D½è¼Æ¡A¦ý¦]¬°num°£¥H©Ò¦³¤£¬O³Ì¤jªº½è¦]¼Æ«á¡A¦¹®Énum¬°³Ì¤jªº½è¦]¼Æ
mov rax,input
num_isnt_prm: mov r8,rax ;¦pªGnum¤£¬O½è¼Æ¡A°£¥H¨ä¦]¼Æ¡A¨Ãpºâ¥i¥H¾ã°£´X¦¸
stosq
mov rax,input
xor rdx,rdx
do_again: mov r9,rax ;¥ý§â³Q°£¼Æ¦s¦bR9ùØ¡A¦pµLªk¾ã°£¡A¥i¥ÑR9¦s¦^ì³Q°£¼Æ
div r8
or rdx,rdx
jnz nxt_prm
inc BYTE PTR [rdi]
jmp do_again
nxt_prm: inc rdi ;¦pµLªk¾ã°£¡A¥ý¨ÏRDI«ü¦V¤U¤@µ§¸ê®Æ¡A¦A¤ñ¸û³Q°£¼Æ¬O§_¤w¸g
cmp r9,1 ;¬O1¤F¡A¦pªG¬O«h¨ÏRAX¡×2¨ÃÂ÷¶}µ{¦¡¡F¦pªG¤£¬O1¡Aªí¥Ü©|¥¼°£
je finish ;§¹¡A¨Ï¤£¯à¾ã°£ªºì³Q°£¼Æ¦s¦^input¡A¦A·j´M¤U¤@Ó½è¦]¼Æ
mov input,r9
jmp get_nxt_prm
finish: mov rax,2
jmp quit
num_is_prm: inc BYTE PTR [rdi+8];¨Ï²Ä¹sµ§¸ê®Æªº½è¦]¼Æ¬°num¡A«ü¼Æ¬°1¡C¨ä¹ê³o´N¥Nªínum¥u¦³
mov [rdi],r9 ;¤@Ó½è¦]¼Æ¡A¥ç§Ynum¬°½è¼Æ
quit: ret
prime_factorization ENDP
;---------------------------------------------------------------------------------------------------
draw_prm_ftr PROC hDC:HDC
LOCAL pPrmFtrPrdt:LPSTR
LOCAL cText:DWORD ;n¦L¥Xªº¦r¤¸¼Æ
LOCAL ptEqu:DWORD ;µ¥¸¹³Ì¥kÃ䪺ÂI©Ò¦bX®y¼Ð
LOCAL flag:QWORD
LOCAL rcBase:RECT,rcExp:RECT
LOCAL buffer[40]:BYTE
INVOKE SelectObject,hDC,hBaseFont
mov rcBase.left,5
mov rcBase.top,44
mov rcExp.top,39
mov flag,0
;Y¨Ï¥ÎªÌ¿é¤J1©Î0¡A«hª½±µ¦L¥X¡u¦¹¼Æ«ç»ò¤À¸Ñ?¡v¡AµM«áªð¦^
cmp number,1
ja over_one
mov rcBase.right,280
mov rcBase.bottom,66
INVOKE DrawText,hDC,OFFSET szZeroOne,9,ADDR rcBase,DT_SINGLELINE
jmp display_ok
;Àˬd¨Ï¥ÎªÌ¿é¤Jªº¼Æ¡A¬O§_¬°½è¼Æ¡A¦pªG¬O½è¼Æ¡A¥u¦³2Ó¦]¼Æ¡A¦Û¤v©M1
over_one: lea r10,aryPrmFtr
mov pPrmFtrPrdt,r10
.IF (QWORD PTR [r10+9]==0)&&(BYTE PTR [r10+8]==1)
mov rdx,OFFSET szPrmFmt ;¨Ï¥ÎªÌ¿é¤J½è¼Æ
.ELSE
mov rdx,OFFSET szNumberFmt ;¨Ï¥ÎªÌ¿é¤J¦X¼Æ¡A¦L¥X¨Ï¥ÎªÌ¿é¤Jªº¼ÆÈ
.ENDIF
INVOKE wsprintf,ADDR buffer,rdx,number
mov cText,eax
INVOKE DrawText,hDC,ADDR buffer,cText,ADDR rcBase,DT_SINGLELINE or DT_CALCRECT
INVOKE DrawText,hDC,ADDR buffer,cText,ADDR rcBase,DT_SINGLELINE
mov r8d,rcBase.right
inc r8d
mov r10,pPrmFtrPrdt ;¦]¬°©I¥swsprintf¡BDrawText¡A©Ò¥HR10·|³Q¯}Ãa
mov ptEqu,r8d
cmp QWORD PTR [r10+9],0 ;Àˬd¨Ï¥ÎªÌ¿é¤Jªº¼Æ¡A¬O§_¬°½è¼Æ
jnz next_factor
cmp BYTE PTR [r10+8],1 ;Y¬°½è¼Æ¡A¸õÅD¦Üdisplay_ok
jz display_ok
next_factor: mov r10,pPrmFtrPrdt ;¨M©w©³¼Æ¦b¿Ã¹õ¤Wªº¶}©l¦ì¸m¡ArcBase.left
.IF (flag==0)||(flag==2) ;flag¡×0¡Aªí¥Ü²Ä¤@Ó½è¦]¼Æ¡A¦]¦¹¥H«e¤@¦¸rcBase.right¬°°ò·Ç
mov r9d,rcBase.right;flag¡×2¡A«e¤@Ó½è¦]¼Æªº«ü¼Æ¬°1¡A¥H«e¤@¦¸rcBase.right¬°°ò·Ç
.ELSEIF flag==1
mov r9d,rcExp.right ;flag¡×1¡A«e¤@Ó½è¦]¼Æªº«ü¼Æ¡Ö1¡A¥H«e¤@¦¸rcExp.right¬°°ò·Ç
.ENDIF
inc r9d
mov r8,QWORD PTR [r10]
or r8,r8
jz display_ok
mov rcBase.left,r9d
.IF flag==0
mov rdx,OFFSET szPrmFtrFmt0 ;flag¡×0¡Aªí¥Ü²Ä¤@Ó½è¦]¼Æ¡A¤£¶·Åã¥Ü¡u¡Ñ¡v
mov flag,1
.ELSEIF flag==1 ;flag¡×1¡Aªí¥Ü«e¤@Ó½è¦]¼Æªº«ü¼Æ¡Ö1¡A¥B«D³Ì¤p½è¦]¼Æ
mov rdx,OFFSET szPrmFtrFmt1 ;¡AnÅã¥Ü¡u¡Ñ¡v
.ELSE
mov rdx,OFFSET szPrmFtrFmt1 ;flag¡×2¡A«e¤@Ó½è¦]¼Æªº«ü¼Æ¬°1¡AnÅã¥Ü¡u¡Ñ¡v
mov flag,1
.ENDIF
INVOKE wsprintf,ADDR buffer,rdx,r8
mov cText,eax
INVOKE SelectObject,hDC,hBaseFont
INVOKE DrawText,hDC,ADDR buffer,cText,ADDR rcBase,DT_SINGLELINE or DT_CALCRECT
.IF rcBase.right>330
mov r8d,ptEqu
mov rcExp.top,55
mov rcBase.left,r8d
mov rcBase.top,60
INVOKE DrawText,hDC,ADDR buffer,cText,ADDR rcBase,DT_SINGLELINE or DT_CALCRECT
.ENDIF
INVOKE DrawText,hDC,ADDR buffer,cText,ADDR rcBase,DT_SINGLELINE
add pPrmFtrPrdt,8
mov r11d,rcBase.right
mov r10,pPrmFtrPrdt
inc r11d
movzx r8,BYTE PTR [r10]
cmp r8,1
jne exp_is_not_1
mov flag,2 ;«ü¼Æ¬°1¡A¤£Åã¥Ü«ü¼Æ
jmp no_draw_exp
exp_is_not_1: mov rcExp.left,r11d
INVOKE wsprintf,ADDR buffer,OFFSET szPrmFtrFmt0,r8
mov cText,eax
INVOKE SelectObject,hDC,hExpFont
INVOKE DrawText,hDC,ADDR buffer,cText,ADDR rcExp,DT_SINGLELINE or DT_CALCRECT
INVOKE DrawText,hDC,ADDR buffer,cText,ADDR rcExp,DT_SINGLELINE
no_draw_exp: inc pPrmFtrPrdt
jmp next_factor
display_ok: ret
draw_prm_ftr ENDP
;---------------------------------------------------------------------------------------------------
;¥ÑRCX©Ò«üªº¦ì§}¡Aºâ¥X¤Q¤»¶i¦ì¼ÆÈ¡A¦s©ñ©óRAXùتð¦^(Y¶W¹L18446744073709551616=2^64¡Aªð¦^®ÉR8¬°1¡F
;§_«hR8¬°0)¡C¤p©ó2^64ªº³Ì¤j½è¼Æ¬O18446744073709551557
GetInt64 PROC
LOCAL buffer[48]:WORD
INVOKE GetWindowText,hEdit,ADDR buffer,44
lea rcx,buffer
xor rax,rax
xor rdx,rdx
mov r9,10
next_digit: movzx r8,WORD PTR [rcx]
or r8,r8
jz finish
sub r8,"0"
mul r9
jc set_r8_one
add rcx,2
add rax,r8
jnc next_digit
set_r8_one: mov r8,1
finish: ret
GetInt64 ENDP
;---------------------------------------------------------------------------------------------------
;·sªº½s¿è®Øµøµ¡¨ç¦¡¡A¥Dn³B²zEnterÁä¡A¥iÅý¨Ï¥ÎªÌ¦b½s¿è®Ø«ö¤UEnterÁä¡A¬Û·í©ó¥H·Æ¹«ÂIÀ»¡upºâ¡v«ö¶s
new_edit_proc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.IF uMsg==WM_KEYDOWN
;³B²z¨Ï¥ÎªÌ«ö¤UÁä½L¤W¥ô¤@Áä®É¡A¨t²Îµo¥XªºWM_KEYDOWN°T®§
.IF wParam==VK_RETURN
;³B²z¨Ï¥ÎªÌ¿é¤JEnterÁä¡A¨ÏR8D¡×ÃѧO½X¡AR8ªº°ªÂù¦r²Õ¡×³qª¾½X¡AµM«á±NWM_COMMAND°T®§
;¶Çµ¹hwndªºµøµ¡¨ç¦¡
mov r8,BN_CLICKED
shl r8,32
add r8,IDB_CALC
INVOKE SendMessage,hwnd,WM_COMMAND,r8,hBtnCalc
xor rax,rax
.ELSE
;¨ä¥L«öÁä¡A«h¶Çµ¹ì¨Óªº½s¿è®Øµøµ¡¨ç¦¡³B²z
INVOKE CallWindowProc,pOldEditProc,hWnd,uMsg,wParam,lParam
.ENDIF
.ELSE
;°£¤FWM_KEYDOWN°T®§¥~¡A¨ä¥L°T®§¥Ñì¨Óªº½s¿è®Øµøµ¡¨ç¦¡³B²z
INVOKE CallWindowProc,pOldEditProc,hWnd,uMsg,wParam,lParam
.ENDIF
ret
new_edit_proc ENDP
;---------------------------------------------------------------------------------------------------
WndProc PROC hWnd:QWORD,uMsg:UINT,wParam:QWORD,lParam:QWORD
LOCAL ps:PAINTSTRUCT
.IF rdx==WM_PAINT
INVOKE BeginPaint,hWnd,ADDR ps
INVOKE SelectObject,ps.hdc,hFont
INVOKE DeleteObject,rax
INVOKE DrawText,ps.hdc,OFFSET szHint,41,OFFSET rcHint,DT_WORDBREAK
.IF what_to_draw==1
INVOKE draw_prm_ftr,ps.hdc
.ELSEIF what_to_draw==2
INVOKE DrawText,ps.hdc,OFFSET szOver2p64,31,OFFSET rcPrmFtrArea,DT_WORDBREAK
.ENDIF
INVOKE EndPaint,hWnd,ADDR ps
.ELSEIF rdx==WM_COMMAND
mov r10,r8
mov r11,r8
shr r10,20h ;R10D=³qª¾½X
and r11,0ffffffffh ;R11D=±±¨î¤¸¥óÃѧO½X
.IF r10d==BN_CLICKED
.IF r11d==IDB_EXIT
jmp exit
.ELSEIF r11d==IDB_CALC
call GetInt64
.IF r8==1
mov what_to_draw,2
jmp paint
.ELSE
mov number,rax
INVOKE prime_factorization,number,ADDR aryPrmFtr
mov what_to_draw,1
paint: INVOKE InvalidateRect,hWnd,OFFSET rcPrmFtrArea,TRUE
.ENDIF
.ENDIF
.ENDIF
.ELSEIF rdx==WM_CREATE
;«Ø¥ß¤TºØ¦r§Î¡QhFont(¤u§@°Ï¤Î±±¥óªº¦r§Î)¡BhBaseFont(©³¼Æ¦r§Î)¡BhExpFont(«ü¼Æ¦r§Î)
INVOKE CreateFont,15,0,0,0,100,0,0,0,ANSI_CHARSET,0,0,0,0,OFFSET szFontFace
mov hFont,rax
INVOKE CreateFont,18,0,0,0,100,0,0,0,ANSI_CHARSET,0,0,0,0,OFFSET szFontFace
mov hBaseFont,rax
INVOKE CreateFont,13,0,0,0,100,0,0,0,ANSI_CHARSET,0,0,0,0,OFFSET szFontFace
mov hExpFont,rax
;«Ø¥ß½s¿è®Ø¡Bpºâ«ö¶s¡BÂ÷¶}«ö¶s
INVOKE CreateWindowEx,0,OFFSET EditClass,0,WS_CHILD or WS_VISIBLE or WS_BORDER\
or ES_LEFT or ES_NUMBER,105,19,150,20,hWnd,IDE_NUMBER,hInstance,0
mov hEdit,rax
INVOKE CreateWindowEx,0,OFFSET ButtonClass,OFFSET szBtnCalc,BS_DEFPUSHBUTTON or\
WS_CHILD or WS_VISIBLE,145,84,88,28,hWnd,IDB_CALC,hInstance,NULL
mov hBtnCalc,rax
INVOKE CreateWindowEx,0,OFFSET ButtonClass,OFFSET szBtnExit,BS_PUSHBUTTON or\
WS_CHILD or WS_VISIBLE,239,84,88,28,hWnd,IDB_EXIT,hInstance,NULL
mov hBtnExit,rax
INVOKE SetFocus,hEdit
;³]©w«ö¶s¤Î½s¿è®Øªº¤å¦r¦r«¬
INVOKE SendMessage,hBtnCalc,WM_SETFONT,hFont,TRUE
INVOKE SendMessage,hBtnExit,WM_SETFONT,hFont,TRUE
INVOKE SendMessage,hEdit,WM_SETFONT,hFont,TRUE
;¤lÃþ¤Æ½s¿è®Ø¡AÅý¨Ï¥ÎªÌ¦b¿é¤J§¹¥¿¾ã¼Æ«á¡A«öEnterÁä¡A´N¬Û·í©ó¥H·Æ¹«ÂIÀ»¡upºâ¡v«ö¶s
INVOKE SetWindowLongPtr,hEdit,GWLP_WNDPROC,OFFSET new_edit_proc
mov pOldEditProc,rax
.ELSEIF uMsg==WM_CLOSE
exit: INVOKE DestroyWindow,hWnd
.ELSEIF uMsg==WM_DESTROY
INVOKE PostQuitMessage,NULL
.ELSE
INVOKE DefWindowProc,rcx,edx,r8,r9
ret
.ENDIF
xor rax,rax
ret
WndProc ENDP
;---------------------------------------------------------------------------------------------------
main PROC
LOCAL wc:WNDCLASSEX
INVOKE GetModuleHandle,NULL
mov hInstance,rax
mov rdx,OFFSET ClassName
mov rcx,OFFSET WndProc
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,rcx
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
mov wc.hInstance,rax
mov wc.lpszClassName,rdx
INVOKE GetStockObject,COLOR_BTNFACE
mov wc.hbrBackground,rax
mov wc.lpszMenuName,NULL
INVOKE LoadIcon,hInstance,OFFSET IconName
mov wc.hIcon,rax
mov wc.hIconSm,rax
INVOKE LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,rax
INVOKE RegisterClassEx,ADDR wc
INVOKE CreateWindowEx,0,OFFSET ClassName,OFFSET AppName,WS_OVERLAPPEDWINDOW\
,650,330,350,156,0,0,hInstance,0
mov hwnd,rax
INVOKE ShowWindow,hwnd,SW_SHOWNORMAL
INVOKE UpdateWindow,hwnd
.WHILE TRUE
INVOKE GetMessage,ADDR msg,0,0,0
.BREAK .IF !rax
INVOKE TranslateMessage,ADDR msg
INVOKE DispatchMessage,ADDR msg
.ENDW
mov rax,msg.wParam
INVOKE ExitProcess,eax
main ENDP
;***************************************************************************************************
END main |
©³¤U¬O PF.RC ªºµ{¦¡½X¡G
1 2 3 4
5 |
#include "RESOURCE.H"
1 RT_MANIFEST MOVEABLE PURE "PF.EXE.MANIFEST"
PrimeFactor ICON PrimeFactor.ic |
©³¤U¬O PF.EXE.MANIFEST ªº¤º®e¡G
1 2 3 4
5 6 7 8
9 10 11 12
13 14 |
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32'
name='Microsoft.Windows.Common-Controls'
version='6.0.0.0'
processorArchitecture='*'
publicKeyToken='6595b64144ccf1df'
language='*'
/>
</dependentAssembly>
</dependency>
</assembly> |
½Ð§â³o¤TÓÀɮ׳s¦P PrimeFactor.ico ¹Ï¥ÜÀÉ©ñ¦b¦P¤@Ó¤l¥Ø¿ý¡AµM«á¶}±Ò¡u©R¥O´£¥Ü¦r¤¸¡v¡A¨Ì·Ó¤U±ªº¤è¦¡²ÕĶ¤Î³sµ²¡G
E:\HomePage\SOURCE\Win64\PRIME>uasm64 -win64 pf.asm [Enter] UASM v2.46, Jan 8 2018, Masm-compatible assembler. Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved. Source code is available under the Sybase Open Watcom Public License. PF.ASM: 365 lines, 4 passes, 184 ms, 0 warnings, 0 errors E:\HomePage\SOURCE\Win64\PRIME>rc pf.rc [Enter] Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 Copyright (C) Microsoft Corporation. All rights reserved. E:\HomePage\SOURCE\Win64\PRIME>link pf.obj pf.res [Enter] Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. /SUBSYSTEM:WINDOWS /DEBUG E:\HomePage\SOURCE\Win64\PRIME>