2016-10-02 18:58:05 +00:00
|
|
|
! plat/osx386/boot.s
|
|
|
|
|
|
|
|
! Declare segments (the order is important).
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
.sect .rom
|
|
|
|
.sect .data
|
|
|
|
.sect .bss
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
|
|
|
|
begtext:
|
|
|
|
! This code is placed at the entry point of the Mach-o
|
|
|
|
! executable and is the first thing that runs.
|
|
|
|
!
|
|
|
|
! 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
|
2016-11-08 20:22:09 +00:00
|
|
|
|
2016-10-02 18:58:05 +00:00
|
|
|
mov eax, (esp) ! eax = argc
|
|
|
|
lea ebx, 4(esp) ! ebx = argv
|
|
|
|
lea ecx, (esp)(eax*4)
|
|
|
|
add ecx, 12 ! environ
|
2016-11-08 20:22:09 +00:00
|
|
|
|
2016-10-02 18:58:05 +00:00
|
|
|
push ecx ! environ
|
|
|
|
push ebx ! argc
|
|
|
|
push eax ! argv
|
|
|
|
push eax ! dummy, representing the return argument
|
|
|
|
xor ebp, ebp
|
2016-11-08 20:22:09 +00:00
|
|
|
|
2016-10-02 18:58:05 +00:00
|
|
|
jmp __m_a_i_n
|
2016-11-08 20:22:09 +00:00
|
|
|
|
2016-10-02 18:58:05 +00:00
|
|
|
! This provides an emergency exit routine used by EM.
|
2016-11-08 20:22:09 +00:00
|
|
|
|
2016-10-02 18:58:05 +00:00
|
|
|
.define EXIT
|
|
|
|
.extern EXIT
|
|
|
|
EXIT:
|
|
|
|
push 1
|
|
|
|
jmp __exit
|
2016-11-08 20:22:09 +00:00
|
|
|
|
2016-10-02 18:58:05 +00:00
|
|
|
.sect rom
|
|
|
|
begrom:
|
|
|
|
|
|
|
|
.sect .data
|
|
|
|
begdata:
|
|
|
|
|
|
|
|
! Some magic data. All EM systems need these.
|
|
|
|
|
|
|
|
.sect .bss
|
|
|
|
begbss:
|
|
|
|
.define hol0
|
|
|
|
.comm hol0, 8 ! line number and filename (for debugging)
|
|
|
|
|
|
|
|
.define _errno
|
|
|
|
.comm _errno, 4 ! Posix errno storage
|
|
|
|
|
|
|
|
.define .trppc, .ignmask
|
|
|
|
.comm .trppc, 4 ! ptr to user trap handler
|
2016-11-08 20:22:09 +00:00
|
|
|
.comm .ignmask, 4 ! user trap ignore mask
|