Comment by gblargg
5 days ago
> with just the 65C816, the register modes (8 or 16) bit can be a challenge to work with. When working on the PANCAKE-ROM project, I got bit by mixing up what mode the CPU was in while writing some memory locations. The memory manipulation was assumed to be in 16 bit mode, but it was 8 bit. The 65C832 makes this even more rough.
I've done a little 65816 coding and I quickly learned that it was best to standardize on register sizes throughout most of the code and for routine calls, only switching to optimize things. 8-bit A and 16-bit X and Y made the most sense by far for small-scale asm code. It let you work in 8 bits when dealing with registers and using common 8-bit variables, while being able to loop over larger data structures with X and Y as memory addresses and counters, and also manipulate 16-bit values to some degree (copying, incrementing/decrementing).
Other common CPUs of the time instead either had different registers names for different sizes (80x86), or coded the size in the instruction (68000). This avoided the mode bits and issues with code written for different modes (which even affected instruction length of the 65816 when using immediate data).
No comments yet
Contribute on Hacker News ↗