On Sun 22 Apr 2012 at 17:49:49 +0200, davee.roberts@fsmail.net wrote: > I can't see why the BASIC POKE command (using an STA instruction) > should invoke a memory read from the 6702 though? One of the functions It isn't the STA but the addressing mode (zp),Y that does it. During the execution of instructions, bus cycles happen and whatever is on the address bus gets read (and ignored). One of the little corners being cut by yhe 6502. In this case it will be an incomplete addition of the value read from zp and the Y register. The 6809 would put $FFFF on the address bus for these (/VMA) cycles. In VICE it is this code, I think: #define STA_IND_Y(addr) \ do { \ unsigned int tmp; \ \ CLK_ADD(CLK,2); \ tmp = LOAD_ZERO_ADDR(addr); \ LOAD_IND((tmp & 0xff00) | ((tmp + reg_y) & 0xff)); \ CLK_ADD(CLK,CLK_IND_Y_W); \ INC_PC(2); \ STORE_IND(tmp + reg_y, reg_a_read); \ } while (0) (load instructions only do this extra read if there is an actual carry from the addition; I'm not sure why store instructions always do it). > Just one minor observation on your BASIC program. I would suggest the > use of integer variables (e.g. a% = peek(q%) etc.) rather than the > default floating point variables. You should be OK however using pure > integers in a floating point environment - it would rule out one > potential source of error. I seem to recall that the Basic converts integer variables to floating point before any calculation. (I just checked a ROM listing (for the 64, but that doesn't matter)). So what would happen is that the 2 integer variables get converted to floating point, the AND routine would convert them to integer, perform the AND (the same code performs OR by application of De Morgan (NOT being done by EOR with $FF or $00)) (see here http://unusedino.de/ec64/technical/misc/c64/romlisting.html#AFE6). Then, NOT would convert it to FP, and then the LET command would convert back into integer to store it (http://unusedino.de/ec64/technical/misc/c64/romlisting.html#A9A5). I suppose we may "thank" Bill Gates for this inefficiency. One annoying thing with the conversion is that the integers are signed. First I tried to get the low byte of the result of the multiplication by "D AND 255" but that failed once D was over 32767. > Dave -Olaf. -- ___ Olaf 'Rhialto' Seibert -- There's no point being grown-up if you \X/ rhialto/at/xs4all.nl -- can't be childish sometimes. -The 4th Doctor Message was sent through the cbm-hackers mailing listReceived on 2012-04-22 23:00:04
Archive generated by hypermail 2.2.0.