Knowing that no RAM address is supposed to be read before being initialized, is it really necessary to clear the entire RAM during the startup instead of simply initializing the used RAM addresses at the proper moment?
The same is supposed for CPU registers.
Clearing the RAM really needed?
Moderator: BigEvilCorporation
Re: Clearing the RAM really needed?
No, and given you're going to explicitly reinitialize all variables anyway (e.g. what happens when you get a game over? the game will reset to the title screen but RAM won't be clear!), it's pretty pointless in practice. It only encourages lazy programming practices =P
What could help during debugging is maybe filling it with something like 0xDEADBEEF, then when you try to touch uninitialized RAM at least it's easier to see with a debugger. But that's it, really.
What could help during debugging is maybe filling it with something like 0xDEADBEEF, then when you try to touch uninitialized RAM at least it's easier to see with a debugger. But that's it, really.
Sik is pronounced as "seek", not as "sick".
-
- Very interested
- Posts: 209
- Joined: Sat Sep 08, 2012 10:41 am
- Contact:
Re: Clearing the RAM really needed?
For me it was just an educational exercise when I was learning, and one that doesn't require any of the other chips to be initialised first. It was an indication that something was working, and a small block of code demonstrating some basic 68000 concepts like moves, loops, and labels.
The 0xDEADBEEF trick is used in software development all over the place, custom allocators in C/C++ can write this value to freed blocks to help catch bad writes, etc. I'm sure there's some advantages to it in ASM somewhere.
A better use of your time would be to learn how to write a custom exception handler. A basic one just needs a hard coded font with the chars 0123456789ADCDEF and a way to display the exception type ID and registers.
The 0xDEADBEEF trick is used in software development all over the place, custom allocators in C/C++ can write this value to freed blocks to help catch bad writes, etc. I'm sure there's some advantages to it in ASM somewhere.
A better use of your time would be to learn how to write a custom exception handler. A basic one just needs a hard coded font with the chars 0123456789ADCDEF and a way to display the exception type ID and registers.
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Re: Clearing the RAM really needed?
I would say it is a good practice to clear out the RAM with a known value. I have been teaching a friend MD programming and half the time he forgets to initialize his variables and then things fail to run on the hardware.
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Re: Clearing the RAM really needed?
its not necessary at the least, but you save yourself a lot of unnecessary headache by clearing the RAM anyway.
Re: Clearing the RAM really needed?
RAM/VRAM clearing is not necessary, but initializing variables/memory is necessary. By default whole memory is filled by some trash, except if you run code after TMSS