0% found this document useful (0 votes)
3K views

Program Control Instructions

The document discusses different types of program control instructions used in microprocessors, including unconditional jump instructions like short jumps, near jumps, and far jumps. It also discusses conditional jump instructions that test flag bits and loop instructions like LOOP that decrement a counter and conditionally jump. Program control instructions allow programs to change flow by skipping sections, branching to different parts of memory, and making decisions based on tests.

Uploaded by

MANIKANDAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views

Program Control Instructions

The document discusses different types of program control instructions used in microprocessors, including unconditional jump instructions like short jumps, near jumps, and far jumps. It also discusses conditional jump instructions that test flag bits and loop instructions like LOOP that decrement a counter and conditionally jump. Program control instructions allow programs to change flow by skipping sections, branching to different parts of memory, and making decisions based on tests.

Uploaded by

MANIKANDAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

7/7/2015

ProgramControlInstructions

ProgrammeControlInstructions
INTRODUCTION
Theprogrammecontrolinstructionsdirecttheflowofaprogrammeandallowtheflowofthe
programmetochange.Achangeinflowoftenoccurswhendecisions,madewiththeCMPor
TESTinstruction,arefollowedbyaconditionaljumpinstruction.
THEJUMPGROUP
Themaintypeofprogrammecontrolinstruction,thejump(JMP),allowstheprogrammemerto
skipsectionsofaprogrammeandbranchtoanypartofthememoryforthenextinstruction.A
conditionaljumpinstructionallowstheprogrammemertomakedecisionsbaseduponnumerical
tests.Theresultsofthesenumericaltestsareheldintheflagbits,whicharethentestedby
conditionaljumpinstructions.

UnconditionalJump
Threetypesofunconditionaljumpinstructionsareavailableinthemicroprocessor'sinstruction
set:shortjump,nearjump,andfarjump.
Theshortjumpisa2byteinstructionthatallowsjumpsorbranchestomemorylocationswithin
+127and128bytesfromthememorylocationfollowingthejump.The3bytenearjumpallows
abranchorjumpwithin32Kbytes(anywhere)fromtheinstructioninthecurrentcode
segment.Finally,the5bytefarjumpallowsajumptoanymemorylocationwithintheentire
memorysystem.Theshortandnearjumpsareoftencalledintrasegmentjumpsandthefar
jumpsareoftencalledintersegmentjumps.

ShortJump.Shortjumpsarecalledrelativejumpsbecausetheycanbemovedanywherein
currentcodesegmentwithoutachange.Thisisbecauseajumpaddressisnotstoredwiththe
opcode.Insteadofajumpaddress,adistance,ordisplacement,followstheopcode.Theshort
jumpdisplacementisadistancerepresentedbya1bytesignednumberwhosevalueranges
between+127and128.
OPCODE(EB)

Displacement
(+127to128)

Whenthemicroprocessorexecutesashortjump,thedisplacementsignextendsandaddsto
theinstructionpointer(IP)togeneratethejumpaddresswithinthecurrentcodesegment.The
shortjumpinstructionbranchestothisnewaddressforthenextinstructioninthe
programmeme.
http://www.electronics.dit.ie/staff/tscarff/program_control/program_control.htm

1/3

7/7/2015

ProgramControlInstructions

Wheneverajumpinstructionreferencesanaddress,alabelidentifiestheaddress.TheJMP
NEXTisanexample,whichjumpstolabelNEXTforthenextinstruction.Weneverusean
actualhexadecimaladdresswithanyjumpinstruction.ThelabelNEXTmustbefollowedbya
colon(NEXT:)toallowaninstructiontoreferenceitforajump.Ifacolondoesnotfollowa
label,youcannotjumptoit.Notethattheonlytimeweeveruseacolonafteralabeliswhen
thelabelisusedwithajumporcallinstruction.

