Y6502 Copyright Peter Coghlan 1991-2011. See license.txt for details. This is a 6502 microprocessor simulator which implements a subset of the functions of a BBC Microcomputer on the MUSIC platform. This software can be built on the MUSIC/SP Demo system version 6.2 with FORTRAN G installed. A copy of a language rom (generally BASIC I or BASIC II for the BBC Micro) needs to be loaded into the simulator to get most use from it. This is not included here. It is possible to extract the ROM contents a real BBC Micro. Before files can be loaded into the simulator, a little fiddling is required. BBC Micro files have attributes that do not exist for ordinary MUSIC files. These consist of a load address (where the file is loaded by default in 6502 memory) and an execution address (the address the 6502 starts exection at after a file is loaded for running). The BBC Micro also keeps track of the length of files as an exact number of bytes while MUSIC can be a bit vague about this. MUSIC provides a file tag which can be used to hold up to 64 characters of extra information about a file. The simulator uses the file tag to store the BBC Micro file attributes. MUSIC originally had a TAG command but this seems to have been omitted from the MUSIC/SP Demo system. It is not a big deal to reimplement this. Until someone does, it is possible to use the ATTRIB command to view the tag on an individual file or the TAG option on the LIBRARY and DIR commands to view the tags on groups of files. To set the tag on a file, it is possible to use the TAG command available within the MUSIC editor. To do this, edit the file in question, being careful not to type anything in the full screen editing area. Give the editor command: TAG to see the existing tag associated with the file. To set a new tag give a command such as: TAG BBC FILE 00001900 00008023 00001234 RWXD The string "BBC FILE" identifies the tag to the simulator as providing BBC Micro file attributes. The first number is the load address, the second number is the execution address and the third number is the file size, all specified in hexadecimal. RWXD is the file permissions. After setting the tag, give the command: FILE to save the file with new tag and exit the editor. A copy of the BBC BASIC ROM to be loaded into the simulator would require a tag such as: BBC FILE 00008000 00008000 00004000 RWXD for the simulator to correctly load it. When writing a file from within the simulator, the required tag is automatically generated. To run the simulator, give the command: BBC at the *Go prompt. Unless a parameter is provided specifying a different file, the simulator will be started and a file called $Y65:BBCOS.HEX containing 6502 machine code in hex format will be loaded and executed. This provides hooks from the 6502 world into the BBC operating system simulation routines. If there are no problems, there should be a banner saying "BBC Computer" and a * prompt. BBC Micro OS commands can be entered at this prompt but not much will be possible until what BBC Micro folks refer to as a language is loaded. At the * prompt, give the command RUN followed by the name of the file containing a suitable language rom image such as BASICII.BBC with a suitable tag already applied. The > prompt should be displayed if BBC BASIC is successfully loaded and BBC BASIC programs can be entered, run, loaded and saved. Note that BBC BASIC loads and saves programs in a tokenised ASCII format. To interrupt the simulator, press PA1 twice and then press return, possibly twice, depending on the state the simulator was in. A short menu should appear giving the options of quitting the simulator, resetting the simulator, getting a memory dump or toggling debug mode. In debug mode, for each 6502 instruction executed, a line is printed which shows the address just executed, the 6502 instruction just executed, a disassembly of the instruction, the memory address of the instruction operand and the 6502 A, X, Y, SP registers and flags - N V B D I Z and C. (This simulator treats the BRK flag as a real flag - this is not strictly correct as the BRK flag is not maintained by a real 6502. This could lead to problems if interrupts were supported but they aren't so hopefully it won't.) It is also possible to exit the simulator by typing /CANCEL at any keyboard read prompt. No method of simulating the ESCAPE key is provided. I guess I never got around to it.