|★ APPLICATIONS ★ PROGRAMMATION ★ Z80 SIMULATOR|Amstrad Action) ★|
|Z80 Simulator||Applications Programmation|
No, no, it's not the lastest release from Codemasters. Z80 Simulator is a machine code debugging tool that should be useful to hackers and programmers alike. ADAM WARING puts it through its paces...
Z80 Simulator does what it says - it's a Z80 simulator that will test your code, performing any actions that the program carries out, without actually executing any instructions.
Obviously it's no use simulating code without any indication of what's going on. So wodges of information appear to guide you through your steps. The registers, disassembled instructions, and other valuable information is displayed at all times.
The Simulator is basically a machine code monitor, albeit a powerful one. The mam difference is that it allows you to use the whole of memory to test your programs. The traditional limitation of monitors is that they require a certain amount of memory to reside in. When examining a program that has been written by someone else - or even one of your own - it can be difficult to decide where to locate the monitor where it won't get overwritten.
Z80 Simulator isn't affected by these problems. The code is actually stored in the alternate memory banks in the 128K machines, and pulls out the bits of code as it needs them. The user doesn't have to worry where the code lies at all. In fact the whole thing is very clever. All memory operations are earned in the extra memory banks. It is indeed a simulation. as the main memory remains uneffected by the program's actions!
You're in command
When the program's first run, a help screen is displayed, showing all the available commands. Should you get stuck, pressing the H key will remind you what's available.
Most commands are available at a single keypress. These are the commonly used ones. Other, less frequently used functions, are known as the extended commands. These are accessed by first pressing X. followed by the keypress This allows all the functions to have reasonably logical names, and also acts as a safeguard - loading a block of code is an extended command, so you won't accidentally overwrite the program you've been tracing for hours.
All the registers may be altered with ease, including the stack and program counter. So 'what if' situations can be tested by entering troublesome routines with different values.
A step at a time
Memory dumps, disassemblies, memory editing can be performed ROMs can be switched in and flags can be examined. But real work starts when you use the single stepping commands -here's where the actual simulation takes place. The program can be stepped through an instruction at a time, with the registers and other information displays being updated as the commands are 'executed'.
For the most pan, the program steps through each instruction quite happily. But there are some situations where it can't simulate the command, and in this instance a warning is given to the user.
Commands that use the I/O ports, that attempt to swap memory banks, that try to alter the interrupt mode or that aren't valid Z80 instructions will throw up such a warning In other words, anything that may cause the Simulator to stop working, or could cause the computer to crash. In this instance the instruction is skipped, but, most importantly, you're told that it's been skipped.
There are other situations in which such a message may be displayed. Breakpoints and high and low address limits can be set by the user. Should the simulated code reach the breakpoint address, or stray outside the minimum or maximum limits, then you'll be told.
Should you want to run some code without being informed of what's happening at every instruction, tracing a subroutine that you know works for instance, the Go command will step through rapidly without updating the display Execution stops, as above, when a break occurs.
Sim is a very useful tool. It's extremely flexible -not having to know where a program's located means that a great deal of the fiddliness normally associated with debuging aids is eradicated.
That's not to say it's for the beginner, though. A good grounding in machine code and a general understanding of the way monitors work is essential - don't expect the manual to teach you anything above a command-specific level.
So, whether the program is of any use to you depends entirely on the way you use your Amstrad. If you're forever getting flummoxed by bugs in your machine code programs, or enjoy hacking mto other peoples, then Sim has an awful lot of plus points!
AMSTRAD ACTION (August 1991)