z80gettingstarted

Please download to get full document.

View again

of 7
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Categories
Published
Z80 Simulator IDE Getting Started There are six examples bundled with Z80 Simulator IDE. They are located in application folder. This is short step by step guide for the beginners that will help them to test these examples and in that way explore the most important features of Z80 Simulator IDE. Example 1 Example 2 Example 3 Example 4 Example 5 Example 6 EXAMPLE 1 - Examine memfill.asm file from the application folder. This assembler routine fills the memory range FF00H - FFFFH with values FFH -
  Z80 Simulator IDEGetting Started TherearesixexamplesbundledwithZ80SimulatorIDE.Theyarelocatedinapplicationfolder.ThisisshortstepbystepguideforthebeginnersthatwillhelpthemtotesttheseexamplesandinthatwayexplorethemostimportantfeaturesofZ80SimulatorIDE.Example1 Example2 Example3 Example4 Example5 Example6 EXAMPLE1-Examinememfill.asmfilefromtheapplicationfolder.ThisassemblerroutinefillsthememoryrangeFF00H-FFFFHwithvaluesFFH-00Hrespectively. LD A,0FFH;initial value in register A LD BC,0FF00H;initial value in register pair BC L1: LD (BC),A;load value in A to the memory location addressed by BCINC BC;increment BC DEC A;decrement A JP NZ,L1;loop until value in A is zero LD (BC),A;load value 00H to memory location FFFFH HALT;halt cpu .END -StartZ80SimulatorIDE.-ClickonTools\Assembler.-ClickonFile\Open.-Selectmemfill.asmfileandclickonOpen.Theassemblersourceprogramwillbedisplayedintheeditor.-ClickonTools\Assemble.Aftertheoperationiscompletedtheassemblerwillgeneratetwofiles:memfill.lst(assemblerlistingwithassembledopcodes)andmemfill.obj(binaryimageofassembledroutinereadytobeloadedintomemory).Theoutputlistingfilememfill.lstwillbedisplayed.-ClickonTools\Load.Thatwillloadtheprogramfilememfill.objintoZ80SimulatorIDEmemory.-Closeassemblerwindow.-SelecttheoptionOptions\Enablelogging.-SelecttheoptionOptions\RefreshMemoryEditor.-ClickonTools\MemoryEditor.ThatwillopentheMemoryEditorwindow.13bytesoftheprogramareinfocus.-Repositionthewindowsonthescreentogetbetterview,ifnecessaryuseAlwaysOnTopoptiononMemoryEditorwindow.-UsingthescrollbarselectthememoryrangeFF00-FFFF.-CheckthatOptions\HALTStopsSimulationoptionisselected.-CheckthatRate\Fastsimulationrateisselected.Youcanchangethesimulationrateevenwhenthesimulationisrunning.-ClickonSimulation\Start.Thesimulationwillstartimmediately.-Watchhowtheprogramaffecttheselectedmemoryrange.-Thesimulationwillautomaticallystopinaboutoneminute.-Logfilelog.txtcreatedduringprogramsimulationandlocatedinapplicationfolderwillbedisplayedinNotepad.-Screenshot:view  EXAMPLE2-Examinememfill2.asmfilefromtheapplicationfolder.Thisismodifiedexample1.ThevaluethatwillbeusedtofillthememoryrangeFF00H-FFFFHisgetfromI/Oport01H.Theroutineisthenrepeated. L2: IN A,(01H);get value on port 01H to be used for memory fill LD D,0FFH;initial value in counter register D LD BC,0FF00H;initial value in pointer register pair BC L1: LD (BC),A;load value in A to the memory location addressed by BCINC BC;increment pointer BC DEC D;decrement counter D JP NZ,L1;loop until value in D is zero LD (BC),A;fill the last memory location FFFFH JP L2;repeat routine .END -StartZ80SimulatorIDE.-ClickonTools\Assembler.-ClickonFile\Open.-Selectmemfill2.asmfileandclickonOpen.Theassemblersourceprogramwillbedisplayedintheeditor.-ClickonTools\Assemble.Aftertheoperationiscompletedtheassemblerwillgeneratetwofiles:memfill2.lst(assemblerlistingwithassembledopcodes)andmemfill2.obj(binaryimageofassembledroutinereadytobeloadedintomemory).Theoutputlistingfilememfill2.lstwillbedisplayed.-Closeassemblerwindow.-ClickonFile\LoadProgram.-Selectmemfill2.objfileandclickonOpen.ThatwillloadtheprogramintoZ80SimulatorIDEmemory.-SelecttheoptionOptions\RefreshMemoryEditor.-SelecttheoptionOptions\PromptForValueBeforeINInstruction.-ClickonTools\MemoryEditor.ThatwillopentheMemoryEditorwindow.17bytesoftheprogramareinfocus.-Repositionthewindowsonthescreentogetbetterview,ifnecessaryuseAlwaysOnTopoptiononMemoryEditorwindow.-UsingthescrollbarselectthememoryrangeFF00-FFFF.-CheckthatRate\ExtremelyFastsimulationrateisselected.Youcanchangethesimulationrateevenwhenthesimulationisrunning.-ClickonSimulation\Start.Thesimulationwillstartimmediately.-ThesimulatorwilldisplayINInstructionEntryDialogwhereyoushouldenteravalueinthehexrange00-FForclickonKeyboardtoeasilygettheASCIIcodeforanyofthekeyboardkeys.ClickonEntertoaccepttheselectedvalue.-Watchhowtheprogramaffectthedisplayedmemoryrangebyloadingtheselectedvaluetoallthosememorylocations.-ThelasttwostepswillberepeateduntilyoustopthesimulationbyclickingonSimulation\Stop.-Screenshot:view  EXAMPLE3-Examinebin2bcd.asmfilefromtheapplicationfolder.ThisexampleisabinarytoBCDconversionroutine.Itisadaptedfromanillustrativeprograminsection11.6ofZ80textbook'TheZ80Microprocessor-Architecture,Interfacing,Programming,andDesign'writtenbyProf.RameshS.Gaonkar-link. START: LD SP,STACK;initialize stack pointer LD HL,BINBYT;point HL index to where binary number is stored LD A,(HL);transfer byte LD HL,OUTBUF;point HL index to output-buffer memory CALL BINBCDHALTBINBCD:LD B,100;load 100 into register B (power of ten holdingregister) CALL BCD;call conversion for BCD3 LD B,10;load 10 into register B CALL BCD;call conversion for BCD2 LD (HL),A;store BCD1 RETBCD:LD (HL),0FFH;load buffer with -1 STORE: INC (HL);clear buffer first and increment for each subtraction SUB B;subtract power of ten from binary number JR NC,STORE;if number is larger than power of ten, go back andadd 1 to buffer ADD A,B;if no, add power of ten to get back remainder INC HL;go to next buffer location RET.ORG 0100HBINBYT .DB 234;example binary number to be converted into a BCD number OUTBUF;output-buffer memory location STACK .EQU 0FFFFH;definition of stack pointer initialization address .END -StartZ80SimulatorIDE.-ClickonTools\Assembler.-ClickonFile\Open.-Selectbin2bcd.asmfileandclickonOpen.Theassemblersourceprogramwillbedisplayedintheeditor.-ClickonTools\Assemble.Aftertheoperationiscompletedtheassemblerwillgeneratetwofiles:bin2bcd.lst(assemblerlistingwithassembledopcodes)andbin2bcd.obj(binaryimageofassembledroutinereadytobeloadedintomemory).Theoutputlistingfilebin2bcd2.lstwillbedisplayed.-Closeassemblerwindow.-ClickonFile\LoadProgram.-Selectmemfill2.objfileandclickonOpen.ThatwillloadtheprogramintoZ80SimulatorIDE  memory.-SelecttheoptionOptions\RefreshMemoryEditor.-ClickonTools\MemoryEditor.ThatwillopentheMemoryEditorwindow.-Repositionthewindowsonthescreentogetbetterview,ifnecessaryuseAlwaysOnTopoptiononMemoryEditorwindow.-Usingthescrollbarselectthememoryrange0100-01FF.-ClickonTools\SimulationLogViewer.ThatwillopentheSimulationLogViewerwindow.-Repositionthewindowsonthescreentogetbetterview,ifnecessaryuseAlwaysOnTopoptiononSimulationLogViewerwindow.-SelecttheKeepLastRecordInFocusoption.-CheckthatRate\Fastsimulationrateisselected.Youcanchangethesimulationrateevenwhenthesimulationisrunning.-CheckthatOptions\HALTStopsSimulationoptionisselected.-ClickonSimulation\Start.Thesimulationwillstartimmediately.-Watchhowtheprogramaffecttheselectedmemoryrange.-ThesimulationwillstopautomaticallywhenHALTinstructionisreached.-Screenshot:viewEXAMPLE4-Examineinterrupt.asmfilefromtheapplicationfolder.Thisexampleshowshowperipheraldevicesandinterruptsinterfacesareused.Theroutinefirstsendsfivedatabytestoport02H(shouldbetreatedastheinitializationoftheperipheraldevice)andthenrespondstogeneratedinterruptsbyechoingthevaluereceivedonport01Htoport02H. JP 0100H;jump to main routine .ORG 0038H;interrupt routine IN A,(01H);get the value from port 01H OUT (02H),A;echo that value to port 02H EI;enable interrupts RETI;return from interrupt .ORG 0100H;main rountine JR L1;jump over data area L2: .DB 0AH;data byte 1 .DB 0BH;data byte 2 .DB 0CH;data byte 3 .DB 0DH;data byte 4 .DB 0EH;data byte 5 L1: LD D,05H;load counter register D LD BC,L2;load pointer register pair BC L3: LD A,(BC);get the data byte OUT (02H),A;send it to port 02H INC BC;increment pointer BC DEC D;decrement counter D JP NZ,L3;loop until all data bytes are sent 
Similar documents
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks