Week1Supposeadatais376a8d43hinHexadecimal,howtoplaceitfromtheaddressthat20000hbylittleendianandbigendian?答:小端存储(littleendian)20000H到20003H地址分别存放的是43H,8DH,6AH和37H大端存储(bigendian)20000H到20003H地址分别存放的是37H,6AH,8DH和43HConvertthefollowdecimalintegerintoBCDandpackedBCDnumber.a)9b)76c)251答:BCD码:a)09Hb)0706Hc)020501H或a)00001001b)0000011100000110c)000000100000010100000001packedBCD:a)09Hb)76Hc)0251H或a)00001001b)01110110c)0000001001010001ConvertthefollowpackedBCDnumberintodecimalnumber:a)10001001b)00001001c)00110010d)00000001答:a)89b)9c)32d)1Convertthefollowbinarynumberintosigneddecimalnumber:a)10000001b)00110011c)10010010d)10001001答:a)-127b)51c)-110d)-119Week2Howmany8-bit,16-bitand32bitgeneral-purposeregistersarethereintheIA-32CPU?Whatarethem?RightAnsweris:8位通用寄存器有AL,AH,BL,BH,CL,CH,DL,DH共8个16位通用寄存器有AX,BX,CX,DX,SI,DI,BP,SP共8个32位通用寄存器有EAX,EBX,ECX,EDX,ESI,EDI,EBP,ESP共8个Intherealmode,findthememoryaddressofthenextinstructionexecutedbythemicroprocessorforthefollowingCS:IPcombinations:a)CS=1000HandIP=2000Hb)CS=1900HandIP=0200Hc)CS=1900HandIP=1000HD)CS=5679HandIP=CDEFHPleasegivethephysicalmemoryaddress.RightAnsweris:Physicalmemoryaddressis:a)12000Hb)19200Hc)1A000Hd)6357FHWillanoverflowoccurwhensignedFFHisaddedtoasigned01H?Howaboutsigned70Haddasinged40H?RightAnsweris:FFH+1,OF=0,不产生溢出70H+40H会产生溢出,OF=1Week3Supposethat(DS)=2000H,(ES)=2100H,(SS)=1500H,(SI)=00A0H,(BX)=0100H,(BP)=0010H,theoffsetaddressofVALis0050H。Determinethephysicaladdressaccessedbyeachofthefollowinginstructions,assumingrealmodeoperation.(1)MOVAX,[100H](2)MOVVAL,BH(3)MOVAX,[BX](4)MOVAX,ES:[BX](5)MOVAX,[BP](6)MOVAX,[SI](7)MOVAX,[BX+50H](8)MOVVAL[BX],BP(9)MOVAH,[BX+SI](10)MOVAL,VAL[BX][SI]RightAnsweris:(1)20100H(2)20050H(3)20100H(4)21100H(5)15010H(6)200A0H(7)20150H(8)20150H(9)201A0H(10)201F0HWritethedirectivetodefinethefollowingvariable:1)Declareanwordarraynamedbuffwhichhas800elementswithoutinitial.2)DeclareastringnamedSTRINGwithinitialvalue“MASM”,”1024”RightAnsweris:buffword800dup(?)或buffdw800dup(?)STRINGbyte“MASM”,“1024”或STRINGdb“MASM”,“1024”What’sdifferentbetweentheEQUoperatorand=operator?RightAnsweris:EQU定义的常量不能再赋值,=定义的可以再次定义Week4Whatisthepurposeofthe.386,.486p,.modeldirective?RightAnsweris:.386表示该程序使用386指令.486p表示该程序使用486保护模式指令What’swrongwiththefollowinginstructions:(l)MOVAH,BX(2)MOV[BX],[SI](3)MOVAX,[SI][DI](4)MOVMYDAT[BX][SI],ES:AX(5)MOVBL,1000(6)MOV2000,BX(7)MOVCS,AXRightAnsweris:1)目的操作数与源操作数不等宽2)两个操作数不能都是存储器操作数3)不能两个都是变址寄存器4)寄存器不能用段超越5)1000超出8位数范围6)立即数不能做目的操作数7)CS不能作为MOV的目的操作数Writeashortsequenceofinstructionsthatloadthedatasegmentregisterwith1000HRightAnsweris:MOVAX,1000HMOBDS,AXWhatisthedifferencebetweentheLEASI,NUMBinstructionandtheMOVSI,OFFSETNUMBinstruction?RightAnsweris:LEA指令的源操作数可以是任意寻址方式的存储器操作数,OFFSET形式的语句只能是变量名或标号名。OFFSET形式是立即数寻址,速度快。Supposethedatadeclaredasfollow:ORG26HNUM1BYTE12H,13HNUM2WORD$+3ORG$+4NUM3WORD325AH,5A6BHQuestion:Howdothedatastoreinmemory?Pleasedrawthememorymap.RightAnsweris:按存储地址顺序从低到高,各字节分别是:12H,13H,2BH,00,-,-,-,-,5AH,32H,6BH,5AH,Supposethedatadeclaredasfollow:ORG100HNUM1DB7,43H,‘AB’NUM2DW1,?NUM3DB2DUP(1,2DUP(5))Question:Howdothedatastoreinmemory?Pleasedrawthememorymap.RightAnsweris:按存储地址顺序从低到高,各字节分别是:7,43H,’A’,’B’,1,0,-,-,1,5,5,1,5,5Week5IfAX=1001HandDX=20FFH,listthesumandthecontentsofeachflagregisterbit(CF,AF,SF,ZFandOF).RightAnsweris:SUM=3100H,CF=0,AF=1,OF=0,SF=0,ZF=0ExplainthedifferencebetweentheSUBandCMP,ANDandTEST.RightAnsweris:CMP和SUB做同样操作,但不保存结果;TEST和AND做同样操作,但不保存结果Programmingin16-bitassemblylanguage1)AddthedatainAL,BLandCL,lettheresultintheDX2)AddthedatainALandaBYTEdatainmemorywhichsymboladdressisNUMusingBase-Plus-Indexaddressing.TheresultinthenextaddressofNUM.RightAnsweris:1)MOVDX,0ADDDL,ALADCDH,0ADDDL,BLADCDH,0ADDDL,CLADCDH,02)MOVBX,OFFSETNUM(或LEABX,NUM)MOVSI,0ADDAL,[BX][SI]INCSIMOV[BX][SI],ALWeek6HowmanywayyouknowtocleartheAXwith0?Pleasegivetheway.RightAnsweris:1)MOVAX,02)ANDAX,03)SUBAX,AX4)XORAX,AX5)MOVBL,0MULBLProgrammingin16-bitassemblylanguage1)UseshiftinstructiontocalculateDX=3×AX+7×BX,supposethedataareassignedandnocarry.2)UselogicinstructiontoimplementtheconversionfromASCIIof0~9tounpackedBCD,andfromunpackedBCDtoASCII.3)ImplementDX.AXshiftright4bits.RightAnsweris:1)MOVCX,AXSHLAX,1;AX*2ADDAX,CX;AX*3MOVDX,BXMOVCL,3SHLDX,CL;BX*8SUBDX,BX;BX*7ADDDX,AX2)MOVAL,’0’LOP:ANDAL,0FHINCALCMPAL,0AHJNELOPMOVAL,0LOP1:ORAL,30HINCALCMPAL,‘:’JNELOP13)MOVCL,4SHRAX,CLMOVBL,DLSHRDX,CLSHLBL,CLORAH,BLSupposeDS=2000H.BX=1256H,SI=528FH,displacementTABLE=20A1H,[232F7H]=3280H,[264E5H]=2450H,afterrunfollownearindirectjumpinstructions,IP=?i.JMPBXii.JMPTABLE[BX]iii.JMP[BX][SI]RightAnsweris:i.1256Hii.3280Hiii.2450HDeterminethejumpconditionsofthefollowingprogram.(1)XORAX,1E1EHJEEQUAL(2)TESTAL,10000001BJNZTHERE(3)CMPCX,64HJBTHERERightAnsweris:(1)AX=1E1EH(2)AL的最高位和/或最低位为1(3)(CX)64HIfthetargetaddressinshortjumpbeyondrangeof-128~127,howtohandle?Giveanexample.RightAnsweris:可以把跳转条件做一些调整,利用无条件跳转的跳转范围大,来达到目的,如:CMPAX,33JELONG……;大于127字节LONG:改为:CMPAX,33JNESHOETJMPLONGSHORT:……;大于127字节……LONG:WhatisA10andA20inthefollowshortjumpinstruction?(inhexadecimal)(1)0110HEB