Disassembly Routines ==================== Requirements and Dependancies ============================= The routines require a global control block of at least 32 bytes in length to be accessible with X% holding the address of this block, and Y% holding X% DIV 256. This can easily be set up with DIM ctrl% 31 near the start of the program and X%=ctrl%:Y%=X%DIV256 at the begining of the major program code and at the start of any main program loop. The FNh0() function from the Number library is required. Routine Summary =============== FNDis_Name() - returns CPU name for supplied CPU number FNDis_Code() - disassemble the supplied code CPU Name and check for presence =============================== DEFFNDis_Name(cpu%) FNDis_Name() returns the name of the supplied cpu number. If the returned string is "", then that CPU number is not recognised. X%+3 also returns the following information: b0-b1: CPU address width, 0=16, 1=24, 2=32 b2-b3: CPU data width, 0=bytes, 1=16-bit words, 2=32-bit words b4-b5: Typical maximum instruction length-3, 3,4,5,6 bytes b6: b7: Disassembly base, 0=hex, 1=octal Disassemble code ================ DEFFNDis_Code(cpu%, addr%, data%) Disassembles a block of code. On entry, cpu% is the CPU number, addr% is the address to assume this code resides at, and data% points to the actual code. Returns the control block at X% containing: X%?2 - disassembly flags, b7=unrecognised, b6=unconditional jump X%?3 - number of bytes disassembled $(X%+4) - text string of disassembled code The number of bytes disassembled is also returned from the function call. Sample Code =========== The following is a very simple piece of code that will give a 6502 disassembly listing. DIM ctrl% 31:X%=ctrl%:Y%=X%DIV256 INPUT "Start address: &"A$:addr%=EVAL("&"+A$) REPEAT num%=FNDis_Code(65,addr%,addr%) PRINT $(X%+4) addr%=addr%+num% UNTIL FALSE