MBR / Bytes to Code Space

Hi,

When a computer is booted, Code is loaded from some external source. i.e. MBR. Right now, The code is being loaded from a 62256. I would like to be able to run code off a Disk, roll my own MBR and be able to run small programs off the disk.

P.S. Is there any way of doing it in C?

Thinking... Has to be addressable to retrieve bytes at different addresses. 32K SRAM So, the maximum Size of the program would have to be < 32K. Could this be expanded? < 32K programs, but multiple programs on disk.

Thanks for your help,

Reply to
Christopher J. Holland
Loading thread data ...

Not really directly from the MBR. In a PC, as the CPU is actually booted, it reads code from an EPROM or nowadays a flash memory, called the BIOS, at the fixed address designed by the CPU makers.

That code initializes all kinds of hardware, including the harddisks.

Only then it issues requests to the hard disk controller to read the MBR of the primary HD (if any) into main memory, and jumps to it.

Note that since you didn't even mention what CPU you're talking about, this could be completely different in your case.

Then you'll have to put code into that 62256 that knows how to handle the disk drive you have attached (how?), and you'll need some RAM mapped as executable code memory to copy code to from the disk, and execute it. You quite definitely can't run code directly off the disk drive.

Yes; for at least some definitions of the term "C" ;-)

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

Speed is not the issue. The CPU can't even *see* that code, much less execute it, while it's still on the disk. It can do that no better than you can read a book (the old-fashioned, dead-tree kind) sitting on its shelf in the city library while you're sitting at home. You have to go and get it, first.

As long as you're attaching it as a hard disk work-alike, it doesn't matter what it physically is --- it's not memory the CPU could execute code from.

Using an 8051 with no external memory attached, odds are you won't even be able to talk to a CF car. (Simulated) disk sectors are 512 Bytes, which is larger than the internal RAM, for starters.

An 8051 makes this even more interesting, because that's a Harvard architecture, meaning it cannot usually execute code sitting in writable ("data") memory, either. You have to wire RAM chip select specially to allow the bytes found in there to be executed as code.

Summing this all up, do yourself a favour: get a beginners' level textbook on microcontrollers from aforementioned city library.

[And BTW, please don't toppost, and don't claim you're snipped-for-privacy@microsoft.com, which quite obviously you are not.].
--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

I do this to prevent unwanted Junk Mail. Perhaps MS has more resources to confront junk mail than I do?

You don't have to read the whole 512 bytes, you can read a single byte. Do yourself a favor and read the book, preferably a basic beginners book :|~ Hard Drives for Dummies :D

From another posting, I found out that the 8051 has no instruction to load code from another source.

I was just curious about the transiti>

Reply to
Christopher J. Holland

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.