Module Name: src Committed By: maxv Date: Sun Dec 4 08:21:08 UTC 2016
Modified Files: src/sys/arch/i386/stand/lib: biosmem.S biosmemps2.S biosmemx.S exec.c multiboot.S startprog.S Log Message: KNF and explain a few things To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/lib/biosmem.S \ src/sys/arch/i386/stand/lib/biosmemx.S cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/lib/biosmemps2.S cvs rdiff -u -r1.61 -r1.62 src/sys/arch/i386/stand/lib/exec.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/lib/multiboot.S cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/lib/startprog.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/i386/stand/lib/biosmem.S diff -u src/sys/arch/i386/stand/lib/biosmem.S:1.9 src/sys/arch/i386/stand/lib/biosmem.S:1.10 --- src/sys/arch/i386/stand/lib/biosmem.S:1.9 Thu Jun 16 13:27:59 2011 +++ src/sys/arch/i386/stand/lib/biosmem.S Sun Dec 4 08:21:08 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: biosmem.S,v 1.9 2011/06/16 13:27:59 joerg Exp $ */ +/* $NetBSD: biosmem.S,v 1.10 2016/12/04 08:21:08 maxv Exp $ */ /* * Copyright (c) 1996 @@ -36,8 +36,9 @@ .text -/* get mem below 1M, in kByte */ - +/* + * Get mem below 1M, in kByte. + */ ENTRY(getbasemem) pusha @@ -45,18 +46,19 @@ ENTRY(getbasemem) .code16 int $0x12 - # zero-extend 16-bit result to 32 bits. - movzwl %ax, %eax + /* Zero-extend 16-bit result to 32 bits */ + movzwl %ax,%eax calll _C_LABEL(real_to_prot) .code32 - movl %eax, 28(%esp) + movl %eax,28(%esp) popa ret -/* get mem above 1M, in kByte */ - +/* + * Get mem above 1M, in kByte. + */ ENTRY(getextmem1) pusha @@ -66,13 +68,13 @@ ENTRY(getextmem1) movb $0x88,%ah int $0x15 - # zero-extend 16-bit result to 32 bits. - movzwl %ax, %eax + /* Zero-extend 16-bit result to 32 bits */ + movzwl %ax,%eax calll _C_LABEL(real_to_prot) .code32 - movl %eax, 28(%esp) + movl %eax,28(%esp) popa ret Index: src/sys/arch/i386/stand/lib/biosmemx.S diff -u src/sys/arch/i386/stand/lib/biosmemx.S:1.9 src/sys/arch/i386/stand/lib/biosmemx.S:1.10 --- src/sys/arch/i386/stand/lib/biosmemx.S:1.9 Tue Oct 14 14:18:11 2008 +++ src/sys/arch/i386/stand/lib/biosmemx.S Sun Dec 4 08:21:08 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: biosmemx.S,v 1.9 2008/10/14 14:18:11 ad Exp $ */ +/* $NetBSD: biosmemx.S,v 1.10 2016/12/04 08:21:08 maxv Exp $ */ /* * Copyright (c) 1997, 1999 @@ -30,11 +30,13 @@ .text -/* int getextmem2(int buffer[2]) - return: 0=OK, -1=error - buffer[0]: extmem kBytes below 16M (max 15M/1024) - buffer[1]: extmem above 16M, in 64k units -*/ +/* + * int getextmem2(int buffer[2]) + * + * return: 0=OK, -1=error + * buffer[0]: extmem kBytes below 16M (max 15M/1024) + * buffer[1]: extmem above 16M, in 64k units + */ ENTRY(getextmem2) pushl %ebp movl %esp,%ebp @@ -47,16 +49,16 @@ ENTRY(getextmem2) call _C_LABEL(prot_to_real) .code16 - xorl %ebx, %ebx - movl $0xe801, %eax + xorl %ebx,%ebx + movl $0xe801,%eax int $0x15 pushf - movw %si, %ax - orw %si, %bx + movw %si,%ax + orw %si,%bx jz 1f /* if zero use configured values */ - movw %cx, %ax /* k below 16M (max 0x3c00 = 15MB) */ - movw %dx, %bx /* 64k above 16M */ + movw %cx,%ax /* k below 16M (max 0x3c00 = 15MB) */ + movw %dx,%bx /* 64k above 16M */ 1: popf setc %bl @@ -64,13 +66,13 @@ ENTRY(getextmem2) calll _C_LABEL(real_to_prot) .code32 - movl 8(%ebp), %edi - xorl %eax, %eax - movw %cx, %ax + movl 8(%ebp),%edi + xorl %eax,%eax + movw %cx,%ax stosl - movw %dx, %ax + movw %dx,%ax stosl - movb %bl, %al + movb %bl,%al cbw pop %edi @@ -81,12 +83,14 @@ ENTRY(getextmem2) popl %ebp ret -/* int getmementry(int *iterator, buffer[5]) - return: 0=ok, else error - buffer[0]: start of memory chunk - buffer[2]: length (bytes) - buffer[4]: type -*/ +/* + * int getmementry(int *iterator, int buffer[5]) + * + * return: 0=ok, else error + * buffer[0]: start of memory chunk + * buffer[2]: length (bytes) + * buffer[4]: type + */ ENTRY(getmementry) pushl %ebp movl %esp,%ebp @@ -96,24 +100,24 @@ ENTRY(getmementry) push %esi push %edi - movl 8(%ebp), %eax - movl 0(%eax), %ebx /* index */ - movl $20, %ecx /* Buffer size */ - movl $0x534d4150, %edx /* "SMAP" */ - movl 12(%ebp), %edi /* buffer address */ + movl 8(%ebp),%eax + movl 0(%eax),%ebx /* index */ + movl $20,%ecx /* Buffer size */ + movl $0x534d4150,%edx /* "SMAP" */ + movl 12(%ebp),%edi /* buffer address */ call _C_LABEL(prot_to_real) .code16 push %di - shrl $4, %edi - mov %ds, %ax - add %di, %ax - mov %ax, %es + shrl $4,%edi + mov %ds,%ax + add %di,%ax + mov %ax,%es pop %di - and $0xf, %di /* buffer addres now in ES:DI */ + and $0xf,%di /* buffer addres now in ES:DI */ - movl $0xe820, %eax /* Some BIOS check EAX value */ + movl $0xe820,%eax /* Some BIOS check EAX value */ int $0x15 setc %cl @@ -121,10 +125,10 @@ ENTRY(getmementry) calll _C_LABEL(real_to_prot) .code32 - movl 8(%ebp), %eax - movl %ebx, 0(%eax) /* updated index */ - xorl %eax, %eax - movb %cl, %al + movl 8(%ebp),%eax + movl %ebx,0(%eax) /* updated index */ + xorl %eax,%eax + movb %cl,%al pop %edi pop %esi @@ -134,9 +138,11 @@ ENTRY(getmementry) popl %ebp ret -/* int biosA20(void) - return: 0=ok, else error -*/ +/* + * int biosA20(void) + * + * return: 0=ok, else error + */ ENTRY(biosA20) pushl %ebp movl %esp,%ebp @@ -149,14 +155,14 @@ ENTRY(biosA20) call _C_LABEL(prot_to_real) .code16 - movl $0x2401, %eax + movl $0x2401,%eax int $0x15 setc %cl calll _C_LABEL(real_to_prot) .code32 - movzbl %cl, %eax + movzbl %cl,%eax pop %edi pop %esi Index: src/sys/arch/i386/stand/lib/biosmemps2.S diff -u src/sys/arch/i386/stand/lib/biosmemps2.S:1.6 src/sys/arch/i386/stand/lib/biosmemps2.S:1.7 --- src/sys/arch/i386/stand/lib/biosmemps2.S:1.6 Thu Jun 16 13:27:59 2011 +++ src/sys/arch/i386/stand/lib/biosmemps2.S Sun Dec 4 08:21:08 2016 @@ -1,6 +1,6 @@ -/* $NetBSD: biosmemps2.S,v 1.6 2011/06/16 13:27:59 joerg Exp $ */ +/* $NetBSD: biosmemps2.S,v 1.7 2016/12/04 08:21:08 maxv Exp $ */ -/*- +/* * Copyright (c) 2003 The NetBSD Foundation, Inc. * All rights reserved. * @@ -33,55 +33,58 @@ .text -/* int getextmemp2(void buffer) - call int 15 function 0xc7 - later PS/2s - RETURN MEMORY-MAP INFORMATION - return: 0=OK, nonzero=error - buffer: filled with memory-map table structure -*/ +/* + * int getextmemps2(void *buffer) + * + * call int 15 function 0xc7 - later PS/2s - RETURN MEMORY-MAP INFORMATION + * return: 0=OK, nonzero=error + * buffer: filled with memory-map table structure + */ ENTRY(getextmemps2) .code32 - movl %eax, %edx - xorl %eax, %eax + movl %eax,%edx + xorl %eax,%eax pusha call _C_LABEL(prot_to_real) .code16 - # do int15, function 0xc0 call to discover if C7h is supported - movb $0xc0, %ah + /* do int15, function 0xc0 call to discover if C7h is supported */ + movb $0xc0,%ah int $0x15 setc %cl - jc out # 0xc0 not supported if carry set + jc out /* 0xc0 not supported if carry set */ - # check feature byte 2, bit 4 to see if return memory map is supported - movb %es:6(%bx), %al - andb $0x10, %al - jnz getmem # 0xc7 supported - - # set %cl to indicate failure, and exit - movb $2, %cl + /* check feature byte 2, bit 4 to see if return memory map is supported */ + movb %es:6(%bx),%al + andb $0x10,%al + jnz getmem /* 0xc7 supported */ + + /* set %cl to indicate failure, and exit */ + movb $2,%cl jmp out getmem: - # move the parameter to right register + /* move the parameter to right register */ push %ds - movl %edx, %esi - andl $0xf, %esi - shrl $4, %edx - mov %ds, %ax - add %dx, %ax - mov %ax, %ds + movl %edx,%esi + andl $0xf,%esi + shrl $4,%edx + mov %ds,%ax + add %dx,%ax + mov %ax,%ds - # actually call int15, function 0xc7 now - movb $0xc7, %ah + /* actually call int15, function 0xc7 now */ + movb $0xc7,%ah int $0x15 - setc %cl # save carry + setc %cl /* save carry */ pop %ds out: calll _C_LABEL(real_to_prot) .code32 - movb %cl, 28(%esp) + movb %cl,28(%esp) popa ret + Index: src/sys/arch/i386/stand/lib/exec.c diff -u src/sys/arch/i386/stand/lib/exec.c:1.61 src/sys/arch/i386/stand/lib/exec.c:1.62 --- src/sys/arch/i386/stand/lib/exec.c:1.61 Sun Jun 5 14:13:57 2016 +++ src/sys/arch/i386/stand/lib/exec.c Sun Dec 4 08:21:08 2016 @@ -1,6 +1,6 @@ -/* $NetBSD: exec.c,v 1.61 2016/06/05 14:13:57 maxv Exp $ */ +/* $NetBSD: exec.c,v 1.62 2016/12/04 08:21:08 maxv Exp $ */ -/*- +/* * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. * All rights reserved. * @@ -88,8 +88,7 @@ */ /* - * starts NetBSD a.out kernel - * needs lowlevel startup from startprog.S + * Starts a NetBSD ELF kernel. The low level startup is done in startprog.S. * This is a special version of exec.c to support use of XMS. */ @@ -260,8 +259,8 @@ common_load_kernel(const char *file, u_l { int fd; #ifdef XMS - u_long xmsmem; - physaddr_t origaddr = loadaddr; + u_long xmsmem; + physaddr_t origaddr = loadaddr; #endif *extmem = getextmem(); @@ -269,14 +268,14 @@ common_load_kernel(const char *file, u_l #ifdef XMS if ((getextmem1() == 0) && (xmsmem = checkxms())) { - u_long kernsize; + u_long kernsize; /* * With "CONSERVATIVE_MEMDETECT", extmem is 0 because - * getextmem() is getextmem1(). Without, the "smart" - * methods could fail to report all memory as well. + * getextmem() is getextmem1(). Without, the "smart" + * methods could fail to report all memory as well. * xmsmem is a few kB less than the actual size, but - * better than nothing. + * better than nothing. */ if (xmsmem > *extmem) *extmem = xmsmem; @@ -343,17 +342,17 @@ common_load_kernel(const char *file, u_l int exec_netbsd(const char *file, physaddr_t loadaddr, int boothowto, int floppy, - void (*callback)(void)) + void (*callback)(void)) { - uint32_t boot_argv[BOOT_NARGS]; - u_long marks[MARK_MAX]; + uint32_t boot_argv[BOOT_NARGS]; + u_long marks[MARK_MAX]; struct btinfo_symtab btinfo_symtab; - u_long extmem; - u_long basemem; + u_long extmem; + u_long basemem; #ifdef DEBUG - printf("exec: file=%s loadaddr=0x%lx\n", - file ? file : "NULL", loadaddr); + printf("exec: file=%s loadaddr=0x%lx\n", file ? file : "NULL", + loadaddr); #endif BI_ALLOC(BTINFO_MAX); @@ -406,7 +405,7 @@ exec_netbsd(const char *file, physaddr_t if (callback != NULL) (*callback)(); startprog(marks[MARK_ENTRY], BOOT_NARGS, boot_argv, - x86_trunc_page(basemem*1024)); + x86_trunc_page(basemem * 1024)); panic("exec returned"); out: @@ -670,11 +669,11 @@ exec_multiboot(const char *file, char *a struct multiboot_info *mbi; struct multiboot_module *mbm; struct bi_modulelist_entry *bim; - int i, len; - u_long marks[MARK_MAX]; - u_long extmem; - u_long basemem; - char *cmdline; + int i, len; + u_long marks[MARK_MAX]; + u_long extmem; + u_long basemem; + char *cmdline; mbi = alloc(sizeof(struct multiboot_info)); mbi->mi_flags = MULTIBOOT_INFO_HAS_MEMORY; @@ -721,7 +720,6 @@ exec_multiboot(const char *file, char *a marks[MARK_NSYM], marks[MARK_SYM], marks[MARK_END]); #endif - #if 0 if (btinfo_symtab.nsym) { mbi->mi_flags |= MULTIBOOT_INFO_HAS_ELF_SYMS; @@ -732,11 +730,11 @@ exec_multiboot(const char *file, char *a #endif multiboot(marks[MARK_ENTRY], vtophys(mbi), - x86_trunc_page(mbi->mi_mem_lower*1024)); + x86_trunc_page(mbi->mi_mem_lower * 1024)); panic("exec returned"); out: - dealloc(mbi, 0); + dealloc(mbi, 0); return -1; } Index: src/sys/arch/i386/stand/lib/multiboot.S diff -u src/sys/arch/i386/stand/lib/multiboot.S:1.1 src/sys/arch/i386/stand/lib/multiboot.S:1.2 --- src/sys/arch/i386/stand/lib/multiboot.S:1.1 Sat Oct 11 11:06:20 2008 +++ src/sys/arch/i386/stand/lib/multiboot.S Sun Dec 4 08:21:08 2016 @@ -1,13 +1,6 @@ -/* $NetBSD: multiboot.S,v 1.1 2008/10/11 11:06:20 joerg Exp $ */ - -/* starts program in protected mode / flat space - with given stackframe - needs global variables flatcodeseg and flatdataseg - (gdt offsets) - derived from: NetBSD:sys/arch/i386/stand/lib/startprog.S - */ +/* $NetBSD: multiboot.S,v 1.2 2016/12/04 08:21:08 maxv Exp $ */ -/*- +/* * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * @@ -62,63 +55,71 @@ */ /* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ + * Copyright 1988, 1989, 1990, 1991, 1992 + * by Intel Corporation, Santa Clara, California. + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appears in all + * copies and that both the copyright notice and this permission notice + * appear in supporting documentation, and that the name of Intel + * not be used in advertising or publicity pertaining to distribution + * of the software without specific, written prior permission. + * + * INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ #include <machine/asm.h> #define MULTIBOOT_INFO_MAGIC 0x2BADB002 /* - * multiboot(phyaddr,header,stack) + * Starts program in protected mode / flat space with given stackframe. + * Needs global variables flatcodeseg and flatdataseg (gdt offsets). + * Derived from: NetBSD:sys/arch/i386/stand/lib/startprog.S + */ + +/* + * multiboot(phyaddr, header, stack) * start the program on protected mode where phyaddr is the entry point */ ENTRY(multiboot) pushl %ebp - movl %esp, %ebp + movl %esp,%ebp - # prepare a new stack - movl $flatdataseg, %eax - movw %ax, %es # for arg copy - movl 16(%ebp), %ebx # stack + /* Prepare a new stack */ + movl $flatdataseg,%eax + movw %ax,%es /* for arg copy */ + movl 16(%ebp),%ebx /* stack */ subl $4,%ebx - movl %ebx, %edi + movl %ebx,%edi + + movl 12(%ebp),%ebx /* header */ + movl 8(%ebp),%ecx /* entry */ - movl 12(%ebp), %ebx # header - movl 8(%ebp), %ecx # entry + /* Set new stack pointer */ + movw %ax,%ss + movl %edi,%esp - # set new stackptr (movsl decd sp 1 more -> dummy return address) - movw %ax, %ss - movl %edi, %esp - - # push on our entry address - movl $flatcodeseg, %eax # segment - pushl %eax - pushl %ecx #entry - - # convert over the other data segs - movl $flatdataseg, %eax - mov %ax, %ds - mov %ax, %es + /* Push on our entry address */ + movl $flatcodeseg,%eax + pushl %eax /* code segment */ + pushl %ecx /* phyaddr */ - movl $MULTIBOOT_INFO_MAGIC, %eax - # convert the PC (and code seg) + /* Convert over the other data segs */ + movl $flatdataseg,%eax + mov %ax,%ds + mov %ax,%es + + movl $MULTIBOOT_INFO_MAGIC,%eax + + /* Jump to phyaddr, with the new code segment */ lret + Index: src/sys/arch/i386/stand/lib/startprog.S diff -u src/sys/arch/i386/stand/lib/startprog.S:1.3 src/sys/arch/i386/stand/lib/startprog.S:1.4 --- src/sys/arch/i386/stand/lib/startprog.S:1.3 Sat Feb 1 14:48:18 2003 +++ src/sys/arch/i386/stand/lib/startprog.S Sun Dec 4 08:21:08 2016 @@ -1,11 +1,4 @@ -/* $NetBSD: startprog.S,v 1.3 2003/02/01 14:48:18 dsl Exp $ */ - -/* starts program in protected mode / flat space - with given stackframe - needs global variables flatcodeseg and flatdataseg - (gdt offsets) - derived from: NetBSD:sys/arch/i386/boot/asm.S - */ +/* $NetBSD: startprog.S,v 1.4 2016/12/04 08:21:08 maxv Exp $ */ /* * Ported to boot 386BSD by Julian Elischer (jul...@tfs.com) Sept 1992 @@ -36,75 +29,80 @@ */ /* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ + * Copyright 1988, 1989, 1990, 1991, 1992 + * by Intel Corporation, Santa Clara, California. + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appears in all + * copies and that both the copyright notice and this permission notice + * appear in supporting documentation, and that the name of Intel + * not be used in advertising or publicity pertaining to distribution + * of the software without specific, written prior permission. + * + * INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ #include <machine/asm.h> /* - * startprog(phyaddr,argc,argv,stack) + * Starts program in protected mode / flat space with given stackframe. + * Needs global variables flatcodeseg and flatdataseg (gdt offsets). + */ + +/* + * startprog(phyaddr, argc, argv, stack) * start the program on protected mode where phyaddr is the entry point */ ENTRY(startprog) pushl %ebp - movl %esp, %ebp + movl %esp,%ebp - # prepare a new stack - movl $flatdataseg, %ebx - movw %bx, %es # for arg copy - movl 20(%ebp), %eax # stack + /* Prepare a new stack */ + movl $flatdataseg,%ebx + movw %bx,%es /* for arg copy */ + movl 20(%ebp),%eax /* stack */ subl $4,%eax - movl %eax, %edi - - # push some number of args onto the stack - movl 12(%ebp), %ecx # argc + movl %eax,%edi - movl %ecx, %eax + /* Push some number of args onto the stack */ + movl 12(%ebp),%ecx /* argc */ + movl %ecx,%eax decl %eax - shl $2, %eax - addl 16(%ebp), %eax # ptr to last arg - movl %eax, %esi + shl $2,%eax + addl 16(%ebp),%eax /* ptr to last arg */ + movl %eax,%esi - std # backwards + std /* backwards */ rep - movsl + movsl /* copy %ds:(%esi) -> %es:(%edi) */ - cld # LynxOS depends on it + cld - movl 8(%ebp), %ecx # entry + movl 8(%ebp),%ecx /* entry */ - # set new stackptr (movsl decd sp 1 more -> dummy return address) - movw %bx, %ss - movl %edi, %esp + /* Set new stack pointer (movsl decd sp 1 more -> dummy return address) */ + movw %bx,%ss + movl %edi,%esp - # push on our entry address - movl $flatcodeseg, %ebx # segment - pushl %ebx - pushl %ecx #entry + /* Push on our entry address */ + movl $flatcodeseg,%ebx + pushl %ebx /* code segment */ + pushl %ecx /* phyaddr */ - # convert over the other data segs - movl $flatdataseg, %ebx - mov %bx, %ds - mov %bx, %es + /* Convert over the other data segs */ + movl $flatdataseg,%ebx + mov %bx,%ds + mov %bx,%es - # convert the PC (and code seg) + /* Jump to phyaddr, with the new code segment */ lret +