1. Trang chủ
  2. » Công Nghệ Thông Tin

Thiết kế và lập trình hệ thống - Chương 24

13 290 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 13
Dung lượng 305,6 KB

Nội dung

Thiết kế và lập trình hệ thống - Chương

 ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑1✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳ArithmeticOperations:•Addition•Subtraction•Multiplication•Division•Comparison•Negation•Increment•DecrementLogicOperations:•AND•OR•XOR•NOT•shift•rotate•compare(TEST)  ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑2✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳Addition,Increment,Add-with-carryandExchange-and-add(80486):Contentsoftherightmost8bitsoftheFLAGSregistercanchange(+Overflow)forarithmeticandlogicinstructions.Flagsinclude:•Z(resultzero?)•C(carryout?)•A(halfcarryout?)•S(resultpositive?)•P(resulthasevenparity?)•O(overflowoccurred?) ✁✁AL✂✄☎✆✆☎✝✞✟✠✡☛☎☞☞✍✌✎✏✍✑✒✓✔✕✖✗✘✚✙✖✙✖✛✜✖✢✏✌✖✗✣✤✥✦✝✧★✩✧✆✄EDI]☛☎☞☞✍✌✕✖✗✪✌✏✖✕✌✞✫✒✕✕✔✬✭✒✗✯✮ ✁✥ECX✂EBX☛★✫✰✱★✫✰✞★✦✰✂★✦✰✱✑✕✪✗✪✓✒✭★✫✰✮✲ ✁✁ECX✂EBX☛✳✌✖☞✬✑✕✒☞☞✪✓✗✴ ✵✶✪✏✓✷✙✌✮  ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑3✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳Subtraction,DecrementandSubtract-with-borrow:Comparison:Changesonlytheflagbits.Oftenfollowedwithaconditionalbranch: ✁✂EAX✂EBX✁✄✥EDI☛✟✷✶✌✕✖✗✪✌✏✖✕✌☎✫✒✕✕✔✬✭✒✗✯✮ ✂✂ECX✂EBX;EAX=EAX-EBX✥✆✝AL✂✎✞✟✠ ✄LABEL1☛✡✷✙✢✪✬✖☛✷✒✭✑✕✶✍✖✭✑☞✮✠✂✄LABEL2☛✪✬✫✰✱✱☎✰✂☎✰✱✌✰✖✭✌✖☎✰✱✫✰✥✆✝✲✥✍✎CX✂DX☛✡✷✙✢✪✬✖☛✷✒✭✑✕✒✶✑✏✖✮  ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑4✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳MultiplicationandDivision:IMUL/IDIV:Signedintegermultiplication/division.MUL/DIV:Unsigned.ALalwaysholdsthemultiplicand(orAXorEAX).ResultisplacedinAX(orDXandAXorEDXorEAX).CandObitsareclearedifmostsignificant8bitsofthe16-bitproductarezero(resultofan8-bitmultiplicationisan8-bitresult).Divisionbyzeroandoverflowgenerateerrors.Overflowoccurswhenasmallnumberdividesalargedividend.✆✁ BL✣✆✁ BX☛✟✢✖✜✪✒✭✂✫✰✱✌✰✁✎✂✟✄✌✪✗✓✖☞✑✓✭✔☎✣✆✁ CX✂✆✝✞✟✠✡;EDX|EAX=EAX*ECX✆✁ ECX☛☎✰✱☎☛✁✦☛✄✷✓✌✪✗✓✖☞☎☛✌✰☞☎✰✱☎✰✁✦✰✄✌✪✗✓✖☞☎✁✣✌CL;DX|AX=(DX|AX)/CX✣✁✣✌CX☛☎✟☞☎☛✱☎✰✘✫☛✂✷✓✌✪✗✓✖☞☛✷✑✏✪✖✓✏☛✪✓☎☛✂✕✖✙✒✪✓☞✖✕✪✓☎✟  ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑5✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳LogicInstructions:Allowbitstobeset,clearedandcomplemented.CommonlyusedtocontrolI/Odevices.Logicoperationsalwaysclearthecarryandoverflowflags.•AND:0ANDanythingis0.CommonlyusedwithaMASKtoclearbits:•OR:1ORanythingis1.CommonlyusedwithaMASKtosetbits:✲✲✲✲✲✲✲✲ ✢✖✕✒✓☞✁✁✁✁✂✂✂✂✄✒✌☎✁✁✁✁✲✲✲✲✆✖✌✷✭✏AND AL✂BL☛☎☛✱☎☛☎✆✌✦☛✲✲✲✲✲✲✲✲ ✢✖✕✒✓☞✁✁✁✁✂✂✂✂✄✒✌☎✲✲✲✲✂✂✂✂✆✖✌✷✭✏OR EAX✂10☛★☎✰✱★☎✰ ✆✞✞✞✞✞✞✞☎✟  ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑6✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳LogicInstructions:•XOR:Truthtable:0110.CommonlyusedwithaMASKtocomplementbits:•TEST:OperatesliketheANDbutdoesn’teffectthedestination.SetstheZflagtothecomplementofthebitbeingtested:Additionaloperationsavailablein80386andup.•BT:Testthebitintheleftoperandspecifiedbytherightoperand.•BTC:Testsandcomplements .•BTR:Testsandclears .•BTS:Testsandsets .PutsbitundertestinCflag.Latterthreechangethebitafterwards.✲✲✲✲✲✲✲✲ ✢✖✕✒✓☞✁✁✁✁✂✂✂✂✄✒✌☎✲✲✲✲✲✲✲✲✆✖✌✷✭✏XOR AH✂CH☛☎✟✱☎✟✰ ✆✫✟ ✄  AL, 4JZ☛☎✦★☛☛✡✷✙✢✏✍✑☛☎✦★☛✪✬✶✪✏✂✪✌✁✖✕✑✮☛✧✖✌✏✌✶✪✏✂✪✓☎☛☎☎✞✞✞✞✞✎✞✞  ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑7✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳LogicInstructions:NOT(logicalone’scomplement)NEG(arithmetictwo’scomplement-signofnumberinverted)Shift:CommonlyusedforcontrolofI/Odevices.Alsousedformultiplicationanddivisionbypowersof2.•Logicalshiftsinsert0,usedwithunsignednumbers•Arithmeticrightshiftsinsertsignbit.Doublepercisionshifts(80386andup):✤  EBXNEG✧★✄✩SHL AX✂✎SAR✟✠✂✫☛☛☎✰✪✌✭✑✗✪✜✒✭✭✔✌✁✪✬✏✖☞✭✖✬✏✎✶✪✏✢✑✌✮☛✟✠✪✌✒✕✪✏✁✙✖✏✪✜✒✭✭✔✌✁✪✬✏✖☞✕✪✗✁✏SHDR AX✂BX✂✎✂☛☎✰✌✁✪✬✏✖☞✕✪✗✁✏✶✔✎✂✒✓☞✬✪✭✭✖☞✬✕✑✙☛✏✁✖✭✖✬✏☞✪✏✁✏✁✖✕✪✗✁✏✎✂✶✪✏✌✑✬✦✰✮SHDL AX✂BX✂✎✵  ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑8✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳Rotate:Rotatesbitsfromoneendtotheotherorthroughthecarryflag.Commonlyusedtooperateonnumberswiderthan32-bits:BitScanInstruction(80386andup):Scanthroughanoperandsearchingfora1bit.Zeroflagissetifa1bitisfound,positionofbitissavedindestinationregister.ROL SI✂✎✵RCR BL✂CL☛✟✠✕✑✏✒✏✖☞✭✖✬✏✶✔✎✵✢✭✒✜✖✌✮☛✦☛✕✑✏✒✏✖☞✕✪✗✁✏✫☛✢✭✒✜✖✌✏✁✕✑✷✗✁✜✒✕✕✔✮SHL AX✂✎☛ ✕✪✗✪✓✒✭✵ ☎✶✪✏✓✷✙✶✍✖✕✪✓✌✰✂✦✰✒✓☞☎✰✮☛✟✁✪✬✏☎✰✭✖✬✏✎✶✪✓✒✕✔✢✭✒✜✖✮RCL BX✂✎☛✆✑✏✒✏✖✜✒✕✕✔✶✪✏✬✕✑✙✢✕✖✏✪✑✷✌✟✟☛✪✓✏✑☛✭✑☞✑✕☞✖✕✶✪✏✑✬✦✰✮RCL DX✂✎☛✆✑✏✒✏✖✜✒✕✕✔✶✪✏✬✕✑✙✢✕✖✏✪✑✷✌✆✫☛✪✓✌✰✮BSL EBX✂EAXBSR BL✂CL☛★☎✰✌✜✒✓✓✖☞✬✕✑✙✏✁✖✭✖✬✏✮☛✫☛✌✜✒✓✓✖☞✬✕✑✙✏✁✖✕✪✗✁✏✮  ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑9✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳StringScanInstructions:SCASB/W/DcomparestheAL/AX/EAXregisterwithabyteblockofmemoryandsetstheflags.OftenusedwithREPEandREPNECMPSB/W/Dcompares2sectionsofmemorydata.ProgramControlInstructions:•ConditionalandUnconditionalJumps•Calls•Returns•InterruptsUnconditionalJumps:•Shortjump:PC-relativeusingtwobytes(+127/-128bytes).ShortjumpsarePC-relative(OffsetaddedtoIP:relocatable).JMP✆★✰✧☛ ✬✬✌✖✏☞✖✏✖✕✙✪✓✖✌✖✓✜✑☞✪✓✗✯✮✆★✰✧ ADD☎✰✂✦✰☛✁ ✁✪✌✕✖☛✷✪✕✖☞✒✬✏✖✕✏✁✖✭✒✶✍✖✭✂  ✂✁✄☎ ✆✝✄✞✠✟✡☛✟☞✝✝✌✎✍☛✏✑✒✏✓✔✄✄✆✝✕✖✁✗✘✙ ✚✞✛✜✢✑10✣✔✎✤✟✌✖✥✜✧✦✥✑✑✢✏✎★✑✥✤✝✩UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳UnconditionalJumps:•Nearjump:PC-relativeusingthreebytes(+/-32K).Sincesegmentsarecyclic,wraparoundallowsanylocationtobereachedwithinthe64Ksegment.Inprotectedmode,nearjumpsrangesare+/-2G.•Farjump:Directjumpusingfivebytes(addressininstr.stream).Twobytesgivetheoffsetandtwobytesgiveanewsegmentaddress.Protectedmode:Thesegmentvaluereferstoadescriptor.(Note:Thelinkerneedstofillinthevaluesinthiscasewhenthepro-gramfilesarecombined.)•IndirectJumps:(EIPvalueinreg/mem,notintheinstructionstream).Usesa16-or32-bitregisterasanoperand.JMP☎✰☛✡✷✙✢✏✍✑✒☞☞✕✖✌✌✗✪✏✖✓✶✔☎✰✮ [...]...  ¦ ¡ !"      Conditional Jumps: Either short or near jumps on the 80386 and up (only short, otherwise) Test flag bits S, Z, C, P and O For unsigned numbers: %& 8 D ) D  5  £ M £¤ Usually a 16-bit offset is used and CS is left alone Using a FAR PTR directive loads both CS and IP §' ¤ ¥¤ AB ¨ E D JMP  A Unconditional Jumps: • Indirect Jumps (register indirect address mode): ¤ 2 ¡¢  8 7 . BALTIMORE COUNTY1 9 6 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳Addition,Increment,Add-with-carryandExchange-and-add(80486):Contentsoftherightmost8bitsoftheFLAGSregistercanchange(+Overflow)forarithmeticandlogicinstructions.Flagsinclude:•Z(resultzero?)•C(carryout?)•A(halfcarryout?)•S(resultpositive?)•P(resulthasevenparity?)•O(overflowoccurred?) ✁✁AL✂✄☎✆✆☎✝✞✟✠✡☛☎☞☞✍✌✎✏✍✑✒✓✔✕✖✗✘✚✙✖✙✖✛✜✖✢✏✌✖✗✣✤✥✦✝✧★✩✧✆✄EDI]☛☎☞☞✍✌✕✖✗✪✌✏✖✕✌✞✫✒✕✕✔✬✭✒✗✯✮ ✁✥ECX✂EBX☛★✫✰✱★✫✰✞★✦✰✂★✦✰✱✑✕✪✗✪✓✒✭★✫✰✮✲ ✁✁ECX✂EBX☛✳✌✖☞✬✑✕✒☞☞✪✓✗✴. 6✪✎✫✬✠✭✮✯✰✰✭✱✲✮✎✳MultiplicationandDivision:IMUL/IDIV:Signedintegermultiplication/division.MUL/DIV:Unsigned.ALalwaysholdsthemultiplicand(orAXorEAX).ResultisplacedinAX(orDXandAXorEDXorEAX).CandObitsareclearedifmostsignificant8bitsofthe16-bitproductarezero(resultofan8-bitmultiplicationisan8-bitresult).Divisionbyzeroandoverflowgenerateerrors.Overflowoccurswhenasmallnumberdividesalargedividend.✆✁ BL✣✆✁ BX☛✟✢✖✜✪✒✭✂✫✰✱✌✰✁✎✂✟✄✌✪✗✓✖☞✑✓✭✔☎✣✆✁ CX✂✆✝✞✟✠✡;EDX|EAX=EAX*ECX✆✁ ECX☛☎✰✱☎☛✁✦☛✄✷✓✌✪✗✓✖☞☎☛✌✰☞☎✰✱☎✰✁✦✰✄✌✪✗✓✖☞☎✁✣✌CL;DX|AX=(DX|AX)/CX✣✁✣✌CX☛☎✟☞☎☛✱☎✰✘✫☛✂✷✓✌✪✗✓✖☞☛✷✑✏✪✖✓✏☛✪✓☎☛✂✕✖✙✒✪✓☞✖✕✪✓☎✟  ✂✁✄☎

Ngày đăng: 15/11/2012, 11:07

w