2007-04-21 23:02:11 +00:00
|
|
|
#
|
|
|
|
! $Source$
|
|
|
|
! $State$
|
|
|
|
! $Revision$
|
|
|
|
|
|
|
|
! Declare segments (the order is important).
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
.sect .rom
|
|
|
|
.sect .data
|
|
|
|
.sect .bss
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
|
|
|
|
begtext:
|
|
|
|
! This code is placed at the beginning of the ELF executable and is the
|
|
|
|
! first thing that runs.
|
2007-04-23 23:24:03 +00:00
|
|
|
!
|
|
|
|
! On entry, the stack looks like this:
|
|
|
|
!
|
|
|
|
! sp+.. NULL
|
|
|
|
! sp+8+(4*argc) env (X quads)
|
|
|
|
! sp+4+(4*argc) NULL
|
|
|
|
! sp+4 argv (argc quads)
|
|
|
|
! sp argc
|
|
|
|
!
|
|
|
|
! The ACK actually expects:
|
|
|
|
!
|
|
|
|
! sp+8 argc
|
|
|
|
! sp+4 argv
|
|
|
|
! sp env
|
|
|
|
|
|
|
|
mov eax, (esp) ! eax = argc
|
|
|
|
lea ebx, 4(esp) ! ebx = argv
|
|
|
|
lea ecx, (esp)(eax*4)
|
|
|
|
add ecx, 12 ! environ
|
|
|
|
|
|
|
|
push ecx ! environ
|
|
|
|
push ebx ! argc
|
|
|
|
push eax ! argv
|
|
|
|
push eax ! dummy, representing the return argument
|
|
|
|
xor ebp, ebp
|
|
|
|
|
2007-04-21 23:02:11 +00:00
|
|
|
jmp __m_a_i_n
|
|
|
|
|
|
|
|
! This provides an emergency exit routine used by EM.
|
|
|
|
|
|
|
|
.define EXIT
|
|
|
|
.extern EXIT
|
|
|
|
EXIT:
|
|
|
|
push 1
|
|
|
|
jmp __exit
|
|
|
|
|
|
|
|
! Define symbols at the beginning of our various segments, so that we can find
|
|
|
|
! them. (Except .text, which has already been done.)
|
|
|
|
|
|
|
|
.sect .data; begdata:
|
|
|
|
.sect .rom; begrom:
|
|
|
|
.sect .bss; begbss:
|
|
|
|
|
|
|
|
! Some magic data. All EM systems need these.
|
|
|
|
|
2007-04-24 19:25:00 +00:00
|
|
|
.define .trppc, .ignmask, _errno
|
2007-04-21 23:02:11 +00:00
|
|
|
.comm .trppc, 4
|
|
|
|
.comm .ignmask, 4
|
2007-04-24 19:25:00 +00:00
|
|
|
.comm _errno, 4
|