4

At least running VICE 2.4:

PRINT PEEK(53280)
 254

POKE 53280,14

PRINT PEEK(53280)
 254

It's clear that only bits #0-#3 are used, and that the "correct" value is obtained with AND 15, but why does the 6510 set the upper bits to 1?

Cactus
  • 27,075
  • 9
  • 69
  • 149
youri
  • 3,685
  • 5
  • 23
  • 43

1 Answers1

5

The 6510 CPU doesn't set the unused higher bits to 1; rather, there is no memory backing the higher bits in the appropriate VIC registers. So what happens is that the CPU puts whatever 8-bit value on the data bus when writing, but the VIC chip only stores the lower 4 bits; then later, when the CPU tries to read from that address, it puts 53280 on the address bus, and the VIC chip needs to put all 8 bits on the data bus. But it has only stored the lower 4 bits; the higher 4 bits will need to be faked up as 1.

Of course, it could also pick other fake values for these extra bits (e.g. it could use all 0s); the point is, it has to be a fixed value, since the real 4 bits were never stored anywhere.

Cactus
  • 27,075
  • 9
  • 69
  • 149
  • Thank you. Yet there must be a reason why it's `1` by design and not more conveniently `0`... maybe some hardware optimization, unless that was purely a "random" design choice. – youri Sep 05 '16 at 07:26
  • 1
    I can't speak for nMOS, but TTL typically reads any un-connected input as a positive voltage, or a 1 bit. This was an artefact of the asymmetric way the transistors were arranged at the input. I forget the details, but a quick search suggests that TTL input was either 'pulled to ground' (0) or 'not pulled to ground' (1) so it stands to reason that when nothing is connected the default answer is 1 (it may also be that the most power-efficient answer is 1). It's possible that nMOS used an analogous FET arrangement... but I do not know. – sh1 Nov 21 '16 at 19:31