Re: [cc65-devel] HuC6280 zero-page addressing problem.
cc65 - a freeware C compiler for 6502 based systems
Brought to you by:
gpz
|
From: Greg K. <gr...@us...> - 2016-06-24 04:54:19
|
On 2016-06-23 2:29 PM, John Brandwood wrote: > Re: [cc65-devel] HuC6280 zero-page addressing problem. > From: groepaz -- 2016-06-22 23:11:53 >> >> I still think it'd be weird if the assembler assembles "lda $2000" into a >> two-byte instruction, however -- you should be writing "lda $00" instead; and, >> treat the first RAM page as actual zeropage; what speaks against it anyway? > > So, you think that I should write $0000 when I really mean $2000??? > That's a very strange suggestion, IMHO. > > Here's an example of the problem in the real-world. > There are specific locations that are used by Hudson's CD System Card BIOS. > > _ax = $20F8 > _al = $20F8 > _ah = $20F9 > > Those are meant to be used with direct-page/zero-page addressing. > So, let's say that I do decide to lie, just to make CA65 happy, and change > those to: > > _ax = $00F8 > _al = $00F8 > _ah = $00F9 > > What happens when I put the address of one of those variables into a pointer; > or, if I use an instruction that doesn't support 1-byte addressing? > They'll end up pointing to the wrong locations! That's madness! > > Similarly, let's say that I want to write to location $0000, which is where > the VDC chip normally is mapped. > > VDC_CTRL = $0000 > VDC_DATA_LO = $0002 > VDC_DATA_HI = $0003 > > Suddenly, CA65 is generating a 1-byte addressing instruction; and, the write > actually is going to $2000. Again, madness! > > The current solution for them is to add "<" or "a:" address-overrides to > every instruction, in order to generate the proper code. > That's ugly, and shouldn't be needed IMHO; but, you guys might disagree. The video chip problem is easy to fix: Use I/O mirror locations. VDC_CTRL := $0200 VDC_DATA := $0202 > > Isn't the point of computers that they actually should do things right? > Don't you want CA65 to work in a way that matches the reality of the > actual processor? > If you expand your thinking of the concept of 1-byte addressing into > something that's referring to the direct-page rather than just the > zero-page, then you'll have no problem matching your current notions > of what's correct to the actual reality of the situation. That issue is important for the Commodore 128 and the 65816 CPU also. My thought is a directive, similar to .ORG, that tells ca65 where the direct page currently is. When ca65 sees an address constant operand, it checks the mnemonic. If that instruction allows the direct-page addressing mode, and the constant is in the 256-byte range of the directive, then it is changed into a "zero-page" address. |