Sei sulla pagina 1di 8

Z80 Simulator IDE Getting Started

There are six examples bundled with Z80 Simulator IDE. They are located in application older. This is short step by step guide or the beginners that will help them to test these examples and in that way explore the most important eatures o Z80 Simulator IDE. Example ! Example " Example # Example $ Example % Example & E'()*+E ! , Examine mem ill.asm ile rom the application older. This assembler routine ills the memory range --00. , ----. with /alues --. , 00. respecti/ely. LD A,0FFH ;initial value in register A LD BC,0FF00H ;initial value in register pair BC LD (BC),A ;load value in A to the memor lo!ation addressed " #$C BC ;in!rement BC D%C A ;de!rement A &' $(,L1 ;loop until value in A is )ero LD (BC),A ;load value 00H to memor lo!ation FFFFH HAL* ;halt !pu +%$D , Start Z80 Simulator IDE. , 0lic1 on Tools2(ssembler. , 0lic1 on -ile23pen. , Select mem ill.asm ile and clic1 on 3pen. The assembler source program will be displayed in the editor. , 0lic1 on Tools2(ssemble. ( ter the operation is completed the assembler will generate two iles4 mem ill.lst 5assembler listing with assembled opcodes6 and mem ill.ob7 5binary image o assembled routine ready to be loaded into memory6. The output listing ile mem ill.lst will be displayed. , 0lic1 on Tools2+oad. That will load the program ile mem ill.ob7 into Z80 Simulator IDE memory. , 0lose assembler window. , Select the option 3ptions2Enable logging. , Select the option 3ptions28e resh )emory Editor. , 0lic1 on Tools2)emory Editor. That will open the )emory Editor window. !# bytes o the program are in ocus. , 8eposition the windows on the screen to get better /iew9 i necessary use (lways 3n Top option on )emory Editor window. , :sing the scroll bar select the memory range --00,----. , 0hec1 that 3ptions2.(+T Stops Simulation option is selected. , 0hec1 that 8ate2-ast simulation rate is selected. ;ou can change the simulation rate e/en when the simulation is running. , 0lic1 on Simulation2Start. The simulation will start immediately. , <atch how the program a ect the selected memory range. , The simulation will automatically stop in about one minute. , +og ile log.txt created during program simulation and located in application older will be displayed in =otepad. , Screenshot4 /iew

L1:

BC

E'()*+E " , Examine mem ill".asm ile rom the application older. This is modi ied example !. The /alue that will be used to ill the memory range --00. , ----. is get rom I>3 port 0!.. The routine is then repeated. L,: L1: #$ LD LD LD A,(01H) ;get value on port 01H to "e used -or memor -ill D,0FFH ;initial value in !ounter register D BC,0FF00H ;initial value in pointer register pair BC (BC),A ;load value in A to the memor lo!ation addressed "

BC

#$C BC ;in!rement pointer BC D%C D ;de!rement !ounter D &' $(,L1 ;loop until value in D is )ero LD (BC),A ;-ill the last memor lo!ation FFFFH &' L, ;repeat routine +%$D , Start Z80 Simulator IDE. , 0lic1 on Tools2(ssembler. , 0lic1 on -ile23pen. , Select mem ill".asm ile and clic1 on 3pen. The assembler source program will be displayed in the editor. , 0lic1 on Tools2(ssemble. ( ter the operation is completed the assembler will generate two iles4 mem ill".lst 5assembler listing with assembled opcodes6 and mem ill".ob7 5binary image o assembled routine ready to be loaded into memory6. The output listing ile mem ill".lst will be displayed. , 0lose assembler window. , 0lic1 on -ile2+oad *rogram. , Select mem ill".ob7 ile and clic1 on 3pen. That will load the program into Z80 Simulator IDE memory. , Select the option 3ptions28e resh )emory Editor. , Select the option 3ptions2*rompt -or ?alue @e ore I= Instruction. , 0lic1 on Tools2)emory Editor. That will open the )emory Editor window. !A bytes o the program are in ocus. , 8eposition the windows on the screen to get better /iew9 i necessary use (lways 3n Top option on )emory Editor window. , :sing the scroll bar select the memory range --00,----. , 0hec1 that 8ate2Extremely -ast simulation rate is selected. ;ou can change the simulation rate e/en when the simulation is running. , 0lic1 on Simulation2Start. The simulation will start immediately. , The simulator will display I= Instruction Entry Dialog where you should enter a /alue in the hex range 00,-- or clic1 on Beyboard to easily get the (S0II code or any o the 1eyboard 1eys. 0lic1 on Enter to accept the selected /alue. , <atch how the program a ect the displayed memory range by loading the selected /alue to all those memory locations.

