From 71f30d9fccf71b4c6be7a01a3b47deaa2e5ab3c6 Mon Sep 17 00:00:00 2001 From: hpa Date: Sat, 13 Dec 2003 02:22:56 +0000 Subject: [PATCH] Minor com32 wrapper code cleanup --- comboot.doc | 1 + sample/Makefile | 8 ++++++-- sample/c32entry.S | 7 +++++-- sample/c32exit.S | 10 ++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 sample/c32exit.S diff --git a/comboot.doc b/comboot.doc index 9132bf2..e9327f5 100644 --- a/comboot.doc +++ b/comboot.doc @@ -79,6 +79,7 @@ notification to the program how much memory is available. The following arguments are passed to the program on the stack: Address Size Meaning + [ESP] dword Return (termination) address [ESP+4] dword Number of additional arguments (currently 5) [ESP+8] dword Pointer to the command line arguments (null-terminated string) [ESP+12] dword Pointer to INT call helper function diff --git a/sample/Makefile b/sample/Makefile index 8964c00..8a2eb6d 100644 --- a/sample/Makefile +++ b/sample/Makefile @@ -27,18 +27,22 @@ OBJCOPY = objcopy PPMTOLSS16 = ../ppmtolss16 LIB = libcom32.a -LIBOBJS = conio.o atou.o skipatou.o printf.o +LIBOBJS = conio.o atou.o skipatou.o printf.o c32exit.o .SUFFIXES: .lss .c .o .elf .c32 -all: syslogo.lss comecho.com hello.c32 hello2.c32 filetest.c32 c32echo.c32 fd.c32 chain.c32 +all: syslogo.lss comecho.com hello.c32 hello2.c32 filetest.c32 c32echo.c32 \ + fd.c32 chain.c32 $(LIB) +.PRECIOUS: %.o %.o: %.S $(CC) $(SFLAGS) -c -o $@ $< +.PRECIOUS: %.o %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< +.PRECIOUS: %.elf %.elf: c32entry.o %.o $(LIB) $(LD) -Ttext 0x101000 -e _start -o $@ $^ diff --git a/sample/c32entry.S b/sample/c32entry.S index 1ae57a2..ee71d8f 100644 --- a/sample/c32entry.S +++ b/sample/c32entry.S @@ -47,9 +47,10 @@ _start: rep ; stosl # Copy COM32 invocation parameters - leal 4(%esp),%esi + leal 4(%esp),%esi # Argument list movl $__com32,%edi movl $6,%ecx + movl %esp,-4(%edi) # Save the initial stack ptr cmpl (%esi),%ecx jbe 1f movl (%esi),%ecx @@ -60,5 +61,7 @@ _start: jmp __start .section ".bss","a" + .globl __entry_esp +__entry_esp: .space 4 .globl __com32 -__com32: .space 24 +__com32: .space 4*6 diff --git a/sample/c32exit.S b/sample/c32exit.S new file mode 100644 index 0000000..5c5ba03 --- /dev/null +++ b/sample/c32exit.S @@ -0,0 +1,10 @@ +# $Id# +# +# Implementation of exit() for com32 based on c32entry.S +# + .text + .globl exit +exit: + movl 4(%esp),%eax # Exit code in %eax = return value + movl (__entry_esp),%esp # Return stack pointer to entry value + ret # Return to termination address -- 2.7.4