home *** CD-ROM | disk | FTP | other *** search
- Z80 EMULATOR by Dave Higton
-
- This is not yet complete, but I have uploaded it to gauge interest. It
- emulates a Z80, specifically in the environment of a Vector Graphic System B
- computer. The memory map is as follows:
-
- 0000-DFFF RAM
- E000-EFFF EPROM (E000-E7FF is monitor, rest is extensions)
- F000-F77F Video RAM, direct mapped to screen as 80 * 24
- F780-F7FF RAM, not mapped to screen
- F800-FBFF EPROM, sometimes used for disc boot EPROMs
- FC00-FFFF RAM, used by monitor and basic I/O for stack etc.
-
- All the RAM from F000-F7FF is accessible in the original machine during
- vertical blanking only, therefore the area from F780-F7FF is very rarely
- used in practice.
-
- The original machine uses the PHANTOM line of the S100 bus to relocate EPROM
- to locations 0000-0FFF for the first instruction following a hard reset.
- The first three bytes in EPROM are a jump to a location in the monitor
- EPROM. Therefore I have made the reset jump to &E000 rather than 0000. This
- is directly equivalent.
-
- The I/O map of the original cannot be exactly copied in the emulator since
- this would require three serial ports, for instance. However, the keyboard
- status port is at 00, keyboard data at 01, and serial status/data INPUT
- ports are at 05 and 04. The original computer had Micropolis 5 1/4"
- hard-sectored disc drives (this was state of the art when it was designed!)
- and the emulation cannot reflect this either. I'm working on mapping the
- Arc's floppy disc hardware into the I/O map at &F0 to &F5, but this isn't
- complete yet. See later caution!
-
- There is no concept of interrupts in this emulator. However, none of the
- normal system software requires them, so this shouldn't be a problem.
-
- All single byte instructions are emulated except &76 (HALT) which would be
- meaningless (would cause the machine to freeze because there aren't any
- interrupts to un-HALT it), therefore causes an abort. All the CB-prefixed
- instructions are emulated. The easier ED-prefixed instructions are
- emulated, others aren't yet (e.g. RLD and so on). The indexed instructions
- using IX are complete except for the DD CB group (shifts/rotates/bit
- test/set/reset). The IY instructions are not present except for PUSH IY and
- POP IY. When I have finished the IX group, it will be easy to complete the
- IY group, largely by copying and global search/replace.
-
- The monitor has the following commands:
- A ASCII Dump <start> <end>
- B Boot Disc (this will cause an abort)
- C Compare <start> <end> <2nd block start> Compares 2 blocks of memory
- D Hex Dump <start> <end>
- E Ext Com (copies serial port's input to screen)
- F Find-2 <start> <end> <byte1> <byte2>
- G Go to <address>
- H Hi RAM (jumps to an address in the top 1K of RAM)
- I Input <port>
- J Jump to DOS (at 0000, to cause a CP/M warm start)
- K Break at <address> Enter breakpoint
- L Lo ram (jumps to an address in main RAM)
- M Move <start> <end> <new start> (copies a block of memory)
- N Non-destructive RAM test <start> <end>
- O Output <port> <data>
- P Program <address>
- Q Checksum <start> <end>
- R Registers
- S Search-1 <start> <end> <byte>
- T Test RAM <start> <end> (destructive test, i.e. overwrites old contents)
- U User area
- V Boot Dualstor (would boot some kind of disc, but won't - yet!)
- W Boot Megastor (would boot a hard disc, but won't - yet!)
- X Exchange <start> <end> <snd block start> Exchanges 2 blocks of memory
- Y Echo keys (to screen)
- Z Zero/fill RAM <start> <end> <data>
-
- Commands such as N, T and Y are terminated by the Esc key. Others return
- immediately to the monitor main loop, except for the disc boot operations.
-
- The character generator is faithfully emulated. Printing characters from
- &20 to &7F are standard ASCII. Characters from &00 to &1F are block graphic
- characters. Setting bit 7 displays any character in inverse video - this
- enables displaying the 6th block graphic.
-
- The monitor has several entry points. &E000 is the cold start entry, &E003
- is the warm start, &E009 is the video driver. Executing opcode &FF (RST
- 38H) prints the register contents and enters the monitor.
-
- Any opcodes which are not implemented cause the emulator to print out all
- register contents and exit. The emulator runs in system mode. Interrupts
- are enabled, but I'm not sure what interrupts are actually accepted and
- serviced. The monotonic timer appears not to run. The emulator is an
- application, i.e. it executes at &8000 and takes over the machine
- completely.
-
- I recommend that you don't output to ports &F0 to &F5 because of the mapping
- to the disc hardware of the Arc. If you do, you could manage to write to a
- floppy disc, thereby damaging the information held on it. You have been
- warned!
-
- The video driver handles various control characters, but they may not be the
- ones you are expecting. E.g. control-D clears screen, control-U is cursor
- up, control-R is cursor down, control-W is cursor left, control-Z is cursor
- right, control-P is erase to beg. of line, control-X is erase to beg. of
- line, control-T toggles normal/inverse video. There is no bell or beep on
- the machine being emulated.
-
- While executing, the Esc key does not cause an escape event. This is
- because the monitor programme requires use of the escape key. It is reset
- to normal when the emulator exits. An abort (due to an illegal instruction)
- is the only way to exit - like the PC emulator.
-
- SPEED
-
- Everyone asks this. There isn't, however, a one-number answer. Some
- instructions execute fast (e.g. LD R, R'), others execute slowly. The final
- answer on speed has to come from any individual programme. In general, it
- executes on an ARM2 A3000 a bit slower than a 4 MHz Z80 with no wait states.
- Since it is an interpreter, I don't know any way to speed it up.
-
- THE FUTURE
-
- 1) I do intend to implement all the instructions!
-
- 2) The floppy disc hardware will be mapped in properly. This won't be
- simple because the emulator doesn't execute fast enough to read/write
- sectors/tracks directly; however, it should end up simple to use.
-
- 3) If someone can tell me how to write a keyboard handler, I'll make the
- Arc's cursor keys emit the codes expected by the monitor programme and
- the other software written by Vector Graphic.
-
- 4) I want to customise CP/M for this hardware. Clearly, the original
- version was for a hard-sectored controller.
-
- If I manage to get it to that state, then there will be a very good text
- editor (SCOPE - SCreen Oriented Program Editor) and an excellent debugger
- (ZRAID - Z80 RApid Interactive Debugger) available. These programmes were
- written by Vector Graphic. I also have used, and can thoroughly recommend,
- SLR Systems' assembler and linker - the virtual linker (SLRNK+) being
- particularly useful since it can cope with a full 64K and more, overlays,
- etc. However, the SLR Systems programmes are current (as is the company)
- and so these programmes would have to be bought by any user. Vector Graphic
- was an American company which went bankrupt some years ago - can anyone
- advise me on what the legal status of their software might be? Clearly
- Digital Research are still in business, and own the copyright of CP/M. So
- if anyone knows anything about the legal requirements of distributing a
- newly customised version of CP/M, I'd like to hear from you.
-
- Leave messages for me on The World Of Cryton BBS.
-
- Dave Higton