EmbeddedRelated.com
Forums

why use assembly in mmu initialization?

Started by yuny...@gmail.com March 30, 2007
I am learning a bootloader code, can some please tell me why mmu
initialization must be implemented in assambly instead of c?

On Mar 30, 5:41 am, "yunyua...@gmail.com" <yunyua...@gmail.com> wrote:

> I am learning a bootloader code, can some please tell me why mmu > initialization must be implemented in assambly instead of c?
The initialization may require special opcodes, or access special registers which can't be done in standard C. Or perhaps you want to be sure that the stack isn't used, which can be hard to guarantee in C.
Arlet wrote:
> On Mar 30, 5:41 am, "yunyua...@gmail.com" <yunyua...@gmail.com> wrote: > > >>I am learning a bootloader code, can some please tell me why mmu >>initialization must be implemented in assambly instead of c? > > > The initialization may require special opcodes, or access special > registers which can't be done in standard C. Or perhaps you want to be > sure that the stack isn't used, which can be hard to guarantee in C. >
C runtime startup often inits the stack pointer first, then clears rw memory, all of which may be inaccessable until the mmu is setup... Chris
In article <1175226087.068901.171870@p15g2000hsd.googlegroups.com>, 
"yunyuaner@gmail.com" <yunyuaner@gmail.com> writes
>I am learning a bootloader code, can some please tell me why mmu >initialization must be implemented in assambly instead of c? >
In a self hosted system Or where you are running the code from a hardware reset NOTHING is set up. No registers, memory spaces, interrupts, watchdogs or stack. Before you get to the start of the C code* which requires a stack (most of the time) and to know where it's memory spaces are for initialised and uninitialised variables globals etc. you have to set it up. You can't do thins in C (see recursion :-) BTW in a self hosted system the fist C function, called "main" in hosted systems does not have to be called "main" in self hosted systems but usually is by tradition -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ /\/\/ chris@phaedsys.org www.phaedsys.org \/\/\ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
On 3=D4=C230=C8=D5, =CF=C2=CE=E75=CA=B128=B7=D6, Chris Hills <c...@phaedsys=
.org> wrote:
> In article <1175226087.068901.171...@p15g2000hsd.googlegroups.com>, > "yunyua...@gmail.com" <yunyua...@gmail.com> writes > > >I am learning a bootloader code, can some please tell me why mmu > >initialization must be implemented in assambly instead of c? > > In a self hosted system Or where you are running the code from a > hardware reset NOTHING is set up. No registers, memory spaces, > interrupts, watchdogs or stack. > > Before you get to the start of the C code* which requires a stack (most > of the time) and to know where it's memory spaces are for initialised > and uninitialised variables globals etc. you have to set it up. You > can't do thins in C (see recursion :-) > > BTW in a self hosted system the fist C function, called "main" in hosted > systems does not have to be called "main" in self hosted systems but > usually is by tradition > > -- > \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ > /\/\/ c...@phaedsys.org www.phaedsys.org\/\/\ > \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Thank you :-)