MDUMP What it does: ÝMost DFS provide a *DUMP command to dump out a file on disk in hexadecimal and in characters. This command provides a means of doing the same thing with an area of memory in the same format. Hence the name _ Memory DUMPer. How it works ÝThe listing given generates the MDUMP command file. Type it in, and when all is correct, RUN it. The code will be generated and saved with the filename MDUMP. Tape users should change the following two lines: Ý 90 mcode%=&B00 Ý 760 LDA #18:JMP OSBYTE \ Reset function keys ÝThe command is called by using Ý Ý*MDUMP addr followed optionally by either an end address or "+" and a length. All the address are given in hexadecimal. (Tape users should use */MDUMP wherever it says *MDUMP here). So, 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. ÝIf the start address is given in the format Frsss, that is, in the range F00000 to FFFFFF, then ROM number r will be paged in and dumped, so Ý Ý*MDUMP FD8000+20 dumps the first 32 bytes of ROM 13. In my machine, this is the BASIC ROM, so it gives: Ý FD8000 C9 01 F0 1F 60 EA 60 0E I.p.`j`. Ý FD8008 01 42 41 53 49 43 00 28 .BASIC.( Ý FD8010 43 29 31 39 38 32 20 41 C)1982 A Ý FD8018 63 6F 72 6E 0A 0D 00 00 corn.... Ý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 F8000 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. The shadow screen (on both), spare memory left over from the shadow screen (on the BBC B+) and the private workspace ram (on the Masters). Given an address in the format EFssss, the MDUMP command will dump this memory. That is: Ý{*} the shadow screen at EF3000 to EF7FFF Ý{*} the spare sideways ram at EF8000 to EFAFFF on the BBC B+ Ý{*} the MOS workspace ram at EF8000 to EF8FFF on the Masters Ý{*} the filing system ram at EFC000 to EFDFFF on the Masters All this is summed up in table I. ÝAddress BBC B BBC B+ Master Ý----------------------------------------- Ý000000 Normal language memory, ie main memory Ý to if no second processor, second ÝEEFFFF processor memory if there is. ÝEF0000 Ý to Main I/O processor memory ÝEF2FFF ÝEF3000 Shadow Shadow Ý to Main screen screen ÝEF7FFF memory memory memory ÝEF8000 Sideways Spare MOS and Ý to ROM#15 sideways VDU ÝEF8FFF memory memory workspace ÝEF9000 Sideways Spare Sideways Ý to ROM#15 sideways ROM#15 ÝEFAFFF memory memory memory ÝEFB000 Sideways Sideways Sideways Ý to ROM#15 ROM#15 ROM#15 ÝEFBFFF memory memory memory ÝEFC000 Filing Ý to MOS ROM MOS ROM system ÝEFDFFF workspace ÝEFE000 Ý to Machine Operating System ROM ÝEFFFFF (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 Ý Table I ÝThis program has been tested on BBC Micros on all operating systems from 1.20 onwards, and with DFSs 1.20 and m.mm. It has also been tested with NFS 3.60. It will not work properly with NFS 3.34, as that issue ROM has a bug in the routine to return the address of the command line. If you have NFS 3.34, I seriously reccomend that you take advantage of the service offered by many companies cheaply (or freely) to upgrade to NFS 3.60. How it works ÝThe first bit of the program calls the filing system to get the address of the parameters on the command line. It then checks that the parameter 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, then the forever flag is reset, and the parameter is examined. (The forever flag is 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 the expected sytax is deviated from, then the error message 'Syntax: MDump (/+)' is given. As the first part of the program is only executed once, the program is able to use it later as variable space to save memory usage and squeeze it into 512 bytes so it will fit in the cassette buffer. ÝThe next bit of the program checks which machine it is running in (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 extra memory, 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 accesses its extra memory memory by fiddling with the ACCCON register, and acc2 is set to note this. (For an explanation of the ACCCON register, see the New Advanced User Guide, Dickens & Holmes.) Ý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.These eight bytes are printed in hexadecimal. ÝThe eight bytes are then printed in characters. Characters 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, jumps forward to prepare to loop around again. ÝIf the forever flag is not set, then a check is performed to see if the and address has been reached. This is done by macking out the bottom three bits and exclusive ORing the end address and the current address. If the addresses are the same (ignoring the bottom three bits) then the program jumps to exit. ÝAt this point 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 is being pressed, then it is acknowledged, and the program exits. ÝFollowing here are the routines used by the program. Ýget_8_bytes fetches eight bytes from memory into the buffer. First it checks if the Tube is running, and if it is, jump to the tube routine. Then, it checks the address to see if it accessing I/O memory or language memory. If the address is &EFxxxx to &FFxxxx, then I/O memory is accessed. If not, then language memory is accessed, so the next bit is skipped. ÝNext, the current ROM number is saved, and a check is made to see if the extra memory has ben flagged as existant. If not, then the bit to access it is skipped. ÝTo access the extra memory, first the ACCCON register is saved, and amended according to the memory wanted. If the memory is &EFxxxx, then the value in acc2 is used, otherwise the value in acc1. If the address is &EFxxxx, then the ROM select latch is set to 128. If the address is &F00000 onwards, then the ROM number in the low nybble of the address high byte is written to the ROM slect latch. ÝNow a loop fetches the eight bytes into the buffer. ÝAfter the bytes have been fetched, the machine is restored to what it was before. If the address was not to I/O memory, signalled by the address being &EF0000 onwards, then the routine just terminates. If there is extra memory, then ACCCON is restored. Finally the ROM select latch is restored. ÝIf the tube flag is set, then the tubeget routine is used. The first thing this does is checks if I/O memory is wanted. If it is, then it just jumps back to the get_8_bytes routine. Otherwise, the Tube system is claimed by the program using an ID number of &10. How to transfer accross the Tube is explained in the New Advanced User Guide. ÝThe final routines are just fairly ordinary I/O routines. pr_addr prints out the current 3-byte address. pr_hex prints out thA register in hex. get_hex_addr reads in a hexadecimal address from the command line to the three zero page locations pointed to by the X register on entry. Notes: 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 x.xx Ý Ý3ÝBBC Master, Ý Ý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.