mbr: clean up *_bin.c files
[syslinux.git] / sample / hello2.c
blob1308a31bfa708bdd8e10abec0b113c47c10460cf
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2002-2008 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
14 * hello2.c
16 * Simple COM32 image
18 * This version shows how to use the bounce buffer for data transfer
19 * to the BIOS or COMBOOT system calls.
22 #include <com32.h>
24 #define NULL ((void *)0)
26 static inline void memset(void *buf, int ch, unsigned int len)
28 asm volatile("cld; rep; stosb"
29 : "+D" (buf), "+c" (len) : "a" (ch) : "memory");
32 static void strcpy(char *dst, const char *src)
34 while ( *src )
35 *dst++ = *src++;
37 *dst = '\0';
40 static void writemsg(const char *msg)
42 com32sys_t inreg;
44 memset(&inreg, 0, sizeof inreg);
46 strcpy(__com32.cs_bounce, msg);
47 inreg.eax.w[0] = 0x0002; /* Write string */
48 inreg.ebx.w[0] = OFFS(__com32.cs_bounce);
49 inreg.es = SEG(__com32.cs_bounce);
50 __com32.cs_intcall(0x22, &inreg, NULL);
53 int __start(void)
55 writemsg("Hello, World!\r\n"
56 "cmdline = ");
57 writemsg(__com32.cs_cmdline);
58 writemsg("\r\n");
59 return 0;