6502 Register Display
Files: 6502Reg - BASIC
Most people with an interest in programming the BBC microcomputer, will at some stage explore the fascinating world of machine code. In order to facilitate this excursion from BASIC the following program was written to help those new to the subject. Its purpose is to display the Accumulator, X, Y and Processor Status registers of the 6502, in decimal, hexadecimal and binary.
The main feature however, is its ability to show how registers change and flags are effected after running a test procedure. 'Flags' is the name given to particular bits of a register which are used to indicate various conditions or values.
A visual interpretation of the registers in this way gives a distinctive picture of what is actually happening within the processor after instructions have been executed, thus a better understanding of part of the internal workings of the processor can be realised.
The program is straight forward, in as much as, when the required data has been intercepted at line 1040, it is then displayed on the screen.
Each time a new number is entered the test routine at lines 170-220 is called by USR(Address). This call is used in much the same way as CALL(Address), however USR(Address) returns the last values of the A, X, Y & P registers in a variable assigned to it, e.g (!regs%).
The variable No% is used to supply the machine code routine with the number to be used within the routine.
As long as you use the above mentioned variables to communicate data to a test routine, you can experiment and see what happens to the 6502's registers, especially the processor status register, as a program is run.
Enter the following numbers and observe the effects with the routine contained in the program as listed. Note, each time you enter a new number the whole program is re-run.
Thus;
Entering 156 A=0 : Zero flag=1 : Carry flag=1.
Entering 157 A=1 : Zero flag=0 : Carry flag=1.
Entering 155 A=255 : Negative flag=1.
Now try entering your own completely new routine between lines 160 and 1000, then watch the effects.