The inside story Most DFS provide a *DUMP command to list the contents of a file in both hexadecimal and in characters. This routine provides a command - *MDUMP - which does exactly the same with an area of memory, not just main memory, but sideways ROM, shadow RAM and the Tube. The listing generates the MDUMP command file. Type it in and check it with Get it Right!. When run it generates the code and saves it as MDUMP. The command is called by entering: *MDUMP addr followed optionally by either an end address or + and a length. All the address are given in hexadecimal, and tape users should use */MDUMP wherever a reference to *MDUMP is made. To dump 16 bytes of memory starting at &700, you could use: *MDUMP 700+10 or *MDUMP 700 710 As this is the area of memory used by BASIC to hold the command line just typed in, you will see something like: 000700 2A 4D 44 55 4D 50 20 37 *MDUMP 7 000708 30 30 20 2B 31 30 0D 00 00 +10.. If no end address or length is given, then the dump will keep going until the Escape key is pressed. Giving the start address in the format Frsss - in the range F00000 to FFFFFF - causes ROM number r to be paged in and dumped, so: *MDUMP FD8000+20 dumps the first 32 bytes of ROM 13. If you have a second processor attached, then addresses in the Fxxxxx range will address the I/O processor's memory, as with filing system addresses, so: *MDUMP FF3000+40 will dump the start of the area of memory reserved for the screen in the I/O processor. Also: *MDUMP F800 FFFF will dump the second processor operating system, on a 6502 second processor. The BBC B+ and Master series have more memory hidden away inside them - both have the shadow screen. There's spare memory left over from that on the B+ and Masters have the private workspace RAM. Given an address in the format FEssss, the *MDUMP command will dump this memory. That is: {*} the shadow screen at FE3000 to FE7FFF. {*} the spare sideways RAM at FE8000 to FEAFFF on the BBC B+. {*} the MOS workspace RAM at FE8000 to FE8FFF on the Master. {*} the filing system RAM at FEC000 to FEDFFF on the Master. The table on the following page gives a summary of the address you can use with this command. +--------+--------------+--------------+--------------| |Address | BBC B | BBC B+ | Master | +--------+--------------+--------------+--------------+ | 000000 | Normal language memory, ie main memory | | to | if no second processor, second | | FDFFFF | processor memory if there is. | +--------+--------------------------------------------+ | FE0000 | | | to | Main I/O processor memory | | FE2FFF | | +--------+--------------+--------------+--------------+ | FE3000 | | Shadow | Shadow | | to | Main | screen | screen | | FE7FFF | memory | memory | memory | +--------+--------------+--------------+--------------+ | FE8000 | Sideways | Spare | MOS and | | to | rom#14 | sideways | VDU | | FE8FFF | memory | memory | workspace | +--------+--------------+--------------+--------------+ | FE9000 | Sideways | Spare | Sideways | | to | rom#14 | sideways | rom#14 | | FEAFFF | memory | memory | memory | +--------+--------------+--------------+--------------+ | FEB000 | Sideways | Sideways | Sideways | | to | rom#14 | rom#14 | rom#14 | | FEBFFF | memory | memory | memory | +--------+--------------+--------------+--------------+ | FEC000 | | | Filing | | to | MOS ROM | MOS ROM | system | | FEDFFF | | | workspace | +--------+--------------+--------------+--------------+ | FEE000 | | | to | Machine Operating System ROM | | FEFFFF | (and memory mapped I/O ports) | +--------+--------------+--------------+--------------+ | Fx0000 | Main I/O processor memory, | | to | including the non-shadow screen | | Fx7FFF | memory. x is ignored. | +--------+--------------+--------------+--------------+ | Fr8000 | | | to | Sideways ROM/RAM number r. | | FrBFFF | | +--------+--------------+--------------+--------------+ | FxC000 | | | to | Machine Operating System ROM | | FxFFFF | | +--------+--------------+--------------+--------------+ The addresses to use to dump various areas of memory The program has been tested on BBC Micros on all operating systems from 1.20 onwards, and with several DFSs. It will work with NFS 3.60, but the NFS 3.34 ROM has a bug in the routine to return the address of the command line, so it will not work. If you have that ROM you should take advantage of the service offered by many companies cheaply - or freely - to upgrade it. How it works The first part of the program calls the filing system to get the address of the parameters on the command line. It then checks that the first is a valid hexadecimal address and reads it in to the zero page locations addr to addr+2. After skipping any spaces, if there are no more parameters, it jumps forward to start the dump, with the forever flag set - as it was when the program started - to &FF. If there is another parameter, it is examined after the forever flag has been reset by giving it a value with bit 7 equal to zero. The character just fetched will be in the range 0 to 127, so that is used. If the following parameter is preceeded with a '+', then the following address is fetched and the start address added onto it. Otherwise, the address is fetched as it is. If there is deviation from the expected syntax, then the error message Syntax: MDump (/+) is given. As the first part of the program is only executed once, this is used later as variable space to save memory and squeeze it into 512 bytes so it will fit in the cassette buffer. The next section of the program checks which machine it is running on by using OSBYTE 0 and sets some flags for accessing the various bits of memory accordingly. Ordinary BBC Bs and and Electrons don't have the extra memory, so this part is skipped past. The Masters and the BBC B+ do have it, so the access flag acc_flg is set to &FF to signal this. The BBC B+ accesses its extra memory by setting the ROM/RAM select latch at &FE30 to 128. This is noted by setting acc2 to 128. The Master and the B+ both access their extra memory by fiddling with the ACCCON register at location &FE34 and acc1 and acc2 are set to note this. For an explanation of the ACCCON register, see the New Advanced User Guide, Dickens & Holmes. It is sufficient to say that on the BBC B+, bit 7 controls whether shadow screen is paged in, and on the Master bits 2 and 3 control wheter the shadow RAM and filing system workspace RAM are paged in or not. As the other bits also affect the system's setup, they have to be preserved when changing bits 2 and 3. Seven is then added to the end address for the checking later. The program goes into a loop which does the following: {*} The current address is printed. {*} Eight bytes are fetched into the buffer. They are printed in hexadecimal. {*} The eight bytes are then printed in characters. Ones in the range 128 to 255 are displayed as characters 0 to 127, where characters 0 to 31 (the control codes) and character 127 (delete) are displayed as full stops. {*} Eight is added to the current address, and if the forever flag is set, the routine jumps forward to prepare to loop around again. {*} If the forever flag is not set, then a check is performed to see if the end address has been reached. This is done by masking out the bottom three bits and Exclusive ORing the end address and the current address. If these are the same - ignoring the bottom three bits - then the program jumps to exit. At this point, before looping back again, a check is made on the escape flag (location &FF). If Escape has not been pressed, then the program loops back to do another eight bytes. If Escape has been pressed, then it is acknowledged, and the program exits. Use of OSBYTE 0 OSBYTE 0 tells you what operating system the machine is running. When entered with X=0, an error message is displayed with the version. With X as non-zero, then X is returned holding a number refering to the OS number. These are: 0 BBC micro, OS 0.10 and Electron 1 BBC micro, OS 1.20 2 BBC B+, OS 2.00 3 BBC Master, 3.20 4 BBC Master, OS 4.00 5 Master Compact, OS 5.00 This is similar to INKEY(-256), but gives an easier series of numbers to decode.