The final stage is to call the main program. In this simple
implementation there is no mechanism to pass arguments or
environments to main
, so the arguments
argc
, argv
and
env
(in r3
,
r4
and r5
) are set to
0
, NULL
and
NULL
respectively.
l.or r3,r0,r0 l.or r4,r0,r0 l.jal _main l.or r5,r0,r0 /* Delay slot */
If the main program returns, its result (held in
r11
on the OpenRISC 1000 ) will be a return code from
the program, which we pass to the exit
.
l.jal _exit l.addi r3,r11,0 /* Delay slot */
exit
should not return, but just in case, we
can put the processor in a tight loop at this stage, in order to
ensure consistent behavior.
.L2: l.j .L2 l.nop