¤p¤ì°¸¤w¸g¤¶²Ð¤F´XºØ²Õ¦X»y¨¥±`¨£ªº¸ê®ÆÃþ«¬¡A¥]§t¦r¦ê¡Bµu¾ã¼Æ ( WORD )¡B¾ã¼Æ ( DWORD )¡Bªø¾ã¼Æ ( QWORD ) µ¥µ¥¡A³o¤@³¹¡A¤p¤ì°¸¥´ºâ¤¶²Ð¤@Ó¸û½ÆÂøªº¸ê®ÆÃþ«¬¡Aµ²ºcÅé¡A¨äì¤å¬O structure¡C¦b Window ¤¤©w¸q¤F³\¦hµ²ºcÅé¡A¦]¦¹¦pªGn¾Ç²ß Windows µ{¦¡³]p¡A¤£¥i¤£ÁA¸Ñµ²ºcÅé¡C
µ²ºcÅé¬O¥Ñ¦hµ§¬ÛÃöªº¸ê®Æ²Õ¦¨¡A¨C¤@µ§¸ê®Æ³£ºÙ¬°Äæ¦ì ( field )¡A¦Ó¨C¤@Äæ¦ìªº¸ê®ÆÃþ«¬¥i¥H¬Û¦P ( ¸ê®ÆÃþ«¬¬O«ü¹³¡uDB¡v¡B¡uDW¡v¡B¡uDD¡v¡K¡K³o¨Ç°²«ü¥O )¡A¤]¥i¥H¤£¦P¡A³o¨ÇÄæ¦ì¶°¦X°_¨Ó¡A¥i¥Hªí¥Ü¤@¨Ç¨Æª«ªº¯S©Ê¡C
¦b«Å§iµ²ºcÅé®É¡A³o¨ÇÄæ¦ì³£¥]§t¦b STRUCT »P ENDS ¤§¶¡¡A®æ¦¡¦p¤U¡G
µ²ºcÅé¦WºÙ STRUCT ¡i¹ï»ô¤è¦¡¡j¡i,NONUNIQUE¡j Äæ¦ì¤@¦WºÙ ¸ê®ÆÃþ«¬¤@ ? Äæ¦ì¤G¦WºÙ ¸ê®ÆÃþ«¬¤G ? ¡@¡E ¡@¡E ¡@¡E ¡@¡E ¡@¡E ¡@¡E µ²ºcÅé¦WºÙ ENDS
µ²ºcÅé¦WºÙ¥Ñµ{¦¡³]p®v¦Ûq¡A¦ý¥²¶·²Ä¤@Ó¦r¥²¶·¬O©³½u©Î^¤å¦r¥À¡A¨ä«á¥i¥H¬O©³½u¡B^¤å¦r¥À¡Bªü©Ô§B¼Æ¦r¡A³Ì¦h¤£¥i¶W¹L 247 Ó¦r¡CÄæ¦ì¦WºÙ¤]¬O¥Ñµ{¦¡³]p®v¦Û¦æ³]©w¡A³W«h¦Pµ²ºcÅé¦WºÙ¤@¼Ë¡C¦b¡i¡j¤ºªº¹ï»ô¤è¦¡»P NONUNIQUE ¥i¥H¬Ù²¤¡A½Ð°Ñ¦Òµù¤@¡C
Á|Ó¨Ò¤l¨Ó»¡¡A§ÚÌ¥i¥H«Å§i¤@ÓºÙ¬° date ªºµ²ºcÅé¡A¥¦ªí¥Ü¬Y¤@¤Ñªº¤é´Á¡A¬O¥Ñ¦è¤¸¦~¥÷¡B¤ë¥÷¡B¤é²Õ¦¨¡C³oÓ date ªºµ²ºcÅé«Å§i¦p¤U¡G
date STRUCT year DW ? month DB ? day DB ? date ENDS
¥Ñ¤W±¥i¥H±oª¾¡Adate µ²ºcÅ馳¤TÓÄæ¦ì¡A¤À§O¬O year¡Bmonth¡Bday¡A¥Nªí¦è¤¸¦~¥÷¡B¤ë¥÷¡B¤é¡A¦è¤¸¦~¥÷¶W¹L 256¡A¬G¥H¨ä¸ê®ÆÃþ«¬¬° DW¡A¤ë¥÷¥²¦b 1¡ã12 ¤§¶¡¡A¤é¥²¦b 1¡ã31 ¤§¶¡¡A¬G§¡¥H DB ©w¸q´N°÷¤j¤F¡C
·íµ²ºcÅé«Å§i§¹¦¨«á¡A¥i¥H§âµ²ºcÅé·í¦¨¬O¬Y¤@ºØ¸ê®ÆÃþ«¬¡A¥¦ªº§@¥ÎÃþ¦ü DB¡BDW¡BDD¡K¡K¡C±µ¤U¨Ó´N¥i¥H¦bµ{¦¡¤¤¥H¦¹µ²ºcÅ骺¦WºÙ©w¸qÅܼƤF¡A¹³³o¼Ë¥Ñµ²ºcÅé¸ê®ÆÃþ«¬©w¸qªºÅܼƺ٬°µ²ºcÅéÅܼơA©w¸qªº¤è¦¡¦p¤U¡G
ÅܼƦW µ²ºcÅé¦WºÙ <ªì©lÈ> ÅܼƦW µ²ºcÅé¦WºÙ {ªì©lȤ@,ªì©lȤG,¡K¡K}
¨Ò¦p¡A§ÚÌèè¤w¸g«Å§i¤F date µ²ºcÅé¡A´N¥i¥H§â date ¬Ý¦¨¬O¤@ºØ§Ú̦ۦæ«Å§iªº¸ê®ÆÃþ«¬¡A§ÚÌ´N¯à¥H³oºØ¸ê®ÆÃþ«¬©w¸qÅܼơC¤p¤ì°¸¼g³o¤@³¹ªº®É¶¡¬O 2022 ¦~ 7 ¤ë 15 ¤é¡A¦]¦¹¥i¥H©w¸q©³¤Uªº¨âÓÅܼơG
today date <2022,7,15> yesterday date <2022,7,14> tomorrow date {2022,7,16}
§ÚÌ°£¤F¥i¥H¥Î¤@¹ï <> ¨Ó©w¸qµ²ºcÅéÅܼƤº¦UÄæ¦ìªºªì©lȤ§¥~¡A¤]¥i¥H¥Î¤j¬A¸¹ ( ¤j¬A¸¹´N¬O«ü¤@¹ï {} ) ¨Ó©w¸qµ²ºcÅéÅܼơA¹³¤W±²Ä¤TÓ¨Ò¤l¡C
¦pªG¤£¶·ªì©lȩΤ£¶·³¡¤Àªì©lÈ¡A¤]¥i¥H¹³¤U±ªº¤è¦¡©w¸q ( ¤U±²Ä¤@¦¡»P²Ä¤G¦¡¬O¤@¼Ëªº¡A²Ä¤T¦¡»P²Ä¥|¦¡¬O¤@¼Ëªº )¡G
someday date <> ;¬Y¤@¤Ñ¡A¤£ª¾¦~¤ë¤é¡A¬G¨Sªì©lÈ someday date <?> someday_this_year date <2022,,> ;¤µ¦~¬Y¤@¤Ñ¡A¤£ª¾¤ë¤é¡A¬G¤ë¤é¨Sªì©lÈ someday_this_year date <2022,?,?>
¦pªGnpºâµ²ºcÅ骺ªø«×¡AMASM ´£¨Ñ¤F¤TÓ¹Bºâ¤l¡GTYPE¡BLENGTHOF¡BSIZEOF ¥i¨Ñpºâ¡A³o¤TÓ¹Bºâ¤l¤£¶È¶È¯àpºâµ²ºcÅé¡A¤]¥Î©ó¤@¯ëªº¸ê®ÆÃþ«¬¡A¥i°Ñ¦Ò²Ä¤C³¹¡C©³¤U¶È´Nµ²ºcÅ黡©ú¡G
¥t¥~ÁÙ¦³¤@ÂInª`·N¡A¦pªGµ²ºcÅé«Å§i®É¡A¦³³]©w¡u¹ï»ô¤è¦¡¡v¡A¨º»òµ²ºcÅ骺¤j¤p´N¤£¬O³æ¯Âªº¬O¦UÄæ¦ìªº¸ê®ÆÃþ«¬¤j¤p¤§©M¡Apºâ¤è¦¡¬Û·íªº½ÆÂø¡A¦]¦¹¦bµ{¦¡¤¤³Ì¦n¥H¤Wzªº¤TºØ¤èªk¨Ópºâ¡C©³¤U¨Ó¬Ý¬Ý´XÓ¨Ò¤l¡A¦nÅý§A§óÁA¸Ñ³o¤TÓ¹Bºâ¤l¡G
date STRUCT year DW ? month DB ? day DB ? date ENDS ;TYPE LENGTHOF SIZEOF someday date <?> ; 4 1 4 days_of_year date 365 DUP (<?>) ; 4 365 1460
¤W±²Ä¤@Ó¨Ò¤l¡Asomeday ªº¸ê®ÆÃþ«¬¬O date¡A¦Ó date ¬O¤@Óµ²ºcÅé¡A¥Ñ¤@Ó¦r²Õ¡B¨âӦ줸²Õ²Õ¦¨¡AÁ`¦@¥|Ӧ줸²Õ¡A¦]¦¹ TYPE someday ¬° 4¡F¦Ó someday ´N¥u¦³¤@Ó¦¨û¡A¦]¦¹ LENGTHOF someday ¬° 1¡Fsomeday Á`¦@ 4 Ӧ줸²Õ¡A¬G SIZEOF someday ¬° 4¡C
²Ä¤GÓ¨Ò¤l days_of_year ªº¸ê®ÆÃþ«¬¤]¬O date¡A¬G TYPE days_of_year ¬° 4¡F¦ý¬O days_of_year ¦³ 365 Ó¦¨û¡A¦]¦¹ LENGTHOF days_of_year ¬° 365¡Fdays_of_year Á`¦@¦û¦³ 4¡Ñ365¡×1460 Ӧ줸²Õ¡A¬G SIZEOF days_of_year ¬° 1460¡C
¦bµ{¦¡¤¤¦pªGn¦s¨úµ²ºcÅ餺ªº¬YÓÄæ¦ì¡A¥i¥H¥Î¤U±ªº¤è¦¡¦s¨ú¡G
mov µ²ºcÅéÅܼƦWºÙ.Äæ¦ì¦WºÙ,¼È¦s¾¹©Î±`¼Æ mov ¼È¦s¾¹,µ²ºcÅéÅܼƦWºÙ.Äæ¦ì¦WºÙ
¨Ò¦p«e±¤w¸g«Å§i¤F date µ²ºcÅé¡A¤]©w¸q¤F someday µ²ºcÅéÅܼơA°²³]¸g¹Lµ{¦¡¹Bºâ¤wª¾ someday ¬O¦è¤¸ 1911 ¦~¤Q¤ë¤Q¤é¡A¨º»ò¥i¥H³o¼Ë§â³oÓ¤é´Á¶ñ¤J someday µ²ºcÅéÅܼơG
mov someday.year,1911 mov someday.month,10 mov someday.day,10
¨Ì·ÓºD¨Ò¡A¤p¤ì°¸¦b¦¹¥Î¤@Ó§¹¾ãªºµ{¦¡»¡©ú¦p¦ó¨Ï¥Îµ²ºcÅé¡C³oÓµ{¦¡¯àÅý¨Ï¥ÎªÌ¿é¤J Claire Redfield ( §J¹p¨à¡D¹p¼wµáº¸¡A´cÆF¥j³ù¤Gªº¤k¥D¨¤ ) ªº°ê^¼Æ¦¨ÁZ¡A«O¦s©ó¤@Óµ²ºcÅéÅܼÆùØ¡AµM«á¦A¨ú¥X³o¤T¬ì¦¨ÁZºâ¥XÁ`¤À¡A¦L¦b¿Ã¹õ¤W¡C¦¹µ{¦¡¦WºÙ¬O SCORE.ASM¡Aì©lµ{¦¡¦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 |
.MODEL SMALL,C
.386
score STRUC
addr_of_name DW ? ;¾Ç¥Í©m¦Wªº¦ì§}
number DW ? ;®y¸¹
chinese DB ? ;°ê¤å¤À¼Æ
english DB ? ;^¤å¤À¼Æ
math DB ? ;¼Æ¾Ç¤À¼Æ
score ENDS
;*******************************************************************************
.STACK
;*******************************************************************************
.DATA
claire DB "Claire Redfield$"
my_score score {?}
input_chinese DB "Input Chinese score : $"
input_english DB 0dh,0ah,"Input English score : $"
input_math DB 0dh,0ah,"Input Math score : $"
error_msg0 DB 0dh,0ah,"Input Arabic numerals only.$"
error_msg1 DB 0dh,0ah,"Score must be less than 100.$"
score_string DB " gets total score : $"
crlf DB 0dh,0ah,"$"
str_total_score DB " $"
;*******************************************************************************
.CODE
;-------------------------------------------------------------------------------
dos_call PROC pStr:WORD
mov dx,pStr
mov ah,9
int 21h
ret
dos_call ENDP
;-------------------------------------------------------------------------------
print_score PROC
LOCAL ten:WORD
mov bx,OFFSET str_total_score+2
mov ten,10
mov cx,2
next: xor dx,dx
div ten
add dl,"0"
mov [bx],dl
dec bx
loop next
add al,"0"
mov [bx],al
INVOKE dos_call,bx
ret
print_score ENDP
;-------------------------------------------------------------------------------
;¿é¤J0¡ã100ªº¤Q¶i¦ì¼Æ¡C
;¿é¤J¡GpPrompt¡G´£¥Ü¨Ï¥ÎªÌ¿é¤Jªº¦r¦ê¦ì§}
;¡@¡@¡@pValue¡G¦s©ñ¨Ï¥ÎªÌ¿é¤J¤§¼ÆȪºÅܼƦì§}¡A¦¹Åܼƪø«×¬°¤@Ӧ줸²Õ
;ªð¦^¡GCX¡×00¡Aµo¥Í¿ù»~¡AYAL¡×0FFh¡A¨Ï¥ÎªÌ¿é¤J«Dªü©Ô§B¼Æ¦r
;¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@YAL¡×0FEh¡A¨Ï¥ÎªÌ¿é¤J¶W¹L100
;¡@¡@¡@CX«D¹s¡A¿é¤J¥¿½T¡ApValue©Ò«üªº¤@Ӧ줸²Õªº¤º®e¡×¨Ï¥ÎªÌ¿é¤Jªº¼ÆÈ
input PROC pPrompt:WORD,pValue:WORD
LOCAL value:WORD
INVOKE dos_call,pPrompt
mov cx,3 ;¦Ò¸Õ¤À¼Æ¥Ñ0¡ã100¤À¡A¬G³Ì¦h¿é¤J¤T¦ì
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
.IF value>100
mov al,0feh
jmp short quit1
.ENDIF
.ELSEIF al==0dh
jmp finish
.ELSE
mov al,0ffh
jmp short quit1
.ENDIF
dec cx
.ENDW
finish: mov ax,value
mov bx,pValue
mov cx,1
mov [bx],al
jmp short quit2
quit1: xor cx,cx
quit2: ret
input ENDP
;-------------------------------------------------------------------------------
.STARTUP
mov my_score.addr_of_name,OFFSET claire
INVOKE input,OFFSET input_chinese,OFFSET my_score.chinese
jcxz error
INVOKE input,OFFSET input_english,OFFSET my_score.english
jcxz error
INVOKE input,OFFSET input_math,OFFSET my_score.math
jcxz error
INVOKE dos_call,OFFSET crlf
INVOKE dos_call,my_score.addr_of_name
INVOKE dos_call,OFFSET score_string
movzx ax,my_score.chinese
movzx bx,my_score.english
movzx cx,my_score.math
add ax,bx
add ax,cx
call print_score
xor al,al
jmp short exit
error: .IF al==0ffh
mov dx,OFFSET error_msg0
.ELSEIF al==0feh
mov dx,OFFSET error_msg1
.ENDIF
INVOKE dos_call,dx
mov al,1
exit: .EXIT al
;*******************************************************************************
END |
µ{¦¡²Ä 3¡ã9 ¦æ«Å§i score µ²ºcÅé¡A¨ä¤º¦³¤ÓÄæ¦ì¡Aȱoª`·Nªº¬O²Ä¤@ÓÄæ¦ì¡Aaddr_of_name¡A¨Ã«D¬O¾Ç¥Í©m¦Wªº¦r¦ê¡A¦Ó¬O¸Ó¦r¦ê©Ò¦b¦ì§}¡A¦Ó¥H¦¹µ²ºcÅé©Ò©w¸qªºÅܼơAmy_score¡A¦b²Ä 15 ¦æ¡A¨ä²Ä¤@ÓÄæ¦ì¬O¡uClaire Redfield$¡v¦r¦êªº¦ì§}¡C¦bµ{¦¡ªº²Ä 95 ¦æ¡A´N¬O§â¡uClaire Redfield$¡v¦r¦êªº¦ì§}¶ñ¤J my_score.addr_of_name Äæ¦ìùØ¡C¬°¦ó¤£ª½±µ§â²Ä¤@ÓÄæ¦ì¼g¦¨¬O©m¦W©O¡Hì¦]¬O¦Ò¼{¨ì©m¦Wªºªø«×¤£©T©w¡A¦]¦¹§â³oÄæ¦ì³]¦¨¬O©m¦Wªº¦ì§}¡C
SCORE.ASM ùئ³¤TӰƵ{¦¡¡G①dos_call¡A©I¥s AH¡×09H/INT 21H DOS ªA°Èµ{¦¡¡F②print_score¡A¦L¥XÁ`¤À¡F③input¡A¿é¤J¦¨ÁZ¡C«e¨âӰƵ{¦¡«Ü²³æ¡A¥Dnªº¹Lµ{¦b«e´X³¹¤w¸g´£¹L¡A´N²¤¹L¤£Á¿¡C³oùØ¥DnÁ¿°Æµ{¦¡ input¡C
²Ä 57 ¦æªí©ú¤F input °Æµ{¦¡¶·¿é¤J¨âӰѼơGpPrompt »P pValue¡C³o¨âӰѼƳ£¬O¦ì§}¡A²Ä¤@Ó¬O´£¥Ü¦r¦êªº¦ì§}¡A¥Î¨Ó´£¥Ü¨Ï¥ÎªÌn¿é¤J¤°»ò¼Ëªº¸ê®Æ¡Cµy«áªº²Ä 59 ¦æ¡A´N¨Ì·Ó´£¥Ü¦r¦êªº¦ì§}©I¥s AH¡×09H/INT 21H §â´£¥Ü¦r¦ê¦L¦b¿Ã¹õ¤W¡C
²Ä 58 ¦æ©w¸q¤F¤@Ó°Ï°ìÅܼơAvalue¡A¦¹ÅܼƥΨӼȮɰO¿ý¨Ï¥ÎªÌ¿é¤Jªº¦Ò¸Õ¤À¼Æ¡A¨C¿é¤J¤@¦ì¼Æ¡Aì¥ýªº¼ÆÈ´NnÅܬ°¤Q¿¡CÁ|¨Ò¨Ó»¡¦n¤F¡A°²³]°ê¤å¦Ò¤F 95 ¤À¡A¨Ï¥ÎªÌ¥²©w¥ý¼Æ¤J¡u9¡v³oÓ«öÁä¡Avalue ·|Åܦ¨ 9¡Fµ¥¨Ï¥ÎªÌ¦A¿é¤J¡u5¡v®É¡A¥²¶·§â 9 ¼¥H 10¡A¦A¥[¤W¿é¤Jªº 5¡A¤~·|¦¨¬° 95 ¤À¡C¦bÁÙ¨S¿é¤J«e¥²¶·¥ý§â value ³]¬°¹s ( ²Ä 61 ¦æ )¡A³o«Ü«n¡A¦]¬°°Ï°ìÅܼƬO©ñ¦b°ïÅ|ùØ¡Aì¥ý¥i¯à¤£¬O¹s¡C
¦Ò¸Õ¤À¼Æ§¡±Ä¨Ï¥Î¤Q¶i¦ì¡A¥B¤À¼Æ±q 0 ¤À¨ì 100 ¤À³Ì¦h¤T¦ì¼Æ¡A¨C¦¸³B²z¤@¦ì¡A¹Lµ{³£¬Û¦P¡A¦]¦¹¤p¤ì°¸¥Î .WHILE/ENDW °j°é³B²z¨Ï¥ÎªÌ¿é¤Jªº¼ÆÈ¡CSCORE.ASM ¥Î CX p¼ÆÁÙ¦³¦h¤Ö¦ì¼Æ»Ýn³B²z¡A¤@¶}©l³]¬°¤T¡A¨C³B²z§¹¤@¦ì¼Æ«á¡A´N·|¨Ï CX ´î¤@¡Aª½¦Ü¹sµ²§ô°j°é ( ²Ä 83¡ã84 ¦æ )¡C
¨C¦¸°j°é°õ¦æªº¹Lµ{¤À¬°¨â³¡¤À¡G¤@¬O©I¥s AH¡×01H/INT 21H Ū¨ú«öÁä¡F¤G¬O³B²z«öÁ䪺³¡¤À¡C¦b¦Ò¼{¦UºØ±¡§Î¤U¡Aµ{¦¡§â¨Ï¥ÎªÌ«ö¤UªºÁä¤À¬°¤TºØ±¡§Î¡G①ªü©Ô§B¼Æ¦r¡A¡u0¡v¡ã¡u9¡v¡F②¡uEnter¡vÁä¡F③¨ä¥L«öÁä¡A¤À§O¦b²Ä 65¡B77¡B79 ¦æÀË´ú¡C
¦bµ{¦¡²Ä 65 ¦æ¬O¥Î¨ÓÀˬd¿é¤Jªº«öÁä¬O§_¦b 30H¡ã39H ¤§¶¡¡A¦pªG¬O´N·|°õ¦æ²Ä 66¡ã72 ¦æ¡CDOS ªA°Èµ{¦¡ AH¡×01H/INT 21H ¶Ç¦^ªº¬O ASCII ½X¡A¨Ò¦p¨Ï¥ÎªÌ«ö¡u0¡vÁä¡A¶Ç¦^ 30H¡A§Y¬° ASCII ªº¡u0¡v¦r¤¸¡F¨Ï¥ÎªÌ«ö¡u9¡vÁä¡A¶Ç¦^ 39H¡A§Y¬° ASCII ¦r¤¸ªº¡u9¡v¦r¤¸¡C¦]¦¹¦b²Ä 66 ¦æ·|´î¥h 30H ( ¤]´N¬O¡u0¡v¦r¤¸ )¡A¨Ï¤§¦¨¬°¼ÆÈ ( ÁÙ°O¹q¸£¤¤ªº¦r¤¸¬O¥H¼ÆȪí¥Ü¡A¡u0¡v¦r¤¸¬O¥H 30H ªí¥Ü )¡C²Ä 67¡ã71 ¦æ¬O¨Ï value Åܬ°¤Q¿¡A¤èªk¬O 8¡Ñvalue¡Ï2¡Ñvalue ´NÅܦ¨ 10¡Ñvalue¡C¦¹³B¨S¦³¥Î mul «ü¥Oì¦]¬O mul ¥²¶·§â AX ·í¦¨³Q¼¼Æ¡A¬G±o¥ý«O¦s AX¡A¥t¤@Óì¦]¬O mul n¯Ó¶O®É¶¡¸û¦h¡CµM«á¥Î cbw §â AL ªº¼ÆÈÂX¥R¦¨ AX¡A¦A¥[¤W value ´N³B²z§¹¤@Ó¦ì¼Æ¡C³Ì«á¦AÀËÅç¬O§_¶W¹L 100¡C
µ{¦¡²Ä 77 ¦æÀˬd¨Ï¥ÎªÌ¬O§_«ö¤U¡uEnter¡vÁä¡A¦pªG¬O´Nªí¥Ü¿é¤J§¹¦¨¡A¸õ¦Ü finish: ¼Ð°O³B ( ¤]´N¬O²Ä 85 ¦æ³B ) Ä~Äò°õ¦æ¡C³oùاâ value ¨ú¥X¨Ó¡A©ñ¶i input ²Ä¤GӰѼƩҫüªº°O¾ÐÅ餺¡CSCORE.ASM §â²Ä¤GÓ°Ñ¼Æ pValue ¦s¤J BX ùØ¡A³o¼Ë´N¥i¥H§â value ¦s¤J BX ©Ò«üªº¦ì§}¡C¨Ò¦p¨Ï¥Î SYMDEB ¥h°lÂܵ{¦¡¡A°õ¦æ¡ug b6¡v«ü¥O¡ASYMDEB ¥ß¨è°õ¦æ¨ì§Y±N¿é¤J°ê¤å¦¨ÁZ®É°±¦í¡A³o®É©|¥¼°õ¦æ¡uINVOKE input,OFFSET input_chinese,OFFSET my_score.chinese¡v¡A¿é¤J SYMDEB ªº¡uu b6 bc¡v«ü¥OÆ[¹î input °Æµ{¦¡ªº¨âӰѼơG
-g b6 [Enter] AX=1566 BX=00C0 CX=01EA DX=0000 SP=04C0 BP=0000 SI=0000 DI=0000 DS=1566 ES=1543 SS=1566 CS=1553 IP=00B6 NV UP EI PL NZ NA PE NC 1553:00B6 681800 PUSH 0018 -u b6 bc [Enter] 1566:00B6 681800 PUSH 0018 ¡÷¿é¤Jªº¤À¼Æn¦s©ñ¦b 0018 ªº¦ì§}¤W¡A¥ç§Y pValue¡×0018 1566:00B9 681B00 PUSH 001B ¡÷´£¥Ü¦r¦ê ( "Input Chinese...$" ) ¦ì§}¦b 001B ³B 1566:00BC E87AFF CALL 0039 ¡÷¦¹«ü¥O¦b BC ³B¡A¦¹«ü¥O¦³¤TӦ줸²Õ ( E87AFF )¡A¬G¤U¤@«ü¥O¦b 00BF ³B¡A§Yªð¦^¦ì§}¡Cinput °Æµ{¦¡¦b¦ì§} 39 ³B -d 0 l30 [Enter] 1566:0000 4C CD 21 00 43 6C 61 69-72 65 20 52 65 64 66 69 LM!.Claire Redfi 1566:0010 65 6C 64 24 04 00 00 00-00 00 00 49 6E 70 75 74 eld$.......Input ¡÷Æ[¹î¦ì§} 001BH ³Bªº´£¥Ü¦r¦ê 1566:0020 20 43 68 69 6E 65 73 65-20 73 63 6F 72 65 20 3A Chinese score : -d 4b0 l20 [Enter] ¡÷¥Ñ SP ¥iª¾°ïÅ|³»ºÝ¦b 4C0H¡A°ïÅ|¬O©¹§C¦ì§}©µ¦ù¡A¬G¡ud 4b0 L20¡v¥iÆ[¹î°ïÅ|¥¼¨Ï¥Î«eªº¼Ë¤l¡A³£¬O©U§£¸ê®Æ 1566:04B0 03 00 57 90 0E E8 A0 61-19 01 B6 00 53 15 35 0C ..W..h a..6.S.5. 1566:04C0 49 68 5B 8B 86 5C FF 5E-5F 8B E5 5D C3 90 55 8B Ih[..\.^_.e]C.U. -g 39 [Enter] AX=1566 BX=00C0 CX=01EA DX=0000 SP=04BA BP=0000 SI=0000 DI=0000 DS=1566 ES=1543 SS=1566 CS=1553 IP=0039 NV UP EI PL NZ NA PE NC 1553:0039 55 PUSH BP -d 4b0 l20 [Enter] 1566:04B0 03 00 57 90 0E E8 A0 61-19 01 BF 00 1B 00 18 00 ..W..h a..?..... 1566:04C0 49 68 5B 8B 86 5C FF 5E-5F 8B E5 5D C3 90 55 8B Ih[..\.^_.e]C.U. -u [Enter] 1553:003A 8BEC MOV BP,SP 1553:003C 83C4FE ADD SP,-02 ┌─1553:003F FF7604 PUSH [BP+04] ¡÷dos_call ªº°Ñ¼Æ │ 1553:0042 E8BBFF CALL 0000 ¡÷©I¥s dos_call °Æµ{¦¡ └─1553:0045 83C402 ADD SP,+02 1553:0048 B90300 MOV CX,0003 1553:004B C746FE0000 MOV Word Ptr [BP-02],0000 1553:0050 EB37 JMP 0089
¤W±°õ¦æ SYMDEB ªº¡ug 39¡v¤§«á¡A´N¤w¶i¤J input °Æµ{¦¡¤F¡C¦A°õ¦æ¡ud 4b0 l20¡vÆ[¹î°ïÅ|¡A¥i¥Hµo²{°ïÅ|¤W¤w¸g¶ñ¤J¤F¤TÓ¦r²Õ ( ¥H¥Õ¦â¼Ð¥Ü )¡A¤À§O¬O¨âӰѼƤΪð¦^¦ì§}¡A°Ñ¦Ò¥k¤W¤èªº¹Ï¤@¡C³~¤¤¥Õ¦âªº¤Q¤»¶i¦ì¬O¦ì§}¡A¶À¦âªº¬O¸Ó¦ì§}ªº¤º®e¡C
µ¥µ{¦¡°õ¦æ§¹ 003C ³Bªº¡uADD SP,-02¡v«á¡A¾ãӰƵ{¦¡ªº°ïÅ|®Ø¤~ºâ§¹¦¨¡A³o®ÉÔªº°ïÅ|¦p¥k¤W¤è¹Ï¤G¡A¦b°ïÅ|¤¤¦ì§} 04B8 ³B¦s©ñªº¬O BP ªºì¥ýªº¼ÆÈ¡A0000¡F¦ý¬O¦]¬°°õ¦æ¤F 003A ³Bªº¡uMOV BP,SP¡v¡A¦]¦¹ BP ¤ºªº¼ÆȬO 04B8¡C¦Ó SP ªº¼ÆȬO 04B6¡A³o¬O¦]¬°°õ¦æ¤F 003C ³Bªº¡uADD SP,-2¡v¡A³oÓ«ü¥O¬O¬°¤F¦b°ïÅ|¤W«Ø¥ß°Ï°ìÅÜ¼Æ value¡C
±µ¤U¨Ó¦b¦ì§} 003F¡ã0045 ³Bªº¤T¹D«ü¥O¬O¦L¥X´£¥Ü¦r¦ê¡A¡uInput Chinese score : ¡v¡A¨S¤°»ò¦n¸Ñ»¡¡Aª½±µ¤U¹F¡ug 4b¡v«ü¥O¡C¦ý¦¹³B¦pªG¦³È±o¤@´£ªº¸Ü¡A¨º´N¬O¨ä°Ñ¼Æ¡A[BP+04]¡A°Ñ¦Ò¹Ï¤G±oª¾ BP¡×04B8¡A¬G BP+04¡×04BC¡A¦b¦ì§} 04BC ªº¬O 001B¡A¥¦¥Nªí´£¥Ü¦r¦êªº¦ì§}¡C
-g 4b [Enter]
Input Chinese score : AX=0924 BX=00C0 CX=0003 DX=001B SP=04B6 BP=04B8 SI=0
000 DI=0000
DS=1566 ES=1543 SS=1566 CS=1553 IP=004B NV UP EI PL NZ NA PO NC
1553:004B C746FE0000 MOV Word Ptr [BP-02],0000 SS:04B6=61A0
004B ³Bªº«ü¥O¬O¨Ï value Âk¹s¡Avalue ªº¦ì§}¬O¦b°ïÅ|ùتº BP-02 ³B¡A¤]´N¬O¦b¦ì§} 04B6¡C¨Æ¹ê¤W¡A¦b°Æµ{¦¡¤º¦s¨ú°Ï°ìÅܼƩΰѼơA³£¬O¥H BP ¬°°ò·Ç¡A¦b¾ãӰƵ{¦¡¤º BP ¤§È³£¤£À³¸Ó§ïÅÜ¡C¦Ó SP «h«ü¦V³Ì«á¤@Ó°Ï°ìÅܼƪº¦ì§}¡C
±µ¤U¨Ó¬O .WHILE/ENDW °j°é¡A¤p¤ì°¸¤£¤@¤@°lÂÜ¡AÂǥѩ³¤Uªº¡uu 7c 80¡v«ü¥O¥iª¾¡A¨Ï¥ÎªÌ¦b«ö¤U¡uEnter¡vÁä«á·|¨ì 008D ³BÄ~Äò°õ¦æ¡C¦]¦¹±µµÛ¦A¤U¡ug 8d¡v«ü¥O¡A¸õ¹L°j°é¤£¤@¤@°lÂÜ¡C¦ý¦b¦¹¹Lµ{¡Aµ{¦¡·|°±¤U¨Ón¨Ï«iªÌ¿é¤J¤À¼Æ¡A°²³]¿é¤J 95¡Aªí¥Ü°ê¤å¦Ò¤F 95 ¤À¡C½ÐÆ[¹î¤U±ªº¾Þ§@¡C
-u 7c 80 [Enter] 1553:007C 3C0D CMP AL,0D 1553:007E 7504 JNZ 0084 1553:0080 EB0B JMP 008D -g 8d [Enter] 95 [Enter] AX=010D BX=00C0 CX=0001 DX=0012 SP=04B6 BP=04B8 SI=0000 DI=0000 DS=1566 ES=1543 SS=1566 CS=1553 IP=008D NV UP EI PL ZR NA PE NC 1553:008D 8B46FE MOV AX,[BP-02] SS:04B6=005F -u [Enter] 1553:0090 8B5E06 MOV BX,[BP+06] 1553:0093 B90100 MOV CX,0001 1553:0096 8807 MOV [BX],AL 1553:0098 EB02 JMP 009C 1553:009A 33C9 XOR CX,CX 1553:009C 8BE5 MOV SP,BP 1553:009E 5D POP BP 1553:009F C3 RET
¦b 008D ³Bªº¡uMOV AX,[BP-02]¡v¡AŪªÌÀ³¸Ó«Ü²M·¡¤F¡A¦ì§} BP-02 ¬O value ©Ò¦b¦ì§}¡A¦]¦¹³o¤@¦æ¬O¨ú¥X value ¤§È¦s¤J AX ùØ¡C±µ¤U¨Ó¿é¤J¡uu¡v«ü¥OÆ[¹î¡A°Ñ¦Ò¤W±ªº¾Þ§@¡C¦b¦ì§} 0090 ³Bªºµ{¦¡¬O¡uMOV BX,[BP+06]¡v¡ABP ¤§È¬° 4B8¡A¥[¤W 6 ¤§«á¬° 4BE¡A¦]¦¹ BP+06 ¥Nªí 4BE ªº¦ì§}¡A¦Ó [BP+06] «hªí¥Ü¦s©ñ¦b¦¹¦ì§}ªº¼ÆÈ¡A0018¡A¦¹¬°²Ä¤GӰѼơA¥NªíµÛn§â¦Ò¸Õ¤À¼Æ 95 ¶ñ¤Jªº¦ì§}¡A¤]´N¬O my_score.chinese ªº¦ì§}¡C
¦b¦ì§} 0096 ³B±N my_score.chinese ªº¦ì§}¨ú¥X©ñ¤J BX ùØ¡A³o¼Ë BX ©Ò«üªº¦ì§}´N¬O my_score.chinese ªº¦ì§}¡A¥Î¡uMOV [BX],AL¡v´N¯à§â°ê¤å¤À¼Æ¶ñ¤J my_score.chinese ùؤF¡CÁöµM¦b§â¨Ï¥ÎªÌ¿é¤Jªº«öÁäÂà´«¦¨¦Ò¸Õ¤À¼Æ®É¡A¬O§â³Ì«áµ²ªG¥ý©ñ¦b value ùØ¡Avalue ¬O¤@Ó¦r²Õ¡A¦ý¦Ò¸Õ¤À¼Æ³Ì¦h¤]¥u¦³ 100 ¤À¡A¦]¦¹¶È¥Î¨ì§C¦ì¤¸²Õ¡A©Ò¥H AL ¨ä¹ê´N¬O°ê¤å¤À¼Æ¡A¦Ó AH µLÃöºòn¡C
Union ¤]¬O¤@ºØ¦Ûqªº¸ê®ÆÃþ«¬¡A«Å§i¤è¦¡»Pµ²ºcÅéÃþ¦ü¡G
Union¦WºÙ UNION ¡i¹ï»ô¤è¦¡¡j¡i,NONUNIQUE¡j Äæ¦ì¤@¦WºÙ ¸ê®ÆÃþ«¬¤@ ? Äæ¦ì¤G¦WºÙ ¸ê®ÆÃþ«¬¤G ? ¡@¡E ¡@¡E ¡@¡E ¡@¡E ¡@¡E ¡@¡E Union¦WºÙ ENDS
Union ¤ºªº¨CÓÄæ¦ìªº¦ì§}³£¬O Union ¶}©l¤§¦ì§}¡A¦ý¨ä¸ê®ÆÃþ«¬ªºªø«×«o¥i¯à¤£¦P¡A³o¼Ë´N¯à³B²z¥i¯à·|ÂX¥Rªº¸ê®Æ¡CUnion ªº¤j¤p¬O¥H³ÌªøªºÄæ¦ì¬°·Ç¡A¦Ó¨ä¥LÄæ¦ìªº°ª¦ì§}¤º¬°¹s¡C
©³¤UÁ|¤@Ó¨Ò¤l¨Ó»¡©ú Union ªºÀ³¥Î¡C¨Ò¦pµ{¦¡«Å§i¤@®a¤½¥qû¤u¸ê®Æ¬°¤@ employee µ²ºcÅé¡A¦Ó³oÓµ²ºcÅ餺ªº²Ä¤@ÓÄæ¦ì¬Oû¤uÃѧO½X¡A¥H id ªí¥Ü¡G
employee STRUCT id DW ? ;û¤uÃѧO½X salary DD ? ;û¤uÁ~¤ô seniority DB ? ;û¤u¦~¸ê employee ENDS
¤@¦ìû¤uÀ³¸Ó¦³¿W¤@µL¤GªºÃѧO½X¤£¯à»P¥L¤H«½Æ¡A¦Ó DW ¥u¯à¦³ 65536 ºØ¡C¦pªG¥H«á¤½¥qÂX¤j¶W¹L¤F 65536 ¤H¡A´N«Ü³Â·Ð¤F¡C³o®ÉÔ¥i¥H©w¸q¦¨©³¤Uªº¼Ë¤l¡G
NUMBER UNION w DW ? d DD ? NUMBER ENDS employee STRUCT id NUMBER {} ;û¤uÃѧO½XÅܦ¨ NUMBER ¸ê®ÆÃþ«¬ salary DD ? seniority DB ? employee ENDS mary employee {} john employee {} ¡K¡K ¡K¡K mov mary.id.w,cx ;(1)û¤u¼Æ¤Ö®É mov john.id.w,ecx ;(2)û¤u¼Æ¦h®É
קï«áªº¨Ò¤l¬O§âû¤uÃѧO½XÅܦ¨ NUMBER ¸ê®ÆÃþ«¬¡A¦¹¸ê®ÆÃþ«¬¥Ñ Union «Å§i¬°¨âÓ¦û¾Ú¦P¤@¦ì§}ªº WORD »P DWORD Äæ¦ì¡C·í¤½¥q¶}©l³Ð¥ß®É¡Aû¤u¼Æ¤Ö¥i¥Î¤W±²Ä (1) ¦s¨úû¤uÃѧO½X¡F·í¤½¥qÂX¤j³W¼Òû¤u¼Æ®É¡A¥i¥Î²Ä (2) ¦s¨úû¤uÃѧO½X¡C
CPU ¦b¦s¨ú°O¾ÐÅé®É¡A³q±`¤£·|¤@¦¸¥u¦s¨ú¤@Ӧ줸²Õ¡A¦³¨Ç CPU ¤@¦¸¦s¨ú¨âӦ줸²Õ¡A¦³¨Ç¬O¥|Ӧ줸²Õ¡A¦³¨Ç¬O¤KӦ줸²Õ¡K¡K³£¬O¤Gªº¾¦¸¤è¡C¦pªG©Ò¦s¨úªº°O¾ÐÅé¦ì§}è¦n¦b¤G¡B¥|©Î¤Kªº¿¼Æ¤W®É¡A·|¦³¸û¦nªº¦s¨ú®Ä²v¡A§_«hÁÙn°µÃB¥~³B²z±N·|©ìºC®Ä²v¡Cx86 ²Õ¦X»y¨¥¬°¤F¯àÅý¦s¨úµ²ºcÅ馳¸û¦nªº®Ä²v¡A¦]¦¹¦b«Å§iµ²ºcÅé®É¥i¥H³]©w¡u¹ï»ô¤è¦¡¡v( alignment ) ³o¤@¿ï¶µ¡C
¹ï»ô¤è¦¡¥u¥i¥H¬O 1¡B2¡B4 ¤TºØ¡C¨º»ò¡A²ÕĶ¾¹¤S¬O¦p¦ó¤À°t¦UÄæ¦ì¦ì§}ªº©O¡H¨ä¹ê¤]¤£Ãø¡A²ÕĶ¾¹ªº°µªk¦³´XÓì«h¡G
³o¼Ë»¡¡A¥²©wÁÙ¬O¦³¤H¤£¬ÆÁA¸Ñ¡A½Ð¬Ý©³¤Uªº¨Ò¤l¡G
employee STRUCT 4 ;«Å§iû¤uÃѧO½X¡BÁ~¤ô¡B¦~¸êªºµ²ºcÅé id DW 43981 ;43981¡×0ABCDh salary DD ? ;1200000¡×124F80h seniority DB 25 ;25¡×19h employee ENDS
²Ä¤@ÓÄæ¦ì id ¥Ñµ²ºcÅ骺°_©l¦ì§} 0 ¶}©l¡A¥¦¬O¤@Ó¦r²Õ¦]¦¹¦û¥Î¤F¨âӦ줸²Õ¡A¬G salary ¥»¨ÓÀ³¸Ó©ñ¦b¦ì§} 2 ªº¦a¤è¡A¨º»ò¬O§_¯uªº¦p¦¹©O¡Hsalary ªº¸ê®ÆÃþ«¬¬OÂù¦r²Õ¡A¸ê®ÆÃþ«¬¤j¤p¬° 4 Ӧ줸²Õ¡A¸ò¹ï»ô¤è¦¡ 4 ¤@¼Ë¤j¡A¦ý¦pªG©ñ¦b¦ì§} 2 ´N¤£¯à³Q¥|¾ã°£¡A¦]¦¹n¦b id ¤§«áÁÙ¶ñ¤J¨âÓ¼ÆȬ°¹sªº¦ì¤¸²Õ ( ¤U¹Ï¦Ç¦âªº 00 )¡A¨Ï¨ä¦ì§}Åܬ° 4¡A¤~¯à³Q¥|¾ã°£¡A¦]¦¹ salary ªº¦ì§}¬O 4¡C³Ì«á¤@Ó¬O seniority Äæ¦ì¡A¥»À³¸Ó¦b¦ì§}¤Kªº¦a¤è¡ADB ¤j¤p¬°¤@Ӧ줸²Õ¤ñ¹ï»ô¤è¦¡¤p¡A¦Ó 8 ¯à³Q¤@¾ã°£¡A¬G seniority ¦b¦ì§}¤K¡C³Ì«áµ²ªG¦p¤U¹Ï¡G
³Ì«á¤@ÓÄæ¦ì§¹¦¨«á¡Aemployee µ²ºcÅ骺¤j¤p¬° 9 Ӧ줸²Õ¡A¤£¯à³Q¹ï»ô¤è¦¡¾ã°£¡A¦]¦¹³Ì«á¦A²K¥[¤TÓ¹s ( ¤W¹Ï²`ÂŦ⪺ 00 ) Åýµ²ºcÅé¤j¤pÅܦ¨ 12¡C¤W¹Ï¤¤¡A©³¤Uªº¶À¦r¬O¬Û¹ï©ó employee ¶}ÀYªº°¾²¾¦ì§}¡A¦Ç¦â©Î²`ÂŦ⪺¡u00¡v¬O²ÕĶ¾¹¬°¤F¹ï»ô°O¾ÐÅé¦Ó¶ñ¤W¥hªº¡C