Makefile: add isohybrid as an IOBJECT
[syslinux.git] / sample / conio.c
blob6698deedae0ef44c6e716620e6e69f3a5860b093
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2001-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 * conio.c
16 * Output to the screen
19 #include <com32.h>
20 #include <stdarg.h>
22 #define NULL ((void *)0)
24 static inline void memset(void *buf, int ch, unsigned int len)
26 asm volatile("cld; rep; stosb"
27 : "+D" (buf), "+c" (len) : "a" (ch) : "memory");
30 int putchar(int ch)
32 com32sys_t regs;
34 memset(&regs, 0, sizeof regs);
36 if ( ch == '\n' ) {
37 /* \n -> \r\n */
38 putchar('\r');
41 regs.eax.b[1] = 0x02;
42 regs.edx.b[0] = ch;
43 __com32.cs_intcall(0x21, &regs, NULL);
45 return ch;
48 /* Note: doesn't put '\n' like the stdc version does */
49 int puts(const char *s)
51 int count = 0;
53 while ( *s ) {
54 putchar(*s);
55 count++;
56 s++;
59 return count;