, The last two steps will be repeated until you stop the simulation by clic1ing on Simulation2Stop. , Screenshot4 /iew

E'()*+E # , Examine bin"bcd.asm ile rom the application older. This example is a binary to @0D con/ersion routine. It is adapted rom an illustrati/e program in section !!.& o Z80 textboo1 CThe Z80 )icroprocessor , (rchitecture9 Inter acing9 *rogramming9 and DesignC written by *ro . 8amesh S. Gaon1ar , lin1. .*A/*: LD .',.*AC0 ;initiali)e sta!1 pointer LD HL,B#$B2* ;point HL inde3 to 4here "inar num"er is stored LD A,(HL) ;trans-er " te LD HL,56*B6F ;point HL inde3 to output7"u--er memor CALL B#$BCD HAL*

B#$BCD: LD B,100 ;load 100 into register B (po4er o- ten holding register) CALL BCD ;!all !onversion -or BCD8 LD B,10 ;load 10 into register B CALL BCD ;!all !onversion -or BCD, LD (HL),A ;store BCD1 /%* BCD: LD (HL),0FFH ;load "u--er 4ith 71 #$C (HL) ;!lear "u--er -irst and in!rement -or ea!h su"tra!tion .6B B ;su"tra!t po4er o- ten -rom "inar num"er &/ $C,.*5/% ;i- num"er is larger than po4er o- ten, go "a!1 and add 1 to "u--er ADD A,B ;i- no, add po4er o- ten to get "a!1 remainder #$C HL ;go to ne3t "u--er lo!ation /%* .*5/%: B#$B2* 56*B6F .*AC0 +5/9 0100H +DB ,8: ;e3ample "inar num"er to "e !onverted into a BCD num"er ;output7"u--er memor lo!ation +%;6 0FFFFH ;de-inition o- sta!1 pointer initiali)ation address +%$D

