Académique Documents
Professionnel Documents
Culture Documents
Outline
8085
Blockdiagram(DataPath) InstructionSetof8085
Sampleprogramof8085 Counter & Time elay Counter&TimeDelay StackandSubRoutine Assignmenton8085 Assignment on 8085 Introductionto8086and30x86architecture
8085MicroprocessorArchitecture
INTR INTA ReSeT6.5 RST5.5 RST7.5 TRAP SID SOD
SerialI/OControl
MUX IR W B D H SP PC Z C E L
ALU
TimingandControl
Inc/Dec.ter I /D t Addlatch
A15 A0
AddressBus(16bit)
I/P O/P
D7 D0
DataBus(8bit) ControlBus(8bit)
Assumption
RAM Memory is interfaced RAMMemoryisinterfaced Instructionsarestoredinmemory O OneI/Odisplayportisinterfacedtodisplay /O di l i i f d di l dataofACC
F R MVIC,FFH7TState MVI C FFH 7 T State F LOOP:DCRC4TState JNZLOOP7/10TState JNZ LOOP 7/10 T State F R R
PerformanceofotherINS F ADDR4TState ADD R 4T S F R ADDM7TState S R R W W 18TState CALLaddr F=Fetchwith4State,S=Fetchwith6State, R=MemoryRead,W=MemoryWrite
Timedelayinloop
TL=TxLoopTStatesxN10 whereT=Systemclockperiod N10=Equiv.decimalvalueofcountloadedtoC ( ) (g ) TL=0.5x106 x(14x255)=1.8ms(ignore10TState)
TrafficLightControl:Counter&Delay
TurnSignaltoRed LoadDelayRed y TimeDelay TurnSignaltoYellow LoadDelayYellow TimeDelay TurnSignaltoGreen T Si lt G LoadDelayGreen TimeDelay
LOOP: MVIA01H OUT01H LDBDELAY_RED LD B DELAY RED CALLDELAY MVIA02H OUT01H LDBDELAY_YELLOW CALLDELAY MVI A 03H MVIA03H OUT01H LDBDELAY_GREEN CALLDELAY CALL DELAY JMPLOOP
StackPointer(SP)&StackMemory ( ) y
Thestackisanareaofmemoryidentifiedby theprogrammerfortemporarystorageof the programmer for temporary storage of information. The stack is a LIFO structure ThestackisaLIFOstructure. Thestacknormallygrowsbackwardsinto Memory memory. memory
Programmercandefinesthe bottomofthestack(SP) bottom of the stack (SP) andthestackgrowsupinto reducingaddressrange.
C
F3
FFFB FFFC FFFD FFFE FFFF
ExamplePOPB
Copy0(SP)toC,IncrementSP ( ) Copy0(SP)toB,IncrementSP
F3 12
SP
Stack/LIFOuseinCALL/RET
Retrieveinformationbackintoitsoriginal location
TheorderofPUSHsandPOPsmustbeopposite
8085recognizesoneadditionalregisterpair g g p
PSW(ProgStatusword)=ACCandFlag
BeforeanyroutineCALLdothis PUSH B PUSH D PUSH PSW AfterRETURNfromcalldothis POP PSW POP D POP B
Subroutines
A subroutine is a group of instructions
That is used repeatedly in different places of the program. Rather than repeat the same instructions several times It can be grouped into a subroutine and call from the different locations.
Instructionsfordealingwithsubroutines.
TheCALLinstructionisusedtoredirectprogram p g executiontothesubroutine. TheRETinstructionisusedtoreturntheexecutionto thecallingroutine. h ll
CALL/RETInstruction
YoumustsettheSPcorrectlybeforeusingCALL CALL 5000H CALL5000H
PushthePCvalueontothestack L d PC ith 16 bit dd LoadPCwith16bitaddresssuppliedCALLins. li d CALL i
RET:LoadPCwithstacktop;POPPC
PC
2000 CALL 5000 CALL5000 2003 2003
FFFB FFFC FFFD FFFE FFFF
17
03 20
SP
18
Stack/LIFOuseinCALL/RET
Retrieveinformationbackintoitsoriginal location
TheorderofPUSHsandPOPsmustbeopposite
8085recognizesoneadditionalregisterpair g g p
PSW(ProgStatusword)=ACCandFlag
BeforeanyroutineCALLdothis PUSH B PUSH D PUSH PSW AfterRETURNfromcalldothis POP PWD POP D POP B
Factorialofanumber
LXISP,27FFH//Initializestackpointer LDA2200H//Getthenumber CPI02H//Checkifnumberisgreaterthan1 CPI 02H // Ch k if b i t th 1 JCLAST MVID,00H//Loadnumberasaresult MOVE,A DCRA MOVC,A//Loadcounteronelessthannumber , // CALLFACTO//CallsubroutineFACTO XCHG//GettheresultinHL//HLwithDE SHLD2201H//Storeresult//storeHLat0(16bit) SHLD 2201H // Store result // store HL at 0(16bit) JMPEND LXIH,000lH//Storeresult=01 SHLD2201H HLT
LAST: END:
AssignmentI
Writeandexecute8085assemblylanguage programtofindvalueofNth Fibonaccinumber (Recursiveversion:usingrecursivesubroutine (R i i i i b ti call) 16 bit can support up to 65356 > F24 16bitcansupportupto65356>F Deadline 12th Aug 2010 11 55Mid night Deadline:12 Aug2010,11.55Midnight Afterdeadlinegrading:Max5outof10 S d TXT SendTXTversionofprogramwithfilename i f ith fil RollNo.txttoasahu@iitg.ernet.in with Assignmentoneassubjectofemail Assignment one as subject of email Dontsubmitcopiedone:willgetNegativemarks
Introductionto 8086&i386processor
16 bit Microprocessor 16bitMicroprocessor Allinternalregistersaswellasinternaland externaldatabuseswere16bitswide external data buses were 16 bits wide 4MainRegister,4IndexRegister,4Segment Register,StatusReg,Instr P R i S R I Ptr. Notcompatiblewith8085,butwithsuccessors TwoUnitworksinparallel:
BusInterfaceUnit(BIU) ( ) ExecutionUnit(EI)
8086Architecture
BusInterface Unit
SUM CBUS
Q6 Q5 Q4 Q3 Q2 Q1
CS(CodeSeg Reg) DS(DataSeg Reg ) ES(ExtraSeg Reg ) SS(StackSeg Reg) IP(Intr Ptr) IP ( (Intr ) Operand InDirect
Sequencer
ABUS
Execution Unit
AH BH CH DH AL BL CL DL
ALU
8086Architecture
ExecutionUnit:
ALUmaybeloadedfromthreetempregisters(TMPA,TMPB, TMPC) Executeoperationsonbytesor16bitwords. Theresultstoredintotempreg orregistersconnectedtothe internaldatabus.
BusInterfaceUnit
BIUisintendedtocomputetheaddresses. Twotemporaryregisters p y g indirectaddressing foursegmentregisters(DS,CS,SSandES), Programcounter(IP InstructionPointer), g ( ), A6byteQueueBuffertostoretheprefetchedopcodes anddata. ThisPrefetch Queueoptimizethebususage. Toexecuteajumpinstructionthequeuehastobeflushedsincethe To execute a jump instruction the queue has to be flushed since the prefetchedinstructionsdonothavetobeexecuted.
Programming model for x86 architecture Programmingmodelforx86architecture 8086Assemblylanguageprogramming MASM/TASM/NASM(x86assembler) MASM / TASM /NASM ( 86 assembler) Ifyoumissthenextclass,willmissalot
Thanks Th k