NearJump.Thenearjumpissimilartotheshortjumpexceptthedistanceisfarther.Anear
jumppassescontroltoaninstructioninthecurrentcodesegmentlocatedwithin32Kbytes
fromthenearjumpinstruction.Thenearjumpisa3byteinstructionthatcontainsanopcode
followedbyasigned16bitdisplacement.Thesigneddisplacementaddstotheinstruction
pointer(IP)togeneratethejumpaddress.Becausethesigneddisplacementisintherangeof
32K,anearjumpcanjumptoanymemorylocationwithinthecurrentrealmodecode
segment.
OPCODE(E9)

DISPLACEMENT

DISPLACEMENT

LowByte

HighByte

FarJump.Thefarjumpobtainsanewsegmentandoffsetaddresstoaccomplishthejump.
Bytes2and3ofthis5byteinstructioncontainthenewoffsetaddressandbytes4and5
containthenewsegmentaddress,withtheLowBytefollowedbytheHighByteinbothcases.
OPCODE(EA)

IP

IP

CS

CS

LowByte

HighByte

LowByte

HighByte

ConditionalJumps
Conditionaljumpsarealwaysshortjumpsinthe8086microprocessor.Thislimitstherangeof
thejumptowithin+127bytesand128bytesfromthelocationfollowingtheconditionaljump.
Theconditionaljumpinstructionstestthefollowingflagbits:sign(S),zero(Z),carry(C),parity
(P),andoverflow(0).Iftheconditionundertestistrueabranchtothelabelassociatedwiththe
jumpinstructionoccurs.Iftheconditionisfalse,thenextsequentialstepintheprogramme
executes.
Theoperationofmostconditionaljumpinstructionsisstraightforwardbecausetheyoftentest
justoneflagbit,butsometestmorethanoneflag.Relativemagnitudecomparisonsrequire
morecomplicatedconditionaljumpinstructionsthattestmorethanoneflagbit.
Becauseweusebothsignedandunsignednumbers,andtheorderofthesenumbersis
http://www.electronics.dit.ie/staff/tscarff/program_control/program_control.htm

2/3

7/7/2015

ProgramControlInstructions

different,therearetwosetsofmagnitudecomparisonconditionaljumpinstructions,bothsigned
andunsigned8bitnumbers.
The16and32bitnumbersfollowthesameorderasthe8bitnumbersexcepttheyarelarger.
NoticethatanFFHisabovethe00Hinthesetofunsignednumbers,butanFFH(1)isless
than00Hforsignednumbers.Therefore,anunsignedFFHisabove00H,butasignedFFHis
lessthan00H.
Whenwecomparesignednumbers,weuseJG,JE,JGE,JLE,JE,andJNE.Thetermsgreater
thanandlessthanrefertosignednumbers.Whenwecompareunsignednumbers,weuseJA,
JB,JAE,JBE,JE,andJNE.Thetermsaboveandbelowrefertounsignednumbers.
Theremainingconditionaljumpstestindividualflagbitssuchasoverflowandparity.Noticethat
JEhasanalternativeopcodeJZ.Allinstructionshavealternateopcodes.

LOOP
TheLOOPinstructionisacombinationofadecrementofCXandaconditionaljump.Inthe
8086,LOOPdecrementsCXandifCXisnotequaltozero,itjumpstotheaddressindicatedby
thelabel.IfCXbecomesa0,thenextsequentialinstructionexecutes.
ConditionalLOOPS.TheLOOPinstructionalsohasconditionalLOOPEandLOOPNE.The
LOOPE(loopwhileequal)instructionjumpsifCXisnotequaltozero,whileanequalcondition
exists.ItwillexittheloopiftheconditionisnotequaloriftheCXregisterdecrementsto0.The
LOOPNE(loopwhilenotequal)instructionjumpsifCXisnotequaltozero,whileanotequal
conditionexists.ItwillexittheloopiftheconditionisequaloriftheCXregisterdecrementsto
0.Aswiththeconditionalrepeatinstructions,alternatesexistforLOOPEandLOOPNE.

http://www.electronics.dit.ie/staff/tscarff/program_control/program_control.htm

3/3

You might also like