BMOW title
Floppy Emu banner

6502 Inspiration

The design of my machine has been significantly influenced by the 6502, the microprocessor used in most 80’s home computers, and the one with which I’m most familiar. There are no published descriptions of the 6502 internals that I know of, however. The documentation describes the instruction set interface, not how those instructions are implemented.Still, I was able to infer a lot from the nature of the 6502 instruction set and addressing modes, and the known clock cycle requirements for the various instructions. I plan to have an instruction set very similar to the 6502’s, to make it as easy as possible to port code. That may seem uncreative or like cheating to some, but I don’t see a good reason for inventing my own oddball instruction names, conventions, and assembler syntax just for the sake of being different. So where possible, I’ll make instructions that look and act like their 6502 counterparts.

I also plan to support at least these addressing modes:

Mode Example Description
implied INX operand implied
absolute LDA $HHLL operand is address $HHLL
absolute, X-indexed LDA $HHLL,X operand is address incremented by X with carry
immediate LDA #$BB operand is byte (BB)
indirect LDA ($HHLL) operand is effective address; effective address is value of address
PC-relative BEQ $BB branch target is PC + offset (BB), bit 7 signifies negative offset
stack-relative, X-indexed LDA SP,X operand address is stack base incremented by X with carry

All but stack-relative addressing mode are from the 6502.

Despite the similarities in instruction set and addressing modes, my machine will be inferior to the 6502 in that it lacks a Y register, zero-page addressing, decimal mode, interrupts, and the capability to set the stack pointer and push the condition code flags on the stack, among others. On the other hand, it will be superior to the 6502 in that it provides a full 16-bit stack pointer (the 6502 has an 8-bit SP) and stack-relative addressing mode, which I see as a necessity for implementing programs in languages like C.

I’ve worked out the microcode and timing for a handful of sample instructions, using my proposed microarchitecture design. Here’s how I stack up against the 6502. Where two numbers are shown, the larger number is for the case where a page boundary (256 bytes) is crossed while doing address arithmetic.

Instruction Description 6502 clock cycles My clock cycles
ADC add with carry, immediate 2 2
JMP jump to absolute address 3 4
BMI branch if minus 3/4 4/5
INC increment memory, absolute, X-indexed 7 7/8
PHA push accumulator onto stack 3 2
JSR jump to subroutine, absolute 6 8
RTS return from subroutine 6 6
LSR logical shift right 1 bit, implied 2 9
LDA load accumulator, stack-relative, X-indexed N/A 4
Be the first to comment! 

No comments yet. Be the first.

Leave a reply. For customer support issues, please use the Customer Support link instead of writing comments.