, Start Z80 Simulator IDE. , 0lic1 on Tools2(ssembler. , 0lic1 on -ile23pen. , Select bin"bcd.asm ile and clic1 on 3pen. The assembler source program will be displayed in the editor.

, 0lic1 on Tools2(ssemble. ( ter the operation is completed the assembler will generate two iles4 bin"bcd.lst 5assembler listing with assembled opcodes6 and bin"bcd.ob7 5binary image o assembled routine ready to be loaded into memory6. The output listing ile bin"bcd".lst will be displayed. , 0lose assembler window. , 0lic1 on -ile2+oad *rogram. , Select mem ill".ob7 ile and clic1 on 3pen. That will load the program into Z80 Simulator IDE memory. , Select the option 3ptions28e resh )emory Editor. , 0lic1 on Tools2)emory Editor. That will open the )emory Editor window. , 8eposition the windows on the screen to get better /iew9 i necessary use (lways 3n Top option on )emory Editor window. , :sing the scroll bar select the memory range 0!00,0!--. , 0lic1 on Tools2Simulation +og ?iewer. That will open the Simulation +og ?iewer window. , 8eposition the windows on the screen to get better /iew9 i necessary use (lways 3n Top option on Simulation +og ?iewer window. , Select the Beep +ast 8ecord In -ocus option. , 0hec1 that 8ate2-ast simulation rate is selected. ;ou can change the simulation rate e/en when the simulation is running. , 0hec1 that 3ptions2.(+T Stops Simulation option is selected. , 0lic1 on Simulation2Start. The simulation will start immediately. , <atch how the program a ect the selected memory range. , The simulation will stop automatically when .(+T instruction is reached. , Screenshot4 /iew

E'()*+E $ , Examine interrupt.asm ile rom the application older. This example shows how peripheral de/ices and interrupts inter aces are used. The routine irst sends i/e data bytes to port 0". 5should be treated as the initialiDation o the peripheral de/ice6 and then responds to generated interrupts by echoing the /alue recei/ed on port 0!. to port 0".. &' 0100H ;<ump to main routine +5/9 008=H ;interrupt routine #$ A,(01H) ;get the value -rom port 01H 56* (0,H),A ;e!ho that value to port 0,H %# ;ena"le interrupts /%*# ;return -rom interrupt +5/9 0100H ;main rountine &/ L1 ;<ump over data area +DB 0AH ;data " te 1 +DB 0BH ;data " te ,

L,:

L1: L8:

L::

+DB 0CH ;data " te 8 +DB 0DH ;data " te : +DB 0%H ;data " te > LD D,0>H ;load !ounter register D LD BC,L, ;load pointer register pair BC LD A,(BC) ;get the data " te 56* (0,H),A ;send it to port 0,H #$C BC ;in!rement pointer BC D%C D ;de!rement !ounter D &' $(,L8 ;loop until all data " tes are sent #? 1 ;set interrupt mode 1 %# ;ena"le interrupts &' L: ;loop -orever +%$D

, Start Z80 Simulator IDE. , 0lic1 on Tools2(ssembler. , 0lic1 on -ile23pen. , Select interrupt.asm ile and clic1 on 3pen. The assembler source program will be displayed in the editor. , 0lic1 on Tools2(ssemble. ( ter the operation is completed the assembler will generate two iles4 interrupt.lst 5assembler listing with assembled opcodes6 and interrupt.ob7 5binary image o assembled routine ready to be loaded into memory6. The output listing ile interrupt.lst will be displayed. , 0lose assembler window. , 0lic1 on -ile2+oad *rogram. , Select interrupt.ob7 ile and clic1 on 3pen. That will load the program into Z80 Simulator IDE memory. , Select the 8ate2=ormal simulation rate. ;ou can change the simulation rate e/en when the simulation is running. , :=SE+E0T the option 3ptions2*rompt -or ?alue @e ore I= Instruction. , Select the option 3ptions2Enable I=>3:T Instructions +ogging. , 0lic1 on Tools2*eripheral De/ices. That will open the *eripheral De/ices window. , 8eposition the windows on the screen to get better /iew9 i necessary use (lways 3n Top option on *eripheral De/ices window. , Turn on the De/ice ! by clic1ing on its 3-- button. Enter 0! or its port number. , Select I= option button to con igure it as an input de/ice. , Turn on the De/ice " by clic1ing on its 3-- button. Enter 0" or its port number. , Do not change its de ault con iguration o an output de/ice. , 0lic1 on Simulation2Start. The simulation will start immediately. , <atch the program sending % bytes 0(9 0@9 009 0D9 0E to the I>3 de/ice on port 0". , @y toggling indi/idual bits o De/ice !9 prepare an arbitrary /alue 5say ((6. ;ou can also prepare the /alue that will be supplied by this de/ice by clic1ing on the /alue label next to the graphical representation. Then by clic1ing on Beyboard button you will be able to easily get the (S0II code or any o the 1eyboard 1eys. , This program uses interrupts9 so a ter the EI instruction I=T button on interrupt inter ace is enabled. , 0lic1 on I=T button. That will send the interrupt signal to the Z80 Simulator9 and the execution o the interrupt routine will start. , The interrupt routine reads the byte supplied by the De/ice ! and echoes it to the De/ice ". , The interrupt generation can be repeated. , 0lic1 on Simulation2Stop to stop the simulation. , Examine I>3 log ile io.txt rom the application older. , Screenshot4 /iew

E'()*+E % , Examine basmul.bas ile rom the application older. This is @asic source program that will be compiled using integrated @asic compiler. It is an integer multiply routine that will multiply two integer numbers !"# and "#$. Dim a As #nteger Dim " As #nteger Dim ! As #nteger a @ 1,8 AFirst num"er " @ ,8: A.e!ond num"er ! @ a B " , Start Z80 Simulator IDE. , 0lic1 on Tools2@(SI0 0ompiler. , 0lic1 on -ile23pen. , Select basmul.bas ile and clic1 on 3pen. The basic source program will be displayed in the editor. , 0lic1 on Tools20ompile. The compiler will generate basmul.asm ile with assembler source. , 0lose @(SI0 0ompiler window. , 0lic1 on Tools2(ssembler. , 0lic1 on -ile23pen. , Select basmul.asm ile and clic1 on 3pen. The assembler source program will be displayed in the editor. , 0lic1 on Tools2(ssemble. ( ter the operation is completed the assembler will generate two iles4 basmul.lst 5assembler listing with assembled opcodes6 and basmul.ob7 5binary image o assembled routine ready to be loaded into memory6. The output listing ile basmul.lst will be displayed. , 0lic1 on Tools2+oad. That will load the program ile basmul.ob7 into Z80 Simulator IDE memory. , 0lose assembler window. , 0hec1 that 3ptions2.(+T Stops Simulation option is selected. , Select the option 3ptions28e resh @rea1points )anager. , 0lic1 on Tools2@rea1points )anager. That will open the @rea1points )anager window. , 8eposition the windows on the screen to get better /iew9 i necessary use (lways 3n Top option on @rea1points )anager window. , 0lic1 on the line corresponding to 00"- address to de ine the brea1point on this instruction. That is the beginning o integer multiplication routine. , Select the .old *0 In -ocus option. , Select the 8ate2-ast simulation rate. , 0lic1 on Simulation2Start. The simulation will start immediately. , <hen the Z80 Simulator IDE reach the brea1point it will automatically switch to Step @y Step simulation rate. , 0lic1 on 8ate2-ast to continue with simulation. , <atch the program execution on the @rea1points )anager. , The simulation will stop when the .(+T instruction is reached. The result o multiplication "8A8"

5A0&E.6 will reside in .+ register pair and also in memory locations assigned to /ariable CcC. , Screenshot4 /iew

E'()*+E & , Examine basprint.bas ile rom the application older. This is @asic source program that will be compiled using integrated @asic compiler. It is a single precision loating point multiply routine that will multiply two real numbers E.8A&%$# and ".#$%&A8 and then send the ormatted text showing the result o the operation to the I>3 port number !. Dim a As .ingle Dim " As .ingle Dim ! As .ingle a @ C+=DE>:8 AFirst num"er " @ ,+8:>ED= A.e!ond num"er ! @ a B " 'rint 1, F$um"er F, a, CrL'rint 1, Fmultiplied " F, ", CrL'rint 1, FeGuals F, !, FHF, CrL, Start Z80 Simulator IDE. , 0lic1 on Tools2@(SI0 0ompiler. , 0lic1 on -ile23pen. , Select basprint.bas ile and clic1 on 3pen. The basic source program will be displayed in the editor. , 0lic1 on Tools20ompile. The compiler will generate basprint.asm ile with assembler source. , 0lose @(SI0 0ompiler window. , 0lic1 on Tools2(ssembler. , 0lic1 on -ile23pen. , Select basprint.asm ile and clic1 on 3pen. The assembler source program will be displayed in the editor. , 0lic1 on Tools2(ssemble. ( ter the operation is completed the assembler will generate two iles4 basprint.lst and basprint.ob7. The output listing ile basprint.lst will be displayed. , 0lic1 on Tools2+oad. That will load the program ile basprint.ob7 into Z80 Simulator IDE memory. , 0lose assembler window. , 0lic1 on Tools2*eripheral De/ices. That will open the *eripheral De/ices window. , 8eposition the windows on the screen to get better /iew9 i necessary use (lways 3n Top option on *eripheral De/ices window. , Turn on the 3utput Terminal by clic1ing on its 3-- button. Enter ! or its I>3 port number. , 0hec1 that 3ptions2.(+T Stops Simulation option is selected. , Select the 8ate2Extremely -ast simulation rate. , 0lic1 on Simulation2Start. The simulation will start immediately. , *8I=T routines are slow and it will ta1e some time until the .(+T instruction is reached. The program will display ormatted text showing the result o the operation on the 3utput Terminal. , Screenshot4 /iew

Potrebbero piacerti anche