code ends
end start
1E£¬00£¬00£¬00£¬20£¬00£¬00£¬64
3.13 ÔÚDEBUGÏÂÉèÖÃ(SP)=20H£¬ÉèÖÃAX¡¢BX¡¢CX¡¢DXΪ²»Í¬Öµ£¬°ÑÕâËĸö¼Ä´æÆ÷ÄÚÈÝÒÀ´ÎѹÈë¶ÑÕ»£¬ÔÙ´Ó¶ÑÕ»ÖÐÒÀ´Îµ¯³öµ½SI¡¢DI¡¢BP¡¢BX¼Ä´æÆ÷¡£Ð´³öÒ»¶Î³ÌÐòʵÏÖÉÏÊö²Ù×÷£¬²¢»³öÿÌõÈëÕ»Ö¸ÁîÖ´ÐкóSPºÍ¶ÑÕ»ÖÐÊý¾ÝµÄ±ä»¯¡£
3.14 Çó³ö7450HÓëÒÔϸ÷Ê®Áù½øÖÆÊýµÄºÍ¼°²î£¬²¢¸ù¾Ý½á¹û±ê³öSF¡¢ZF¡¢CF¡¢OF±ê־λµÄÖµ¡£
(1) 1234H (2)5678H (3)9804H
(4)E0A0H
SF¡¢ZF¡¢CF¡¢OF (1)1234H+7450H£¬ 1 0 0 1 (2)5678H+7450H£¬ 1 0 0 1 (3)9804H+7450H£¬ 0 0 1 0 (4)E0A0H+7450H£¬ 0 0 1 0 3.15 ÔÚÊý¾Ý¶ÎÓÐÈç϶¨Ò壺 DATAX DW £¿£¬£¿ DATAY DW £¿£¬£¿
SUM DW £¿£¬£¿£¬£¿£¬£¿
ÇëÓÃ16λָÁî°´ÏÂÁÐÒªÇóд³öÖ¸ÁîÐòÁУº
(1)DATAXºÍDATAYÁ½¸ö×ÖÊý¾ÝÏà¼Ó£¬ºÍ´æ·ÅÔÚSUMÖС£ MOV AX£¬DATAX ADD AX£¬DATAY MOV SUM AX
(2)DATAXºÍDATAYÁ½¸öË«×ÖÊý¾ÝÏà¼Ó£¬ºÍ´æ·ÅÔÚSUM¿ªÊ¼µÄ×Öµ¥ÔªÖС£ MOV AX£¬DATAX MOV DX£¬DATAX+2 ADD AX£¬DATAY ADC DX£¬DATAY+2 MOV SUM£¬AX MOV SUM+2£¬DX
(3)DATAXºÍDATAYÁ½¸ö×ÖÊý¾ÝÏà³Ë(ÓÃMUL)£¬»ý´æ·ÅÔÚSUM¿ªÊ¼µÄ×Öµ¥
ÔªÖС£
(4)DATAXºÍDATAYÁ½¸öË«×ÖÊý¾ÝÏà³Ë(ÓÃMUL)£¬»ý´æ·ÅÔÚSUM¿ªÊ¼µÄ×Öµ¥ÔªÖС£
(5)DATAXË«×Ö³ýÒÔ×ÖDATAY(ÓÃDIV)£¬É̺ÍÓàÊý´æ·ÅÔÚSUM¿ªÊ¼µÄ×Öµ¥ÔªÖС£
(6)DATAXºÍDATAYÁ½¸öѹËõBCDÂëÊý¾ÝÏà¼Ó£¬ºÍ´æ·ÅÔÚSUMÖС£ 3.16 Ë«×Ö³¤ÊýX´æ·ÅÔÚDXºÍAXÖУ¬Éè(DX)=1004H£¬(AX)=1002H£¬ÒªÇóÓÃ16λָÁîд³ö£º
(1) ¶Ô´æ·ÅÔÚDXºÍAXÖеÄË«×Ö³¤ÊýÇó²¹µÄÖ¸ÁîÐòÁУ¬²¢ÑéÖ¤½á¹û¡£ NOT AX
NOT DX ADD AX£¬1 ADC DX£¬0
(2) Óüõ·¨Ö¸ÁîÇó0-XµÄÖ¸ÁîÐòÁУ¬²¢ÑéÖ¤½á¹û¡£ MOV BX£¬0 MOV CX£¬0 SUB BX£¬AX
SBB CX£¬DX £»½á¹ûÔÚCX£¬BX
3.17ÊÔ±àдһ¸ö³ÌÐòÇó³öË«×Ö³¤ÊýµÄ¾ø¶ÔÖµ¡£Ë«×Ö³¤ÊýÔÚA¿ªÊ¼µÄ×Öµ¥ÔªÖУ¬½á¹û´æ·ÅÔÚB¿ªÊ¼µÄ×Öµ¥ÔªÖС£
A DW £¿£¬£¿ B DW £¿£¬£¿ ¡£¡£¡£
MOV AX£¬A MOV DX£¬A+2 TEST DX£¬8000H JZ ZS NOT AX NOT DX ADD AX£¬1 ADC DX£¬0 ZS£ºMOV B£¬AX
MOV B+2£¬DX
3.18 ÓÃÒÆλָÁîΪÖ÷ʵÏÖ¶ÔAXÖеÄÎÞ·ûºÅÊý³ËÒÔ5£¬²»¿¼Âdz˻ý¿ÉÄܳ¬³ö16λ¡£
MOV DX£¬AX
MOV CL£¬2 SHL AX£¬CL ADD AX£¬DX
3.19 ÓÃÒÆλָÁîΪÖ÷ʵÏÖ¶ÔAXÖеÄÎÞ·ûºÅÊý³ËÒÔ5£¬¿¼Âdz˻ý¿ÉÄܳ¬³ö16λµÄÇé¿ö¡£
Ìáʾ£ºÓÃDX½ÓAX×óÒƵÄ룬32λ²Ù×÷¡£
3.20 °ÑAXÖеÄÄÚÈÝÒÀ´Îµ¹ÅÅÐò£¬¼´µÚ0λÒƵ½µÚ15룬µÚ1λÒƵ½µÚ14룬¡¡£
3.21 ÔÚÊý¾Ý¶ÎÓÐÈç϶¨Ò壺
BUFF DB ¡®ABCD$EFGHIJK$¡¯
STR1 DB 12 DUP(?) LEN DB £¿
Óô®Ö¸Áî±àд³ÌÐòÍê³ÉÒÔϲÙ×÷£º (1) ¶Ô×Ö·û´®STR1È«²¿Öÿոñ·û¡£ MOV AX£¬DATA
MOV DS£¬AX MOV AL£¬20H LEA DI£¬STR1
MOV CX£¬STR1-BUFF CLD
REP STOSB
(2) ´Ó×óµ½ÓÒ°ÑBUFFÖеÄ×Ö·û´®´«Ë͵½STR1¡£ MOV AX£¬DATA MOV DS£¬AX MOV ES£¬AX CLD
LEA SI£¬BUFF LEA DI£¬STR1
MOV CX£¬STR1-BUFF REP MOVSB
(3) ´ÓÓÒµ½×ó°ÑBUFFÖеÄ×Ö·û´®´«Ë͵½STR1¡£ MOV AX£¬DATA MOV DS£¬AX MOV ES£¬AX STD
LEA SI£¬STR1-1 LEA DI£¬LEN-1 MOV CX£¬STR1-BUFF REP MOVSB
(4) ±È½ÏBUFFÓëSTR1Á½¸ö×Ö·û´®ÊÇ·ñÏàµÈ£¬ÈçÏàµÈÔòDX=1£¬·ñÔòDX=0¡£ MOV AX£¬DATA MOV DS£¬AX MOV ES£¬AX CLD
LEA SI£¬BUFF LEA DI£¬STR1
MOV CX£¬STR1-BUFF REPE CMPSB
(5) ²éÕÒBUFFÖÐÓÐÎÞ×Ö·û$£¬°Ñ×Ö·û$³öÏֵĴÎÊý¼ÆÈëBX¼Ä´æÆ÷¡£ MOV AX£¬DATA MOV ES£¬AX MOV BX£¬0 CLD
MOV AL£¬¡®$¡¯ LEA SI£¬BUFF
MOV CX£¬STR1-BUFF NEXT: REPNE SCASB
JCXZ NO-FOUND INC BX JMP NEXT
3.22 ¶ÔÓÚ¸ø¶¨µÄAXºÍBXµÄÖµ£¬Ö´ÐÐÏÂÁгÌÐò¶Î£¬³ÌÐò½«×ªÏòÄÄÀ
ADD AX, BX
JNO L1
JNC L2 SUB AX£¬BX JNC L3 JNO L4 JMP L5
(1) AX=1234H£¬ BX=6789H (2) AX=9200H£¬ BX=4000H (3) AX=420EH£¬ BX=8031H (4) AX=E002H£¬ BX=8086H L1£¬L1£¬L1£¬L5
3.23 ÏÂÃæ²»ÍêÕûµÄ³ÌÐò¶ÎÊDZȽÏAXºÍBXµÄÖµ£¬°ÑÆäÖдóµÄÊýËÍMAX±äÁ¿¡£Èç¹ûÊÇÎÞ·ûºÅÊý£¬Ó¦ÈçºÎÌîдָÁÈç¹ûÊÇÓзûºÅÊý£¬Ó¦ÈçºÎÌîдָÁ
CMP AX£¬BX
( JB L1 ) ÓзûºÅÊý:JL L1 MOV MAX£¬AX
( JMP L2 ) L1£ºMOV MAX£¬BX L2£ºHLT
3.24 ÔÚÏÂÁгÌÐò¶ÎµÄÀ¨ºÅÖзֱðÌîÈëÈçÏÂÖ¸Á³ÌÐòÖ´ÐÐÍêºó£¬AX¡¢CXµÄÄÚÈÝÊÇʲô£¿
(1) LOOP (2) LOOPE (3) LOOPNZ MOV AX, 8
MOV CX£¬5 L1£ºSHL AX£¬CL
( )
Ìáʾ£ºÉÏ»ú£¬SHLÖ¸ÁîʹZF=0£¬LOOPEÖ¸Áî²»¿ÉÄÜÑ»·¡£
3.25 ²âÊÔAL¼Ä´æÆ÷£¬Èç¹û×î¸ßλºÍ×îµÍλͬʱΪ0£¬ÔòתL0£¬Èç¹û×î¸ßλºÍ×îµÍλֻÓÐһλΪ1£¬ÔòתL1£¬Èç¹û×î¸ßλºÍ×îµÍλͬʱΪ1£¬ÔòתL2¡£»³öÁ÷³Ìͼ£¬²¢±àд³ÌÐò¶Î¡£
ROL AL,1 AND AL,3 JZ L0 SUB AL,3 JZ L3 JMP L2