Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Harvey ! (Registered 2024-11-25) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > The mistery of $00/$01 ram bytes and the ghost value.
2014-03-13 11:32
Flavioweb

Registered: Nov 2011
Posts: 463
The mistery of $00/$01 ram bytes and the ghost value.

As asked by Groepaz, here is the splitted thread about this story.
What's the point?
The question is that this code:
.> c000 a9 7f lda #$7f
.> c002 cd 12 d0 cmp $d012 
.> c005 d0 fb bne $c002 
.> c007 ad 11 d0 lda $d011 
.> c00a 10 fb bpl $c007 
.> c00c a5 01 lda $01 
.> c00e a0 e0 ldy #$e0 
.> c010 8c ff 3f sty $3fff 
.> c013 85 01 sta $01 
.> c015 a5 01 lda $01 
.> c017 ad 00 de ldx $de00
.> c01a 60 rts

write and then read value "$e0" from RAM lication $01 (not from internal cpu "register"!) reading it from an "unconnected" ram location (as $de00 is), just after a "regular" access to $01 by the cpu.
The first big part of the mistery is that i supposed that value coming from $01 ram was "parked" on the bus, since cpu when access "internal" $01 setup anyway the bus to read from ram, but without really access it.
As pointed out in the other thread, before a LDX $DE00 can access the bus to read the value contained into ram $01, at least 3 bytes go throught the bus: the opcode LDX, a 00 and a DE.
But at the end of execution, we have the value "$E0", as supposed to be, in .X.
So... where this value come from?
And again.
If we try to write into $01, "directly" without use the "idle vic access"/$01 write trick, no value is stored into ram $01.
Why we need vic to do that?
For eg:
SEI
LDA $01
LDX #$E0
STA $01
STX $DE00
CLI
RTS

don't store anything in ram $01.
Groepaz says that into an issue of C=hacking on codebase the question is explained as well... but i looked for infos without success.
Someone of you can explain me what kind of magic is this?
2014-03-13 12:55
lft

Registered: Jul 2007
Posts: 369
The $e0 is still at $3fff, so VIC fetches this byte at every half cycle. Including the half cycles between operand fetches and the read from $de00. You are not reading from $01, you are reading the idle byte (which happens to hold the same value as $0001 does).

Hope this clears things up.
2014-03-13 13:59
Oswald

Registered: Apr 2002
Posts: 5086
that makes sense. the C= Hacking article suggests using sprite collision for reading, for writing the method is the same there, however I have my doubts its working, as VICII always performs read accesses, why would it let both the bus address and R/W line alone, even in an idle read ? an idle read must set bus to read and address to 3fff.
2014-03-13 14:33
Flavioweb

Registered: Nov 2011
Posts: 463
YES!
Now make sense.
Now i have to understand why value in $3FFF is written to $01.
2014-03-13 16:27
Oswald

Registered: Apr 2002
Posts: 5086
Quote: YES!
Now make sense.
Now i have to understand why value in $3FFF is written to $01.


you should check atleast visually $01 to make sure the write happens. not sure maybe you did that already.
2014-03-13 16:29
chatGPZ

Registered: Dec 2001
Posts: 11354
didnt i post the test program that does all that before? it works, really :)
2014-03-14 16:32
Fresh

Registered: Jan 2005
Posts: 101
When the cpu writes to addresses 0/1, it sets R/W to low (write), it correctly sets the address lines ($0000/$0001) BUT it sets the data register to tri-state (font: vic article - it clearly makes sense, because it needs to route the data register bus to its internal I/O ports).
But also the VIC lines are in tri-state, because the video chip is in idle, so the data bus is just floating or, as it often happens in c64 world, it's somehow keeping the last levels. Those levels depend on the last half cycle, during which the VIC has read its own stuff.
Now, as mentioned before, R/W line and address bus are correctly set, so the stuff on the floating data bus - VIC latest read - happily goes to the memory chip.
2014-03-14 16:50
chatGPZ

Registered: Dec 2001
Posts: 11354
Quote:
it's somehow keeping the last levels.

well, not "somehow" of course, there is no magic involved - it is parasitic capacitance of the bus and the i/o driver stages. the same phenomena that also eg lets you read back the value from readonly SID registers.
2014-03-14 18:49
Flavioweb

Registered: Nov 2011
Posts: 463
Quoting Groepaz
readonly SID registers.

Writeonly...
gotcha!

Rotfl... just kiddin' eh... =)

Now my mind goes around thinking how can happen if i write to, for eg, $DE00 in the middle of some Vic-half-cycles...

...shame that i have never coded a FLI routine...
=P
2014-03-14 18:56
chatGPZ

Registered: Dec 2001
Posts: 11354
Quote:

Writeonly...
gotcha!

oooops =D

as for open i/o... again in c=hacking you can find an article by marko m. where he runs a "program" located at $de00, that one gives some more answers on the behaviour of this stuff.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
CA$H/TRiAD
Brittle/Dentifrice^(?)
A3/AFL
csabanw
Alakran_64
Røly/Mayday!
Knight Rider/TREX
Guests online: 106
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 The Demo Coder  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Wonderland XIV  (9.6)
10 Comaland 100%  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Libertongo  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Morph  (9.5)
9 Dawnfall V1.1  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Nostalgia  (9.3)
5 Censor Design  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.7)
2 Fungus  (9.3)
3 Black Beard  (9.2)
4 Baracuda  (9.2)
5 hedning  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.052 sec.