Make sure we use calll/retl for the C code, so the stack frame layout
[profile/ivi/syslinux.git] / memdisk / conio.c
1 #ident "$Id$"
2 /* ----------------------------------------------------------------------- *
3  *   
4  *   Copyright 2001 H. Peter Anvin - All Rights Reserved
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9  *   Bostom MA 02111-1307, USA; either version 2 of the License, or
10  *   (at your option) any later version; incorporated herein by reference.
11  *
12  * ----------------------------------------------------------------------- */
13
14 /*
15  * conio.c
16  *
17  * Output to the screen
18  */
19
20 #include <stdint.h>
21 #include "conio.h"
22
23 int putchar(int ch)
24 {
25   if ( ch == '\n' )
26     putchar('\r');              /* \n -> \r\n */
27
28   asm volatile("int $0x10"
29                :: "a" ((uint16_t)(0x0e00|(ch&0xff))),
30                "b" ((uint16_t)0x07)
31                : "eax", "ebx", "ecx", "edx",
32                "esi", "edi", "ebp");
33
34   return ch;
35 }
36
37 int puts(const char *s)
38 {
39   int count = 0;
40
41   while ( *s ) {
42     putchar(*s);
43     count++;
44     s++;
45   }
46
47   return count;
48 }