summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorhpa <hpa>2003-11-24 02:44:42 +0000
committerhpa <hpa>2003-11-24 02:44:42 +0000
commit43cf4dda600db1ccd05d9788c7b1da0cde7c0413 (patch)
tree0c69eaa8d2e0f49bc4ea8770762a97d4552771ad /sample
parent4a10396ab1f114fc37fa8f276e047fe3c283671c (diff)
downloadsyslinux-43cf4dda600db1ccd05d9788c7b1da0cde7c0413.tar.gz
Fix COMBOOT/COM32 command-line generation.syslinux-2.08-pre1
Add test programs.
Diffstat (limited to 'sample')
-rw-r--r--sample/Makefile6
-rw-r--r--sample/c32echo.c49
-rw-r--r--sample/comecho.asm35
3 files changed, 89 insertions, 1 deletions
diff --git a/sample/Makefile b/sample/Makefile
index 0d23c98f..373828c3 100644
--- a/sample/Makefile
+++ b/sample/Makefile
@@ -18,6 +18,7 @@
CC = gcc
LD = ld
AR = ar
+NASM = nasm
RANLIB = ranlib
CFLAGS = -march=i386 -O2 -fomit-frame-pointer -I../com32/include
SFLAGS = -march=i386
@@ -30,7 +31,7 @@ LIBOBJS = conio.o
.SUFFIXES: .lss .c .o .elf .c32
-all: syslogo.lss hello.c32 hello2.c32 filetest.c32
+all: syslogo.lss comecho.com hello.c32 hello2.c32 filetest.c32 c32echo.c32
%.o: %.S
$(CC) $(SFLAGS) -c -o $@ $<
@@ -44,6 +45,9 @@ all: syslogo.lss hello.c32 hello2.c32 filetest.c32
%.c32: %.elf
$(OBJCOPY) -O binary $< $@
+%.com: %.asm
+ $(NASM) -f bin -o $@ -l $*.lst $<
+
$(LIB): $(LIBOBJS)
rm -f $@
$(AR) cq $@ $^
diff --git a/sample/c32echo.c b/sample/c32echo.c
new file mode 100644
index 00000000..9733d41f
--- /dev/null
+++ b/sample/c32echo.c
@@ -0,0 +1,49 @@
+#ident "$Id$"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2002 H. Peter Anvin - All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Bostom MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * c32echo.c
+ *
+ * Simple COM32 program which only prints out its own command line
+ */
+
+#include <com32.h>
+
+#define NULL ((void *)0)
+
+static inline void memset(void *buf, int ch, unsigned int len)
+{
+ asm volatile("cld; rep; stosb"
+ : "+D" (buf), "+c" (len) : "a" (ch) : "memory");
+}
+
+int __start(void)
+{
+ com32sys_t inreg, outreg;
+ const char *p;
+
+ memset(&inreg, 0, sizeof inreg);
+ inreg.eax.b[1] = 0x02; /* Write Character */
+
+ for ( p = __com32.cs_cmdline ; *p ; p++ ) {
+ inreg.edx.b[0] = *p;
+ __com32.cs_intcall(0x21, &inreg, NULL);
+ }
+
+ inreg.edx.b[0] = '\r';
+ __com32.cs_intcall(0x21, &inreg, NULL);
+ inreg.edx.b[0] = '\n';
+ __com32.cs_intcall(0x21, &inreg, NULL);
+
+ return 0;
+}
diff --git a/sample/comecho.asm b/sample/comecho.asm
new file mode 100644
index 00000000..3cdf601a
--- /dev/null
+++ b/sample/comecho.asm
@@ -0,0 +1,35 @@
+;
+; Simple COMBOOT program that just prints out its own command line.
+; This also works in DOS.
+;
+
+ org 100h
+
+_start:
+ xor cx,cx
+ mov cl,[80h] ; Command line len
+ mov si,81h ; Command line
+
+ mov dl,"<"
+ mov ah,02h
+ int 21h
+
+.writechar:
+ lodsb
+ mov dl,al
+ mov ah,02h
+ int 21h
+ loop .writechar
+
+ mov dx,end_str
+ mov ah,09h
+ int 21h
+
+ ; Exit with near return, INT 20h, or INT 21h AX=4C00h
+ ret
+
+
+end_str db ">", 0Dh, 0Ah, "$"
+
+
+ \ No newline at end of file