root/dos/crt0.S

Revision 0fa4369624b4637a7e36ed22e89a759031f08327, 1.3 KB (checked in by H. Peter Anvin <hpa@…>, 3 years ago)

FAT: change DOS installer to EXE; additional 32K limit fixes

Additional fixes for the 32K limits in the installers. In the case
of the DOS installer, that means changing it from COM format to EXE
format (since COM format has a 63K hard limit); retain the name
syslinux.com for user compatibility, though (DOS doesn't care what the
extension except for pathname search; if it finds an MZ EXE header it
will use it.)

With the change to EXE means having to handle more than one segment.
Since we don't have a real DOS compiler we have to wing it a bit.

Signed-off-by: H. Peter Anvin <hpa@…>

  • Property mode set to 100644
Line 
1        .code16
2
3#ifndef REGPARM
4# error "This file assumes -mregparm=3 -DREGPARM=3"
5#endif
6
7        .section ".text","ax"
8        .globl _start
9        .type _start,@function
10_start:
11        # Align the stack and make sure the high half is zero
12        andl $0xfff8,%esp
13
14        # DS, ES points to the PSP at this point
15        pushw %es               # Save PSP pointer
16        movw %cs,%ax
17        movw %ax,%ds
18        movw %ax,%es
19
20        # Clear the .bss
21        cld
22        xorl %eax,%eax
23        movw $__bss_start,%di
24        movw $__bss_end+3,%cx
25        subw %di,%cx
26        shrw $2,%cx
27        rep ; stosl
28
29        # Copy the command line into our own segment
30        popw %fs                # FS -> PSP
31        movw $_cmdline,%di
32        movzbw %fs:0x80,%cx
33        movw $0x81,%si
34        fs ; rep ; movsb
35        # Already zero-terminated since we're writing into clean bss
36
37        # Compute argc and argv (assumes REGPARM)
38        movl $_cmdline,%edx
39        pushl %eax              # Make space for argv
40        movl %esp,%eax
41        calll __parse_argv
42        pushl %eax              # argc
43
44        # Initialize malloc
45        calll __init_memory_arena
46
47        # Now call main... (NOTE: gcc forces main to be regparm 0)
48        popl %eax               # argc
49        popl %edx               # argv
50        calll main
51
52        # Here %eax is the exit code, fall through into exit
53
54        .size _start,.-_start
55
56        .globl exit
57        .type exit,@function
58exit:
59        # Exit code already in %eax
60        movb $0x4c,%ah          # Terminate program
61        int $0x21
621:      hlt
63        jmp 1b
64        .size exit,.-exit
65
66        .section ".bss","aw"
67        .balign 4
68_cmdline:
69        .space 128
70        .size _cmdline,.-_cmdline
Note: See TracBrowser for help on using the browser.