WRITING machine code programs can be extremely frustrating at times. It's not often that a routine works straight away and I'm always surprised when it does. When things go wrong in Basic you can always press Escape to stop the program or maybe it'll stop anyway with an error report. Then you can usually see where it's gone wrong by listing the offending lines and easily correct them. Machine code is totally different. When things go wrong they do so with a vengeance and often the only solution is to switch off the micro and start again. It can be very difficult to work out why the program crashed, where it was up to and what it was doing. Breakpoints is a routine that will enable you to run a machine code program and stop when the program counter reaches a preset value. For instance you could run a routine at &9100 and instruct it to stop when the program counter reaches &9151. It's an essential tool for debugging machine code. When you run Breakpoints it will set up |RUN, a new RSX which requires two parameters. The first is the entry address of the code and the second is where you want to stop. Take the following program for instance:
8008:3E F4 LD A,245 8002:06 08 LD B,8 8084:CB 08 RRC B 8006:80 ADD A,B 8007:EE FF XOR &FF 8009:CD 5A BB CALL &BB5A 800C:C9 RET It is supposed to produce a beep by loading the A register with 7 - in a rather round about way - and calling &BB5A. If you run it nothing appears to happen and it's difficult to see why. If we |RUN the code we can stop it at any point. For instance:
|RUN,&8000,&8009 will run the code at &8000 until the program counter reaches &8009, just before the CALL &BB5A. When the breakpoint is reached the contents of all the registers are printed along with the status of the flags. You can now see what code inCWTA ★ AMSTRAD CPC ★ DOWNLOAD ★ |
|
CPCrulez[Content Management System] v8.7-desktop/c Page créée en 520 millisecondes et consultée 1672 foisL'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko. |
|
|