°}¦C ( array ) ¬O³\¦h¸ê®ÆÃþ«¬¬Û¦Pªº¸ê®Æ¶°¦X¦b¤@°_©Ò§Î¦¨ªº¤@ºØ¸ê®Æµ²ºc¡C¦b²Õ¦X»y¨¥ùØ¡A¥i¥H¥Î¥ô¦ó¤wª¾ªº¸ê®ÆÃþ«¬©Î¬O¦Û¦æ«Å§iªºµ²ºcÅé©w¸q¤@Ó°}¦C¡A¦b°}¦C¤¤ªº¨C¤@µ§¸ê®Æ³£ºÙ¬°¤¸¯À ( element )¡A¨CÓ¤¸¯À³£¥H¡u,¡v¤À¹j¡C¨Ò¦p©w¸q¤@Ó 10 ¥H¤U½è¼Æ©Ò§Î¦¨ªº°}¦C¡A¦p¤U¡G
prime1 DB 2,3,5,7 love DB "I love my wife so much!"
prime1 ´N¬O¤@Ó°}¦C¡A¥Ñ¥|Ó¤¸¯À²Õ¦¨¡A¨CÓ¤¸¯Àªº¸ê®ÆÃþ«¬³£¬O BYTE¡CÁöµM¦b²Ä¤T³¹®É¡A´Nª¾¹D love ¬O¤@Ó¦r¦ê¡A¦ý¬O¥¦¤]²Å¦X¥Ñ³\¦h¸ê®ÆÃþ«¬¬Û¦Pªº¸ê®Æ§Î¦¨ªº¶°¦X¡A¦]¦¹¦r¦ê¤]¥i¥H¬Ý¦¨¬O°}¦C¡C¹³ love ´N¬O¥Ñ 23 Ó¤¸¯À¡A¨CÓ¤¸¯À³£¬O¤@Ӧ줸²Õ§Î¦¨ªº°}¦C¡C
°²¦p°}¦C¤ºªº¤¸¯À¤Ó¦h¡A¦b©w¸q°}¦C®É¥i¥H¥Î¸ó¶V¦h¦æ¡A¥u¦³²Ä¤@¦æ»Ýn«Å§i¸ê®ÆÃþ«¬¡A¥B¨C¤@¦æ³£¥H¡u,¡vµ²§À¡A±q²Ä¤G¦æ°_ª½±µ¼g°}¦C¤¤ªº¤¸¯À§Y¥i¡C¨Ò¦p©³¤Uªº¨Ò¤l¡Aprime2 ¬O¤p©ó 50 ªº½è¼Æ©Ò²Õ¦¨ªº°}¦C¡G
prime2 DB 2,3,5,7,11,13, 17,19,23,29,31, 37,41,43,47
¦pªG°}¦Cùئ³«½Æªº¤¸¯À¡A¦b©w¸q®É¥i¥H¥Î DUP °²«ü¥O¡C¦pªG¤£½T©w¤¸¯À¤§Èªº¸Ü¤]¥i¥H¥Î¡u?¡vªí¥Ü¡C¨Ò¦p©³¤Uªº¨Ò¤l¡G
array1 DW 10 DUP (3) ;10 Ó 3¡A¦ý¨CÓ 3 ³£¬O¦r²Õ series DD 5 DUP (1,2,3) ;3 ÓÂù¦r²Õ¡G1¡B2¡B3 «½Æ 5 ¦¸ buffer DB 256 DUP (?),256 DUP (1) ;256 Ó¥¼ªì©lªº¼ÆȤΠ256 Ó 1¡A¨CÓ¤¸¯À³£¬O¦ì¤¸²Õ
³Ì¯S§Oªº¬O°}¦C¤]¥i¥H¬O¥Ñ¦ì§}²Õ¦¨ªº¡A¨Ò¦p©³¤Uªº¨Ò¤l¡G
str_sunday DB 0dh,0ah,"Sunday$" str_monday DB 0dh,0ah,"Monday$" str_tuesday DB 0dh,0ah,"Tuesday$" str_wednesday DB 0dh,0ah,"Wednesday$" str_thursday DB 0dh,0ah,"Thursday$" str_friday DB 0dh,0ah,"Friday$" str_saturday DB 0dh,0ah,"Saturday$" week DW OFFSET str_sunday,OFFSET str_monday,OFFSET str_tuesday, OFFSET str_wednesday,OFFSET str_thursday, OFFSET str_friday,OFFSET str_saturday
¤W±ªº week ´N¬O¤@Ó°}¦C¡A¥¦¥Ñ¤CÓ¤¸¯À²Õ¦¨¡A¦Ó¨CÓ¤¸¯À³£¦U¦Û¬O¤@Ó¦r¦êªº¦ì§}¡A¦Ó³o¤CÓ¦r¦ê«o¤S¬O¬P´Á´Xªº^¤å³æ¦r¡C
¦pªG¤£Á¿²M·¡¡A°}¦Cªº¤j¤p¥i¯à¬O«ü°}¦Cùئ³´XÓ¤¸¯À¡A¤]¦³¥i¯à¬O°}¦C¦û¥Î¤F´XӦ줸²Õ¡CMASM ùئ³¤TÓ¹Bºâ¤l¡A¯à°÷¦b¤£¦Pªº®É¾÷ùعB¥Î¥Hpºâ°}¦Cªº¤j¤p¡G①LENGTHOF ¥i¥H¨ú±o°}¦C¦³¦h¤Ö¤¸¯À¡F②TYPE ¥i¥H¨ú±o¨CÓ¤¸¯À¦û¦³¦h¤ÖӦ줸²Õ¡F③SIZEOF ¥i¥H¨ú±o¤@Ó°}¦CÁ`¦@¦û¦³¦h¤Ö¦ì¤¸²Õ¡C¬Ý©³¤Uªº¨Ò¤l¡G
;TYPE LENGTHOF SIZEOF array1 DW 10 DUP (3) ; 2 10 20 series DD 5 DUP (1,2,3) ; 4 15 60 buffer DB 256 DUP (?),256 DUP (1) ; 1 512 512 love DB "I love my wife so much!" ; 1 23 23 week DW OFFSET str_sunday,OFFSET str_monday, ; 2 7 14 OFFSET str_tuesday,OFFSET str_wednesday, OFFSET str_thursday,OFFSET str_friday,OFFSET str_saturday
n¦s¨ú°}¦C¤¤ªº¤¸¯À¡A¥²¶·¨Ï¥Î¦ì§}¡A¦Ü¤Ö¦³¨âºØ¤è¦¡¥i¥H¦s¨ú°}¦C¤¤ªº¤¸¯À¡G①ª½±µ©w§}©M②¶¡±µ©w§}¡C
¨Ï¥Îª½±µ©w§}¦s¨ú°}¦Cùتº¤¸¯À¡A¥Î¤U±ªº¦¡¤l¡G
°}¦C¦WºÙ[±`¼Æ] [°}¦C¦WºÙ+±`¼Æ]
¦b°ª¶¥»y¨¥¤¤¡A¦¹±`¼Æ¨ä¹ê´N¬O¯Á¤Þ¡A¯Á¤Þ¥i¥H·Q¦¨¬O±q¹s¶}©lªº²Ä´XÓ¤¸¯À¡F¦ý¦b²Õ¦X»y¨¥ùØ¡A¦¹±`¼Æ¤£¤@©w¬O¯Á¤ÞÈ¡A¦Ó¬O¶ZÂ÷°}¦Cªº°_©l¦ì§}¦h¤ÖӦ줸²Õ¡C¨Ó¬Ý¬Ý©³¤Uªº¨Ò¤l¡A¥i¯à·|¤ñ¸û©ú¥Õ¡C°²³]©w¸q prime2 °}¦C¬°¤p©ó 50 ªº©Ò¦³½è¼Æ¡A¦p¤Uµ{¦¡¡G
prime2 DB 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 mov al,prime2[3]
¦]¬° prime2 ¬O¥H¡uDB¡v©w¸q°}¦C¡A¦]¦¹¨CÓ¤¸¯À¦û¥Î¤@Ӧ줸²Õ¡A½Ð°Ñ¦Ò¤U¹Ï¡A²Ä¹sÓ¤¸¯À¬O 2¡B²Ä¤@Ó¤¸¯À¬O 3¡B²Ä¤GÓ¤¸¯À¬O 5¡K¡K¨Ì¦¹Ãþ±À¡C( ª`·N¡A¦b²Õ¦X»y¨¥ùØ¡A°}¦Cªº¤¸¯À¥Ñ 0 ¶}©l ) ¦pªG¥Î¡umov al,prime2[3]¡vŪ¨ú prime2 °}¦Cªº²Ä¤TÓ¤¸¯À¡AÅãµM AL ·|Åܦ¨ 7¡C
¦ý¦pªG¥Î SYMDEB ¸ü¤Jµ{¦¡¤Ï²ÕĶ«á¡A¡umov al,prime2[3]¡v·|Åܦ¨¡uMOV AL,[prime2+03]¡v¡C¨Æ¹ê¤W¡Aprime2 ¬O¬YÓ¦ì§}¡A¸Ó¦ì§}´N¬O prime2 °}¦Cªº°_©l¦ì§}¡F¦Ó¤¤¬A¸¹¤ºªº 03 ¥Nªí¬Û¹ï©ó prime2 °_©l¦ì§}«áªº¤TӦ줸²Õ ( ¥i¬Ý¦¨¬O¬Û¹ï©ó prime2 ªº°¾²¾¦ì§} )¡F¦Ó§â¤@Ó¦ì§}©ñ¦b¤@¹ï¤¤¬A¸¹¤º¡A¥Nªí¸Ó¦ì§}ùر©ÒÀx¦sªº¼ÆÈ¡C©Ò¥H¡uMOV AL,[prime2+3]¡v¤]·|¨Ï AL Åܦ¨ 7¡C
³o¼Ë¬Ý¨Ó¡A¡uprime2[3]¡v»P¡u[prime2+3]¡v¨ä¹ê¬O¤@¼Ëªº·N«ä¡C
¦ý¬O¦pªG§â°}¦C«Å§i¬° DW ¸ê®ÆÃþ«¬¡Aµ{¦¡¦p¤U¡G
prime2 DW 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 mov ax,prime2[3]
¦b°O¾ÐÅ餺ªº±Æ¦C±¡§ÎÅܦ¨¤U¹Ïªº¼Ë¤l¡A¨CÓ¤¸¯Àªº¦û¾Ú¨âӦ줸²Õ ( §Y¤@Ó¦r²Õ )¡A°õ¦æ§¹¡umov ax,prime2[3]¡v«á¡AAX Åܦ¨ 500h¡A§Y¤Q¶i¦ìªº 1280
ÅãµM¦b²Ä¤GÓ¨Ò¤l¤¤¡A¦pªGn¨ú±o²Ä¤TÓ¤¸¯À¡A¤£¯à¥Î¡umov ax,prime2[3]¡v¡C¨º¦³¨S¦³¤èªk¨ú±o²Ä n Ó¤¸¯Àªº¼ÆÈ©O ( n ¥Ñ¹s¶}©l )¡H·íµM¬O¦³ªº¡A¦Ó¥B«Ü²³æ¡C¤½¦¡Åܦ¨¡G
°}¦C¦WºÙ[n¡Ñ(TYPE °}¦C¦WºÙ)] [°}¦C¦WºÙ+n¡Ñ(TYPE °}¦C¦WºÙ)]
¤W±ªº n ¥Nªí²Ä´XÓ¤¸¯À¡A±q¹s¶}©l¡F¦Ó TYPE ¯àpºâ¥X°}¦C¤¤ªº¨CÓ¤¸¯À¦û¥Î¦h¤Ö¦ì¤¸²Õ¡C¨Ò¦p©³¤Uªº¨Ò¤l
prime2 DW 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 mov ax,prime2[?]
n¨ú±o½è¼Æ 7¡A¥¦¬O²Ä¤TÓ¤¸¯À ( ª`·N¡A2 ¬O²Ä¹sÓ¡B3 ¬O²Ä¤@Ó¡K¡K¨Ì¦¹Ãþ±À )¡A¦]¬° prime2 ¬O¥H DW ©w¸qªº¡A¬G TYPE prime2 ¬° 2¡A¦]¦¹ ? ¬° 6¡A¼g¦¨¡umov ax,prime2[6]¡v©Î¬O¡umov ax,[prime2+6]¡v³£¯àŪ¨ú²Ä¤TÓ¤¸¯À¡A¨Ï±o AX Åܬ° 7¡C
¨Æ¹ê¤W¡A²Õ¦X»y¨¥¯u¥¿ªº¼gªkÀ³¸Ó¬O¡umov ax,[prime2+6]¡v¡A¼g¦¨¡umov ax,prime2[6]¡v¬O¬°¤F°t¦X°ª¶¥»y¨¥¦Ó¤£±o¤£ªº¼gªk¡C¤£¹L¨SÃö«Y¡A¹ï©ó²ÕĶ¾¹¡AML.EXE¡A¨Ó»¡¡A¥¦³£¥i¥H±µ¨ü³o¨âºØ¼gªk¡A²ÕĶ«áªºµ²ªG¤]³£¤@¼Ë¡C
¨Ï¥Î¶¡±µ©w§}¦s¨ú°}¦C¤¤ªº¤¸¯À¡A¥Î©³¤Uªº¦¡¤l¡G
°}¦C¦WºÙ[¼È¦s¾¹] [°}¦C¦WºÙ+¼È¦s¾¹]
³o¨â±ø¦¡¤l¬O¤@¼Ëªº¡A³oùتº¼È¦s¾¹¥²¶·¬O°ò©³¼È¦s¾¹ ( ´N¬O BX )¡B¯Á¤Þ¼È¦s¾¹ ( ´N¬O SI ©Î DI ) ©Î«ü¼Ð¼È¦s¾¹ ( ´N¬O BP ©Î SP )¡A¤£¹L¦]¬° BP ¤@¯ë·|¦b°ïÅ|®Ø¤¤·í§@°ò©³¨Ï¥Î¡A¬G¨Ï¥Î BX¡BSI¡BDI ¸û¦n¡C°²¦pµ{¦¡¦³«Å§i¡u.386¡v¡A¨º»ò¥ô¦ó¤@Ó 32 ¦ì¤¸ªº³q¥Î¼È¦s¾¹ ( ¨Ò¦p EAX¡BEBX¡BECX¡BEDX ) ³£¥i¥H¡C
¡u°}¦C¦WºÙ[¼È¦s¾¹]¡vªºì²z»Pª½±µ©w§}Ãþ¦ü¡A°}¦C¦WºÙ·|³Q²ÕĶ¾¹¡u½Ķ¡v°}¦Cªº°_©l¦ì§}¡A¦A¥[¤W¼È¦s¾¹¤ºªº¼ÆÈ´NÅܦ¨¤¸¯À©Ò¦bªº¦ì§}¡C¨Ò¦p©³¤Uªº¨Ò¤l¡G
prime2 DW 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 mov bx,3 ;n¨ú±o²Ä 3 Ó¤¸¯À shl bx,1 ;¡uSHL BX,1¡v¬Û·í©ó¨ÏBX¼¥H2¡A¦]¬°¨CÓ¤¸¯À¦û¨âӦ줸²Õ mov ax,prime2[bx] ;¬Û·í©ó prime2[6]¡A«á¨ÓAX·|Åܦ¨7
¦pªG¦³»Ýn¡A¶¡±µ©w§}¤]¥i¥H¦P®É¨Ï¥Î¨âӼȦs¾¹¡A¦ý³o¨âӼȦs¾¹¤@Ó¥²¶·¬O BX¡BBP ¤GªÌ¤¤ªº¤@Ó¡A¥t¤@Ó¤]¥²¶·¬O SI¡BDI ¤GªÌ¤¤ªº¤@Ó¡C¤]´N¬O»¡¦b¡u[]¡v¤º¦pªG¦³¨âӼȦs¾¹¡A¨º»ò¥²¶·¤@Ó¬O¯Á¤Þ¼È¦s¾¹¡]SI¡BDI¡^¡A¥t¤@Ó¬O°ò©³¼È¦s¾¹¡]BX¡BBP¡^¡A¤£¯à¦P®É¬O¯Á¤Þ¼È¦s¾¹¡A©Î¦P®É¬O°ò©³¼È¦s¾¹¡C°²³]¦³«Å§i¡u.386¡v°²«ü¥Oªº¸Ü¡A³o¨âӼȦs¾¹´N¨S¦³¨î¡C¨Ò¦p©³¤Uªº¨Ò¤l¡G
prime2 DW 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 mov si,2 mov di,si mov bx,4 mov ax,prime2[bx][si] mov cx,prime2[bx+si] mov dx,[prime2+bx+si] mov ax,prime2[si+di]
˼Ʋĥ|¹D¡ã˼ƲĤG¹D«ü¥O¨ä¹ê³£¬O¦s¨ú¦P¤@¦ì§}¡A¦]¦¹ AX¡BCX¡BDX ³£µ¥©ó 7¡C¹ï²Õ¦X»y¨¥¨Ó»¡¡A¡umov dx,[prime2+bx+si]¡v¬O³Ì¦nªº¼gªk¡A¦ý¬O ML.EXE ¤@¼Ë¯à±µ¨ü¨ä¥L¨âºØ¼gªk¡A²ÕĶ«áªºµ²ªG¤]¤@¼Ë¡C¤W±µ{¦¡¤¤ªº³Ì«á¤@±ø«ü¥O¡umov ax,prime2[si+di]¡v¬O¤£¦X x86 «ü¥Oªº»yªk¡A¦]¬°¤£¯à¦P®É¨Ï¥Î¨âÓ¯Á¤Þ¼È¦s¾¹¡C
.MODEL SMALL,STDCALL .386 prime2 DW 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 mov ecx,2 mov edx,4 mov ax,prime2[ecx][edx]
¤W±ªº¨Ò¤l¤w¸g¦³¡u.386¡v°²«ü¥O¡A´N¤£©w¥u¯à¥Î EBX¡BEBP¡BESI¡BEDI µ¥°ò©³¼È¦s¾¹©Î¯Á¤Þ¼È¦s¾¹¡A³s³q¥Î¼È¦s¾¹³£¯à¦b¶¡±µ©w§}¤¤¨Ï¥Î¡C
¤W¤@³¹¡A¤p¤ì°¸¤¶²Ð¤F¤@Óµ{¦¡¥s°µ¡uWHATDAY.ASM¡v¡A¯àpºâ¦è¤¸¬Y¦~¬Y¤ë¬Y¤é¬O¬P´Á´X¡C³Ì«ápºâ¥X¬P´Á´X®É¡A¨Ï¥Î¡u.IF/.ELSEIF/.ELSE/.ENDIF¡v«ü¥O¨ú±o¬P´Á´Xªº¦r¦ê¦ì§}¡A¤~±N¨äÅã¥Ü¦b¿Ã¥ú¹õ¤W¡C
³o¤@³¹¤p¤ì°¸¤£¥Î¤¾ªøªº¡u.IF/.ELSIF/.ELSE/.ENDIF¡v°²«ü¥O¡A¦Ó¬O¥Î°}¦Cªº¤è¦¡¨ú¥X¬P´Á´Xªº¦r¦ê¦ì§}¡C§ï¼g«áªºµ{¦¡ºÙ¬°¡uWHATDAY1.ASM¡v¡Aì©l½X¦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 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 |
.MODEL SMALL,STDCALL
.386
DATE STRUCT
year DW ? ;¦è¤¸¦~¥÷
month DB ? ;¤ë¥÷
day DB ? ;¤é
DATE ENDS
;*******************************************************************************
.STACK
;*******************************************************************************
.DATA
today DATE {?}
str0 DB "Input year : $"
str1 DB 0dh,0ah,"Input month : $"
str2 DB 0dh,0ah,"Input day : $"
str_sunday DB 0dh,0ah,"Sunday$"
str_monday DB 0dh,0ah,"Monday$"
str_tuesday DB 0dh,0ah,"Tuesday$"
str_wednesday DB 0dh,0ah,"Wednesday$"
str_thursday DB 0dh,0ah,"Thursday$"
str_friday DB 0dh,0ah,"Friday$"
str_saturday DB 0dh,0ah,"Saturday$"
week DW OFFSET str_sunday,OFFSET str_monday,OFFSET str_tuesday,
OFFSET str_wednesday,OFFSET str_thursday,
OFFSET str_friday,OFFSET str_saturday
error_message DB 0dh,0ah,"Input Arabic numerals only.$"
;*******************************************************************************
.CODE
;-------------------------------------------------------------------------------
print_string PROC pStr:WORD
mov dx,pStr
mov ah,9
int 21h
ret
print_string ENDP
;-------------------------------------------------------------------------------
;¿é¤J0¡ã65535ªº¤Q¶i¦ì¾ã¼Æ¡C
;ªð¦^¡GCX¡×00¡Aµo¥Í¿ù»~
;¡@¡@¡@CX«D¹s¡A¿é¤J¥¿½T¡AAX¡×¨Ï¥ÎªÌ¿é¤Jªº¼ÆÈ
input PROC
LOCAL value:WORD
mov cx,5 ;³Ì¦h¿é¤J¤¦ì
mov value,0 ;¨ÏvalueÂk¹s
.WHILE cx
mov ah,1 ;DOSªA°Èµ{¦¡¡AÁä½L¿é¤J¦r¤¸
int 21h ;AL¡×¿é¤J¦r¤¸ªºASCII½X
.IF (al>="0")&&(al<="9")
sub al,"0"
mov dx,value
shl value,3 ;8*value
shl dx,1 ;2*value
cbw
add value,dx ;value¡×8*value+2*value¡×10*value
add value,ax ;value¡×value¡ÏAX
.ELSEIF al==0dh
jmp finish
.ELSE
jmp short quit1
.ENDIF
dec cx
.ENDW
finish: mov ax,value
mov cx,1
jmp short quit2
quit1: xor cx,cx
quit2: ret
input ENDP
;-------------------------------------------------------------------------------
;pºâ¬Y¦~¬Y¤ë¬Y¤@¤Ñ¬O¬P´Á´X
;¿é¤J¡Gpdate¡GDATEµ²ºcÅ骺¦ì§}¡A¨ä¤¤year¡Bmonth¡Bday¥²¶·¤w¶ñ¤J¥¿½T¤é´Á
;¿é¥X¡GAX¡×¬P´Á´X¡G0¡×¬P´Á¤é¡B1¡×¬P´Á¤@¡A2¡×¬P´Á¤G¡K¡K
; AX¡×-1¡A¿é¤J¿ù»~ªºDATEµ²ºcÅé
what_day_is PROC pdate:WORD
LOCAL w:WORD
;ASSUME si:PTR DATE
;what_day_is§Q¥ÎZeller's¤½¦¡¨D¥X¬YÓ¤é´Á¬O¬P´Á´X¡A¥HWªí¥Ü
;W={C/4¡Ð2*C¡ÏY¡ÏY/4¡Ï13*(M¡Ï1)/5¡ÏD¡Ð1} Mod 7
; ¤ë¥÷¡G1¤ë 2¤ë 3¤ë 4¤ë 5¤ë 6¤ë 7¤ë 8¤ë 9¤ë 10¤ë 11¤ë 12¤ë
; --------------------------------------------------------
; M¡×13 14 3 4 5 6 7 8 9 10 11 12
; A¡× 1 1 0 0 0 0 0 0 0 0 0 0
; B¡×¥|¦ì¼Æ¦r¦~¥÷¡ÐA
; C¡×Bªº«e¨â¦ì¼Æ(¤d¦ì¼Æ©M¦Ê¦ì¼Æ©Ò²Õ¦¨ªº¨â¦ì¼Æ)
; Y¡×Bªº«á¨â¦ì¼Æ(¤Q¦ì¼Æ©MÓ¦ì¼Æ©Ò²Õ¦¨ªº¨â¦ì¼Æ)
; D¡×¤é
mov si,pdate
mov cl,100
movzx bx,(DATE PTR [si]).month
mov ax,(DATE PTR [si]).year
cmp bx,2 ;Àˬd¬O§_¬°¤¸¤ë¥÷©Î¤G¤ë¥÷
ja not_adj
add bx,12 ;¦pªG¤ë¥÷¬°¤¸¤ë¥÷©Î¤G¤ë¥÷¡An½Õ¾ã¦¨«e¤@¦~ªº13¤ë¡B
dec ax ;14¤ë¡A¥ç§Y¤ë¥÷Åܦ¨13¤ë¡B14¤ë¦P®É¦~¥÷´î¤@
not_adj: div cl ;¦~¥÷¡×B¡×AX
movzx cx,ah ;CX¡×Y
movzx dx,al ;DX¡×C
mov w,cx ;W¡×Y
shr cx,2 ;CX¡×Y/4
add w,cx ;W¡×Y¡ÏY/4
mov cx,dx
shr cx,2 ;CX¡×C/4
shl dx,1 ;DX¡×2*C
movzx ax,(DATE PTR [si]).day
add w,cx ;W¡×C/4¡ÏY¡ÏY/4
sub w,dx ;W¡×C/4¡Ð2*C¡ÏY¡ÏY/4
add w,ax ;W¡×C/4¡Ð2*C¡ÏY¡ÏY/4¡ÏD
inc bx ;BX¡×M¡Ï1
mov cx,50dh ;CL¡×13¡ACH¡×5
mov ax,bx
mul cl
div ch
cbw ;AX¡×13*(M¡Ï1)/5
add ax,w
mov cx,7
dec ax ;AX¡×C/4¡Ð2*C¡ÏY¡ÏY/4¡Ï13*(M¡Ï1)/5¡ÏD¡Ð1
cwd
idiv cx ;¦]¬°DX:AX¦³¥i¯à¬Ot¼Æ¡A¦]¦¹¥ÎIDIV
cmp dx,0 ;¦pªGDX:AX¬Ot¼Æ©Ò±o¾l¼Æ(¦s©óDX)¤]¬Ot¼Æ
jge ok
add dx,cx ;¦]¦¹¾l¼Æn¥[¤W¤C¡A½T«O¬°¥¿¼Æ
ok: mov ax,dx
ret
what_day_is ENDP
;-------------------------------------------------------------------------------
.STARTUP
INVOKE print_string,OFFSET str0
call input
jcxz error
mov today.year,ax
INVOKE print_string,OFFSET str1
call input
jcxz error
mov today.month,al
INVOKE print_string,OFFSET str2
call input
jcxz error
mov today.day,al
INVOKE what_day_is,OFFSET today
mov bx,ax ;AX¡×0¡G¬P´Á¤é¡A1¡G¬P´Á¤@¡A2¡G¬P´Á¤G¡K¡K
shl bx,1 ;¦]¬°weekùتº¨CÓ¤¸¯À¦û¥Î2Ӧ줸²Õ
mov dx,week[bx] ;DX¡×¬P´Á´Xªº¦r¦ê
INVOKE print_string,dx
mov al,0
jmp short exit
error: INVOKE print_string,OFFSET error_message
mov al,1
exit: .EXIT al
;*******************************************************************************
END |
WHATDAY1.ASM ¤¤ªº²Ä 23¡ã25 ¦æ©w¸q¤F week °}¦C¡A³oÓ°}¦Cùئ@¦³ 7 Ó¤¸¯À¡A¨CÓ¤¸¯À³£¥Nªí¤@Ó¦r¦êªº¦ì§}¡A¦Ó³o¨Ç¦r¦ê³£¬O¬P´Á´Xªº^¤å³æ¦r¡C¥Î SYMDEB ¸ü¤J WHATDAY1.SYM ¤Î WHATDAY1.EXE¡A¿é¤J¡ud str_sunday¡v«Ü®e©ö¥i¥HÆ[¹î¤CÓ¬P´Á´Xªº¦r¦ê¥H¤Î week °}¦Cªº¼Ë¤l¡G( ¦³Ãö SYMDEB ¤Î MAPSYM ªº¥Îªk¡A½Ð°Ñ¦Ò²Ä¤C³¹¡A¦¹¥~n¥ý³]¦n¸ô®|¡A°õ¦æ SYMDEB¡BMAPSYM ¤~¤£·|¥X¿ù )
E:\DOS\WHATDAY>ml /Zf /Fm whatday1.asm [Enter] ¡÷¡u/Fm¡v«Ø¥ß WHATDAY1.MAP ÀÉ¡A¡u/Zf¡v«Å§i©Ò¦³²Å¸¹¦WºÙ¬°¡uPIBLIC¡v Microsoft (R) Macro Assembler Version 6.11 n«Å§i¡uPUBLIC¡vªº²Å¸¹¤~¯à¼g¤J WHATDAY1.MAP ùØ Copyright (C) Microsoft Corp 1981-1993. All rights reserved. Assembling: whatday1.asm Microsoft (R) Segmented Executable Linker Version 5.31.009 Jul 13 1992 Copyright (C) Microsoft Corp 1984-1992. All rights reserved. Object Modules [.obj]: whatday1.obj Run File [whatday1.exe]: "whatday1.exe" List File [nul.map]: "whatday1.map" /m Libraries [.lib]: Definitions File [nul.def]: E:\DOS\WHATDAY>mapsym whatday1 [Enter] ¡÷»s§@ WHATDAY1.SYM ÀÉ Microsoft (R) Symbol File Generator Version 4.00 Copyright (C) Microsoft Corp 1984, 1985. All rights reserved. Program entry point at 0000:00be E:\DOS\WHATDAY>symdeb whatday1.sym whatday1.exe [Enter] ¡÷¸ü¤J WHATDAY1.SYM ¤Î WHATDAY1.EXE °£¿ù Microsoft (R) Symbolic Debug Utility Version 4.00 ´N¯à¥Hì©l½Xªº²Å¸¹¦W°£¿ù Copyright (C) Microsoft Corp 1984, 1985. All rights reserved. Processor is [80286] -d str_sunday [Enter] 157C:0030 0D 0A 53 75 ..Su 157C:0040 6E 64 61 79 24 0D 0A 4D-6F 6E 64 61 79 24 0D 0A nday$..Monday$.. 157C:0050 54 75 65 73 64 61 79 24-0D 0A 57 65 64 6E 65 73 Tuesday$..Wednes 157C:0060 64 61 79 24 0D 0A 54 68-75 72 73 64 61 79 24 0D day$..Thursday$. 157C:0070 0A 46 72 69 64 61 79 24-0D 0A 53 61 74 75 72 64 .Friday$..Saturd 157C:0080 61 79 24 3C 00 45 00 4E-00 58 00 64 00 6F 00 78 ay$<.E.N.X.d.o.x 157C:0090 00 0D 0A 49 6E 70 75 74-20 41 72 61 62 69 63 20 ...Input Arabic 157C:00A0 6E 75 6D 65 72 61 6C 73-20 6F 6E 6C 79 2E 24 00 numerals only.$. 157C:00B0 00 00 00 00 00 00 00 00-00 00 00 00 ............ -
Æ[¹î¤W±¶É¦L°O¾ÐÅ骺¤º®e¡A¦b¦ì§} 157C:0083 ³B¥H¥Õ¦â¼Ð¥Üªº´N¬O week °}¦Cªº²Ä¹sÓ¤¸¯À¡A¤]´N¬O str_sunday ¦r¦ê ( ¥H¥Õ¦â¼Ð¥Ü ) ªº¦ì§}¡F¥H¬õ¦â¼Ð¥Üªº´N¬O week °}¦Cªº²Ä¤@Ó¤¸¯À¡A¤]´N¬O str_monday ¦r¦ê ( ¥H¬õ¦â¼Ð¥Ü ) ªº¦ì§}¡K¡K¡C
°²¦p°õ¦æ WHATDAY1.EXE ®É¡A§ÚÌ¿é¤Jªº¤é´Á¬O¡u¦è¤¸2022¦~¤K¤ë¤G¤é¡v¡A©I¥s§¹²Ä 138 ¦æªº what_day_is °Æµ{¦¡«á¡Aªð¦^®Éªº¦^¶ÇȦs©ó AX¡AAX ¬°¤G¡A¥ç§Y¬P´Á¤G¡C±µ¤U¨Ó²Ä 139 ¦æ¡A§â AX ¤§È©ñ¤J BX ùØ¡A¥Dn¥Øªº¬On¥Î BX §@¬°¶¡±µ©w§}ªº°ò©³¼È¦s¾¹¡C¤£¹L³o®É BX ¤ºªº¼ÆÈÁÙn×¥¿¡A¦]¬° week °}¦C¤¤ªº¨CÓ¤¸¯À³£¦û¨âӦ줸²Õ¡A©Ò¥H BX ÁÙn¼¥H¤G¡A²Ä 140 ¦æªº¡uSHL BX,1¡v´N¬OÅý BX ¼¥H¤G¡A±o¨ì BX ¬°¥|¡A¥ç§Y¶ZÂ÷ week °}¦C°_©l¦ì§}¥|Ӧ줸²Õ¡A¨£¤U¹Ï¥ªÃ䪺³¡¥÷¡C
¦Ó week ¬O¤@°}¦C¡A°_©l¦ì§}¬O 0083H ( ¼Ð¥Ü¥Õ¦âªº 3C 00 )¡F¦Ó BX¡×4¡A¦]¦¹¡uweek[bx]¡vªº·N«ä¨ä¹ê´N¬O°O¾ÐÅé¦ì§} 0087 ¤ºªº¼ÆÈ¡A¬d¾\¦ì§} 0087 ¤ºªº¼ÆȬO 004E¡A¦]¦¹°õ¦æ§¹¡umov dx,week[bx]¡v«á¡ADX¡×004E¡C004E ©Ò«ü¦Vªº¦ì§}¡A´N¬O¡u0dh,0ah,"Tuesday$"¡v¦r¦ê¡C
WHATDAY1.ASM ¨ä¥L³¡¥÷³£©M«e¤@³¹ªº WHATDAY.ASM Ãþ¦ü¡A´N¤£ÂØz¡C©³¤U¦A¬Ý¥t¥~¤@Ó¨Ò¤l¡C
¦ì§}²Õ¦¨ªº°}¦C¡A¤£¥u¥i¥H³B²z¸ê®Æ¡A¤]¯à·í§@¸õÅDªº¥Øªº¦a¡A¬Æ¦Ü¬O¥Î©ó©I¥s°Æµ{¦¡¡C©³¤Uªº FUNC.ASM ´N¬O§Q¥Î¨ã¦³¤£¦P¥\¯àªº¼ÆӰƵ{¦¡ªº¦ì§}²Õ¦¨°}¦C¡AFUNC.ASM ¥i¥HÅý¨Ï¥ÎªÌ¿ï¾Ü°õ¦æþÓ¥\¯à¡AµM«á¥H°}¦C¤¤ªº¤¸¯À¬°¥Øªº¦a©I¥s¬Û¹ïÀ³ªº°Æµ{¦¡¡C
FUNC.ASM ¦³¥|Ó¥\¯à¡GⓄ°h¥Xµ{¦¡¡F①²M°£¿Ã¹õ¡F②¦L¥X¤@Ó¦r¦ê¡F③¤Q¤»¶i¦ì¼ÆÅܤQ¶i¦ì¡C³o¥|Ó¥\¯à¦U¦Û¥Ñ¤@ӰƵ{¦¡t³d¡A¤À§O¬O exit¡Bcls¡Bpnt¡Bh2d¡A²Ä¤@Ó exit ¨ä¹ê¤£ºâ¬O°Æµ{¦¡¡A¥¦¬O¤@Ó¦ì§}¡A°õ¦æ¨ì¦¹¦ì§}´N·|©I¥s AH¡×4CH/INT 21H¡C¦ý¤£½×¦p¦ó¡A»P°Æµ{¦¡¦ì§}¤@¼Ë¡A³£¬O¦ì§}¡A³o¥|Ó¦ì§}²Õ¦¨ func °}¦C¡C§ÚÌ¥ý¨Ó¬Ý¬Ý FUNC.ASM ªºì©lµ{¦¡¡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 |
.MODEL SMALL,STDCALL
.386
;*******************************************************************************
.STACK
;*******************************************************************************
.DATA
menu DB 0dh,0ah,"0:Exit",
0dh,0ah,"1:Clear screen",
0dh,0ah,"2:Print a message",
0dh,0ah,"3:Hexadecimal to Decimal",
0dh,0ah,"Your selection is : $"
func DW OFFSET exit,OFFSET cls,OFFSET pnt,OFFSET h2d
string DB 9,9,"I learn assembly language.$"
prompt DB 0dh,0ah,"Input Hexadecimal : $"
;*******************************************************************************
.CODE
;-------------------------------------------------------------------------------
print_string PROC pStr:WORD
mov dx,pStr
mov ah,9
int 21h
ret
print_string ENDP
;-------------------------------------------------------------------------------
;input_hexÅý¨Ï¥ÎªÌ¿é¤J¤Q¤»¶i¦ì¼Æ¡A¨ä¼ÆȦb0¡ã65535(©ÎFFFFh)¤§¶¡
;¿é¤J¡GpStr¡G¨Ï¥ÎªÌ¿é¤Jªº¼ÆÈÅܦ¨¦r¦ê¡A¦s©ópStr©Ò«üªº¦ì§}¤§¤¤
;¿é¥X¡GCX¡×0¡A¿é¤J¿ù»~
;¡@¡@¡@CX¡×¨ä¥L¼Æ¡A¥¿½T¡AAX¡×¿é¤Jªº¼ÆÈ¡ACX¡×¨Ï¥ÎªÌ¿é¤Jªº¦r¦ê§ÀºÝ¦ì§}
input_hex PROC pStr:WORD
LOCAL value:WORD
xor cx,cx
mov si,pStr
mov value,cx ;¨ÏvalueÂk¹s
mov WORD PTR [si],0a0dh
add si,2
mov cx,4 ;¤@Ó¦r²Õªº¤Q¤»¶i¦ì¼Æ³Ì¦h¦³¥|¦ì
.WHILE cx
mov ah,1 ;DOSªA°Èµ{¦¡¡AÁä½L¿é¤J¦r¤¸
int 21h ;AL¡×¿é¤J¦r¤¸ªºASCII½X
mov [si],al
.IF al==0dh
jmp short finish
.ELSEIF (al>="0")&&(al<="9")
sub al,"0"
.ELSEIF (al>="A")&&(al<="F")
sub al,37h
.ELSEIF (al>="a")&&(al<="f")
and BYTE PTR [si],0dfh
sub al,57h
.ELSE
xor cx,cx
jmp short quit
.ENDIF
inc si
shl value,4
cbw ;¨ÏAHÅܬ°0
add value,ax ;value¡×value¡ÏAX
dec cx
.ENDW
finish: mov ax,value
mov cx,si
quit: ret
input_hex ENDP
;-------------------------------------------------------------------------------
cls PROC
mov ax,619h ;¨Ï¥ÎAH=06/INT 10H BIOS ªA°Èµ{¦¡
mov dx,184fh ;±²°Êµøµ¡ªº¥k¤U¨¤¬O²Ä24¦C¡B²Ä79¦æ
xor cx,cx ;±²°Êµøµ¡ªº¥ª¤W¨¤¬O²Ä0¦C¡B²Ä0¦æ
mov bh,7 ;±²°Ê«áªº«e´º¦â¬O¥Õ¦â¡AI´º¦â¬O¶Â¦â
int 10h
mov cx,1 ;³]©wCX¡×1¡AÅý¥Dµ{¦¡ª¾¹D¨Sµo¥Í¿ù»~
ret
cls ENDP
;-------------------------------------------------------------------------------
pnt PROC
INVOKE print_string,OFFSET string
mov cx,1 ;³]©wCX¡×1¡AÅý¥Dµ{¦¡ª¾¹D¨Sµo¥Í¿ù»~
ret
pnt ENDP
;-------------------------------------------------------------------------------
h2d PROC
LOCAL answer[16]:BYTE ;answer·|Àx¦s¨Ï¥ÎªÌ¿é¤Jªº¦r¤¸¡A¨Ò¦p¨Ï¥ÎªÌ¿é
LOCAL ten:WORD ;¤Jcd0¡Aanswer·|Åܦ¨¡u0d,0a,"CD0h=03280d$"¡v
mov ten,10
INVOKE print_string,OFFSET prompt
INVOKE input_hex,ADDR answer ;ªð¦^®É¡AYCX¡×0ªí¥Üµo¥Í¿ù»~¡F
jcxz h2d_exit ;YCX¤£¬°0¡ACX¬°input_hex¤w¶ñ¤Jªº
mov bx,cx ;¦r¦êµ²§À¦ì§}
mov WORD PTR [bx],"=h" ;§â"h="¶ñ¤J¸Ó¦ì§}
add bx,7 ;§â"d$"¶ñ¤J¸Ó¦ì§}«á¤CӦ줸²Õ³B¡A
mov WORD PTR [bx],"$d" ;¬°ªº¬O¯d¤U¤Q¶i¦ì¼ÆȪºªÅ¶¡
mov cx,5
dec bx
.WHILE cx
xor dx,dx
div ten
add dl,"0"
mov [bx],dl
dec bx
dec cx
.ENDW
lea dx,answer
INVOKE print_string,dx ;DX¡×answer¦r¦êªº¦ì§}
mov cx,1 ;³]©wCX¡×1¡AÅý¥Dµ{¦¡ª¾¹D¨Sµo¥Í¿ù»~
h2d_exit: ret
h2d ENDP
;-------------------------------------------------------------------------------
.STARTUP
select: INVOKE print_string,OFFSET menu
mov ah,1
int 21h
sub al,"0"
cmp al,3 ;¦pªG¨Ï¥ÎªÌ¿ï¾Ü¶W¹L3ªº¿ï¶µ¡A«·s¦A¿ï¤@¦¸
ja select
cbw
mov bx,ax
shl bx,1
call func[bx] ;©I¥scls¡Bpnt¡Bh2d¤TӰƵ{¦¡ªº¨ä¤¤¤@Ó
jcxz short exit ;YCX¡×0¡Aªí¥Üµo¥Í¿ù»~
jmp select
exit: .EXIT al
;*******************************************************************************
END |
FUNC.ASM ³Ì¥Dn¬[ºc¬O¡G
.DATA func DW OFFSET exit,OFFSET cls,OFFSET pnt,OFFSET h2d . . .CODE ;------------------------------------------------------------------------------- cls PROC . . cls ENDP ;------------------------------------------------------------------------------- pnt PROC . . pnt ENDP ;------------------------------------------------------------------------------- h2d PROC . . h2d ENDP ;------------------------------------------------------------------------------- .STARTUP . . mov bx,ax ;AX¡×¨Ï¥ÎªÌ¿ï¾Üªº¥\¯à¡A¥i¯à¬O0¡B1¡B2¡B3 shl bx,1 call func[bx] ;©I¥scls¡Bpnt¡Bh2d¤TӰƵ{¦¡ªº¨ä¤¤¤@Ó . . exit: .EXIT 0
§â¥Dn¬[ºc¼g¥X¨Ó¡Aµ{¦¡ªº¹B§@¤è¦¡´N«Ü²M·¡¤F¡C¦b¸ê®Æ°Ï¬qùØ©w¸q¤F func °}¦C¡Aùر¦³¥|Ó¤¸¯À¡A¤À§O¬O¥|ӰƵ{¦¡ªº¶i¤JÂI¦ì§} ( ²Ä¹sÓ¤¸¯À¤ñ¸û¯S§O¡Aexit ¨Ã«D°Æµ{¦¡¡A¬O°h¥X func µ{¦¡ªº¼Ð°O )¡C¦Ó¨CÓ¶i¤JÂIªº¦ì§}ªø«×³£¬O¨âӦ줸²Õ¡A¦]¦¹¥Î¡uDW¡v©w¸q func °}¦C¡C
¦b¤W±ªº¥Dn¬[ºc¤¤¡A¡u.STARTUP¡v¤§«áªºµ{¦¡«Ü²³æ¨S¦³¦C¥X¨Ó¡A¨ä¥Dn¥Øªº¬O¦L¥X¿ï³æ¤ÎÅý¨Ï¥ÎªÌ¿ï¾Ü 0¡ã3 ¥|ӿﶵ¡A¨Ï¥ÎªÌ¿ï¾Üªº¼ÆÈ·|Àx¦s¦b AX ùØ¡A¦ý¬O¶¡±µ©w§}ªº¼È¦s¾¹¥u¯à¥Î BX¡BBP¡BSI¡BDI µ¥¡A©Ò¥H§â AX ¤§È²¾¤J BX¡A¦A¼¥H¤G¡A±µ¤U¨Ó´N¬O«ÂI¤F¡C
¨Æ¹ê¤W¡ACALL¡BJMP ¤£¬O¥u¯à©I¥s©Î¸õÅD¨ì©T©wªº¦ì§}¥h¡A¥¦Ì¥i¥H¥Î¡u¶¡±µ¡vªº¤è¦¡¡AÅý©I¥s©Î¸õÅDªº¥Øªº¦aÅܱo¥i¨Ì¹ê»Ú±¡ªp¦Ó§ïÅÜ¡C¦¹³B¤p¤ì°¸¶È¤¶²Ð¶¡±µ©I¥s¡A¶¡±µ¸õÅD´X¥G¤@¼Ë¡A¥u¤£¹L±N«ü¥O¥Ñ CALL §ï¦¨ JMP ¦Ó¤w¡AŪªÌ¥i¥H¦Û¦æ¹Á¸Õ¡C
¶¡±µ©I¥s©M¶¡±µ©w§}Ãþ¦ü¡A¥i¥H¨Ï¥Î±`¼Æ»P¼È¦s¾¹·í°µ©I¥sªº¥Øªº¦a¦ì§}¡A¨ä»yªk¦p¤U¡G
CALL ¼È¦s¾¹ CALL [¼È¦s¾¹] CALL ±`¼Æ[¼È¦s¾¹] ;©Î CALL [±`¼Æ+¼È¦s¾¹] CALL ±`¼Æ[¼È¦s¾¹¤@][¼È¦s¾¹¤G] ;©Î CALL [±`¼Æ+¼È¦s¾¹¤@+¼È¦s¾¹¤G]
¤@¯ë¨Ó»¡¡A¤W±ªº±`¼ÆÀ³¸Ó¬O¤@Ó°}¦Cªº¦WºÙ¡A¦Ó¼È¦s¾¹¥u¯à¬O BX¡BBP¡BSI¡BDI¡F¦pªG¬O¦³¼È¦s¾¹¤@¡B¼È¦s¾¹¤G¡A¨º»ò°ò©³¼È¦s¾¹ ( BX ©Î BP ) ©M¯Á¤Þ¼È¦s¾¹ ( SI ©Î DI ) ¦U¿ï¤@Ó¡A¤£¯à¦P®É¬O°ò©³¼È¦s¾¹©Î¦P®É¬O¯Á¤Þ¼È¦s¾¹¡C¨Ò¦p©³¤Uªº¨Ò¤l³£¬O¥¿½Tªº¡G
call bx
call [bx]
call func[si]
call func[si][bp]
call [func+si+bp] ;»P¡ucall func[si][bp]¡v¬Û¦P
¦Ó©³¤Uªº¨Ò¤l¬O¿ù»~ªº¡G
call bx+si ;¥u¯à¥Î¤@ӼȦs¾¹ call ax ;¤£¯à¥Î AX ¼È¦s¾¹ call [cx] ;¤£¯à¥Î CX ¼È¦s¾¹ call func[si+di] ;¤£¯à¥Î¨âÓ¯Á¤Þ¼È¦s¾¹
¦pªG¤w¸g«Å§i¡u.386¡v°²«ü¥O¡A¨º»ò 32 ¦ì¤¸ªº³q¥Î¼È¦s¾¹¡BESI¡BEDI¡BEBP ³£¯à¥Î¦b¶¡±µ©I¥s¤W¡A¤£¨ü¤W±ªº¨î¡C©³¤Uªº¨Ò¤l³£¬O¥¿½Tªº¡G
call ecx call WORD PTR [eax] call func[esi][edi]
¨¥Âk¥¿¶Ç¡A§Ṳ́w¸g©ú¥Õ¤F¥¿½Tªº¶¡±µ©I¥s»yªk¡A©³¤U¤p¤ì°¸¥Î FUNC.ASM ·í§@¨Ò¤l»¡©ú¶¡±µ©I¥s¬O¦p¦ó¹B§@ªº¡C
¸ò WHATDAY1.ASM ¤@¼Ë¡A¸g¹L²ÕĶ¡B³sµ²¡B»s³y SYM ÀÉ«á¡A¥Î SYMDEB ¸ü¤J FUNC.SYM¡BFUNC.EXE «á¡Aª½±µ¿é¤J¡G
E:\DOS\STRUCT>c:\tools\symdeb func.sym func.exe [Enter] Microsoft (R) Symbolic Debug Utility Version 4.00 Copyright (C) Microsoft Corp 1984, 1985. All rights reserved. Processor is [80286] -u select [Enter] ¡÷¤Ï²ÕĶÅý¨Ï¥ÎªÌ¿ï¾Ü¥\¯àªºµ{¦¡½X _TEXT:select: 1564:00EF 680000 PUSH 0000 1564:00F2 E80BFF CALL _print_string@2 ¡÷¦]¬°¦bµ{¦¡¤@¶}©l«Å§i¤F¡u.MODEL SMALL,STDCALL¡v¡ASTDCALL ·| 1564:00F5 B401 MOV AH,01 Åý²ÕĶ¾¹×§ï°Æµ{¦¡¦WºÙ¡A°Ñ¾\¡u²Ä¤Q³¹ PROTO °²«ü¥O¡v¤@¸`¡C 1564:00F7 CD21 INT 21 1564:00F9 2C30 SUB AL,30 ;'0' 1564:00FB 3C03 CMP AL,03 1564:00FD 77F0 JA select -u [Enter] 1564:00FF 98 CBW 1564:0100 8BD8 MOV BX,AX 1564:0102 D1E3 SHL BX,1 1564:0104 FF975C00 CALL [BX+005C] ¡÷³o¤@¦æ¨ä¹ê´N¬O call func[bx] 1564:0108 E302 JCXZ exit 1564:010A EBE3 JMP select _TEXT:exit: 1564:010C B44C MOV AH,4C ;'L'
¦ì§}²Ä 0104 ³Bªº¡uCALL [BX+005C]¡v¨ä¹ê´N¬Oì©lµ{¦¡²Ä 118 ¦æ¡ucall func[bx]¡v¤Ï²ÕĶªºµ²ªG¡C°}¦C func ¥NªíµÛ 005C ³oÓ¦ì§}¡A¦bì©lµ{¦¡¤¤¡A§â¡ufunc[bx]¡v¼g¦¨¡u[func+bx]¡v¬O¤@¼Ëªº¡A²ÕĶ®É ML.EXE ·|¥hpºâ func ªº¦ì§}¡AµM«á¼g¦b¥ØªºÀɤº¡C§ÚÌÅçÃÒ func ¬O¤£¬O¦b 005C ³B¡A¿é¤J¤U±«ü¥O¡G
-d func l8 [Enter] 1575:0050 0C 01 7A 00 ..z. ¡÷ªGµM¦b 005C ³B 1575:0060 8A 00 94 00 ....
°}¦C func ªº²Ä¹sÓ¤¸¯À¦b¦ì§} 010C ³B¡A¨Ì¾Úì©lµ{¦¡¬Oµ{¦¡¼Ð°O exit: ³B¡A¤W±¥H¥Õ¦â¦r¼Ð¥ÜªºªG¯u´N¬O¦b 010C ³B¡C¦AÀˬd¬Ý¬Ý²Ä¤@Ó¤¸¯À¡A¿é¤J¡uu 7a¡v¤Ï²ÕĶ³o¬qµ{¦¡½X¡AªGµM¸òì©lµ{¦¡ªº cls °Æµ{¦¡¤@¼Ë¡C
-u 7a [Enter]
_TEXT:_cls@0:
1564:007A B81806 MOV AX,0618
1564:007D BA4F18 MOV DX,184F
1564:0080 33C9 XOR CX,CX
1564:0082 B707 MOV BH,07
1564:0084 CD10 INT 10
1564:0086 B90100 MOV CX,0001
1564:0089 C3 RET
¦b¦ì§} 007A ³B¬O°Æµ{¦¡ cls ªº¶i¤JÂI¡A¦ý¬O¦Ó pnt¡Bprint_string ³o¨Ç°Æµ{¦¡¤]³£¦p¦¹¡AML.EXE ¬°¦ónקï°Æµ{¦¡¦WºÙ©O¡H³o¤p¤ì°¸¤]¤£²M·¡¡A¦p¦³¤j¯«ª¾¹D¡A©|¤£§[«ü±Ð¡C
°²³]¨Ï¥ÎªÌ¿ï¾Ü®É«ö¡u2¡v³oÓ«öÁä¡A¨º»ò AX ¤ºªº¼ÆÈ´N¬O 2¡C²¾¤J BX «á¦A§â BX ¼¥H¤G¡A¨º»ò BX ´N¬O 4 ¤F¡C©³¤U¸ÑÄÀ¶¡±µ©I¥s¡A¡ucall func[bx]¡v³o¹D«ü¥O¡C°Ñ¦Ò¥k¹Ï¡Afunc °}¦Cªº¦ì§}¬O 005C¡A¦A¥[¤W BX ¬Û¹ï©ó func °_©l¦ì§}ªº°¾²¾¦ì§}´N¬O 0060¡A¦Ó¥[¤W¤¤¬A¸¹«á¥Nªíªº«o¬O 0060 °O¾ÐÅé¦ì§}¤ºªº¼ÆÈ¡A¦]¦¹ func[bx] ¨ä¹ê¥Nªí 008A ( °O±o func[bx] »P [func+bx] ¬O¤@¼Ëªº·N«ä )¡A©Ò¥H³Ì«á¡ucall func[bx]¡v´NÅܦ¨¡uCALL 008A¡v¤F¡C
¤p¤ì°¸¦b¼¶¼g³o¤@³¹®É¡A¬d¾\ºô¸ô¤Wªº¸ê®Æ¡Aµo²{³\¦h¤Hµo°Ý¡uJMP BX¡v»P¡uJMP [BX]¡v¦³¦ó¤£¦P¡H°²³]§A¤w¸g²z¸Ñ¤F¡u¶¡±µ©I¥s»P¶¡±µ¸õÅD¡v¡A´N¯à¸Ñµª³oÓ°ÝÃD¤F¡C«eªÌ¬O¸õÅD¨ì BX ©Ò«üªº¦ì§}¡A«áªÌ¬O¸õÅD¨ì BX ©Ò«ü¦ì§}ªº°O¾ÐÅ餺®eªº¦ì§}¡C¥H¤W¹Ï¬°¨Ò¡A°²³] BX¡×0060H¡A¡uJMP BX¡v´N¬O¸õ¨ì 0060H ªº¦ì§}³B¡A¦Ó¡uJMP [BX]¡v«h·|¸õ¨ì 008AH ªº¦ì§}³B¡C
²M°£¿Ã¹õªº¤è¦¡¦³³\¦hºØ¡A¥i¥H§âµø°T°O¾ÐÅ骺¤º®e³£¶ñ¤JªÅ¥Õ¦r¤¸¡A³o¼Ë¿Ã¹õ´NÅܦ¨ªÅµL¤@ª«¡A®ÄªG´N¬Û·í©ó²M°£¿Ã¹õ¤F¡C³o¤@³¹¤p¤ì°¸n¤¶²Ð¥t¤@ºØ¤èªk¡A±N¿Ã¹õªº¤º®e¦V¤W±²°Ê¡A¦pªG±²°Êªº¦æ¼Æ¶W¹L¿Ã¹õ³Ì¦hÅã¥Üªº¦æ¼Æ¡A¤]¯àÅý¿Ã¹õÅܪŵL¤@ª«¡C
©Ò¿×¦V¤W±²°Êªº·N«ä¬O³Ì¤W±¤@¦C¦V¤W²¾¨ì¿Ã¹õ¥~±¡A¦]¦¹ì¨Ó³Ì¤W±¤@¦Cªº¤º®e´N®ø¥¢¤£¨£¡A¦Ó¨ä¤Uªº¨C¤@¦C³£¦V¤W²¾°Ê¤@¦C¡A¿Ã¹õ³Ì©³¤U·|·s²¾¤J¤@¦CªÅ¥Õ¦C¡C·íµM¤]¥i¥H¦V¤W±²°Ê¤£¥u¤@¦C¡A¦pªG¬O¦V¤W±²°Ê¼Æ¦C¡A³o¼Ëªº¸Ü´N¬O³Ì¤W±¼Æ¦C²¾¥X¿Ã¹õ¥~¡A¿Ã¹õ©³¤U¦^²¾¶i¼Æ¦CªÅ¥Õ¦C¡C
BIOS ªA°Èµ{¦¡¡AAH¡×06H/INT 10H ¥i¥H¦V¤W±²°Ê¿Ã¹õ¼Æ¦C¡A¤£¶È¦p¦¹¡A¥¦±²°Êªº½d³ò¤]¥i¥H¶È¤@Ó¡uµøµ¡¡v¤º ( ©Ò¿×µøµ¡¥i¥H·Q¦¨¤@Ó¯x§Î )¡A¦Ó¦bµøµ¡¥~³¡«h¤£¨ü¼vÅT¡CAH¡×07H/INT 10H «h¬O¦V¤U±²°Ê¿Ã¹õ¼Æ¦C¡A¥¦ªº¥Îªk©M AH¡×06H/INT 10H ³£¬Û¦P¡A®t§O¥u¦b©ó±²°Ê¤è¦V¡A¦]¦¹©³¤U¶È»¡©ú AH¡×06H/INT 10H ªº¥Îªk¡G
µøµ¡¤º®e¦V¤W±²°Ê ¿é¤J¡GAH¡×06H ¡@¡@¡@AL¡×·Qn±²°Êªº¦C¼Æ¡AY AL¡×0¡Aªí¥Ü²M°£µøµ¡¤º®e ¡@¡@¡@CH¡BCL¡×¥ª¤W¨¤ªº¦C¸¹»P¦æ¸¹ ¡@¡@¡@DH¡BDL¡×¥k¤U¨¤ªº¦C¸¹»P¦æ¸¹ ¡@¡@¡@BH¡×µøµ¡©³³¡·s²¾¶i¨Óªº«e´º¦â»PI´º¦â °õ¦æ¡GINT 10H ªð¦^¡GµL µøµ¡¤º®e¦V¤U±²°Ê ¿é¤J¡GAH¡×07H ¡@¡@¡@AL¡×·Qn±²°Êªº¦C¼Æ¡AY AL¡×0¡Aªí¥Ü²M°£µøµ¡¤º®e ¡@¡@¡@CH¡BCL¡×¥ª¤W¨¤ªº¦C¸¹»P¦æ¸¹ ¡@¡@¡@DH¡BDL¡×¥k¤U¨¤ªº¦C¸¹»P¦æ¸¹ ¡@¡@¡@BH¡×µøµ¡©³³¡·s²¾¶i¨Óªº«e´º¦â»PI´º¦â °õ¦æ¡GINT 10H ªð¦^¡GµL
¥ý¬Ý¤U¹Ïªº±¡§Î¡A¨C¤@¦C³£¬Oªü©Ô§B¼Æ¦r¡A±q 0 ¶}©l¨ì 9¡A¤£Â_«½Æ¡C¥u¦³²HÂŦâ©Ò®Ø¦íªº¯x§Î¤£¦P¡A¦ý¥J²ÓÆ[¹î¡A·|µo²{²HÂŦâ®Ø®Ø¤ºªº¨C¤@¦C©¹¤W²¾¨â¦C¡A´N§Î¦¨¤U±ªº¹Ï§Î¡G
°Ñ¦Ò¤W¹Ï¡A¯x§Î©Ò§Î¦¨ªº¡uµøµ¡¡v¶È¥H¥ª¤W¨¤©M¥k¤U¨¤ªº®y¼Ð´N¯àµe±o¥X¨Ó¡A¥ª¤W¨¤ªº®y¼Ð©ñ¦b CX ¼È¦s¾¹ùØ¡ACH ¬O¦C¸¹¡ACL ¬O¦æ¸¹¡C¦b¼Æ¾Ç¤Wªº¥±®y¼Ð¥H ( x,y ) ¨Óªí¥Ü¡Ax ¬O¾î®y¼Ð¡By ¬OÁa®y¼Ð¡C¦b³oùؤp¤ì°¸¤]¥é·Ó¼Æ¾Ç¤Wªºª½¨¤®y¼Ð¨tªí¥Ü¡ACL ¥Nªí¾î®y¼Ð ( §Y¦æ¸¹ )¡ACH ¥NªíÁa®y¼Ð ( §Y¦C¸¹ )¡F¹ï©ó 80¡Ñ25 ªº¤å¦r¼Ò¦¡¦Ó¨¥¡ACL ½d³ò¦b 0¡ã79 ¤§¶¡¡ACH ¦b 0¡ã24 ¤§¶¡¡C¦pªG¬O¦b 40¡Ñ25 ¤å¦r¼Ò¦¡¤U¡A¨º»ò CL ½d³ò¦b 0~39 ¤§¶¡¡C
¥k¤U¨¤®y¼Ð¦s©ñ¦b DX ùØ¡A©M CX ¤@¼Ë¡Cn©¹¤W±²°Ê´X¦C¦s©ñ¦b AL ùØ¡A°²³] AL ¬°¹s¡A´N·|²M°£µøµ¡¤º®e¡Cµøµ¡©³³¡·s²¾¶iªº¤º®e³£¬OªÅ¥Õ¡A¦Ó¨ä«e´º¦â»PI´º¦â¦s©ñ©ó BH ¤º¡C¤W¹Ï©Ò§Î¦¨ªºµøµ¡¡A¬O°õ¦æ©³¤Uªºµ{¦¡³y¦¨ªº¡G
mov cx,904h ;²Ä¤E¦C²Ä¥|¦æ mov dx,1014h ;²Ä¤Q¤»¦C²Ä¤G¤Q¦æ mov ah,6 mov al,2 ;±²°Ê¨â¦æ mov bh,7 int 10h
¦pªGn²M°£¿Ã¹õ¡A´N¥i¥H§ân±²°Êªºµøµ¡½d³ò³]¬°¾ãӿùõ¡C¨Ò¦pÅã¥Ü¼Ò¦¡ 3 ¬° 80¡Ñ25 ªº¤å¦r¼Ò¦¡¡A¨º»ò´N¥i¥H§â CX ³]¬° 0¡ADX ³]¬° 184Fh¡AAL ³]¬° 0 ©Î 25¡C( 18h¡×24¡B4Fh¡×79 )
AH¡×06H/INT 10H ªA°Èµ{¦¡¤£¶È¯à¦b¤å¦r¼Ò¦¡¤¤¦V¤W±²°Ê¡A¦b¹Ï§Î¼Ò¦¡¤¤¤]¯à¦V¤W±²°Ê¡C¦pªG¬O¦b¹Ï§Î¼Ò¦¡¡An±²°Êªºµøµ¡¤´¥H²Ä´X¦C¡B²Ä´X¦æªº¦r¤¸ªí¥Ü¡A¤£¬O¥HÂIªí¥Ü¡C¨Ò¦pÅã¥Ü¼Ò¦¡ 6 ¬° 640¡Ñ200ªº¹Ï§Î¼Ò¦¡¤¤¡A·íµM¤]¥i¥HÅã¥Ü¦r¤¸¡A©ÒÅã¥Üªº¦r¤¸¨CÓ³£¬O 8¡Ñ8¡A´«¥y¸Ü»¡¦bÅã¥Ü¼Ò¦¡ 6 ªº®ÉÔ¡A³Ì¦h¥iÅã¥Ü 25¦C¡A¨C¦C 80 Ó¦r¤¸¡C·ín¦V¤W±²°Ê¦Ó«ü©wµøµ¡½d³ò®É¡A¤´±N¥¦¬Ý§@¤å¦r¼Ò¦¡¤U«ü©w CX »P DX¡C¤]´N¬O»¡ CL¡BDL ½d³ò¦b 0¡ã79 ¤§¶¡¡ACH¡BDH ªº½d³ò¦b 0¡ã24 ¤§¶¡¡C±²°Ê®É¡Aµøµ¡¤ºªº¥ô¦ó¤º®e¡A¥]§t¤å¦r©Î¹Ï®×³£¯à±²°Ê¡C